@subconverter/core 0.2.1 → 0.4.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.
package/dist/index.d.cts CHANGED
@@ -189,6 +189,13 @@ interface RulesetContent {
189
189
  /** Create a ruleset config with subconverter's defaults. */
190
190
  declare function createRulesetConfig(): RulesetConfig;
191
191
 
192
+ /** Clash kernel flavor targeted by Clash output (`flavor=`). */
193
+ type ClashFlavor = "mihomo" | "premium" | "stash";
194
+ /**
195
+ * Parse a `flavor=` value (case-insensitive); unknown values fall back to
196
+ * `mihomo`, mirroring subconverter-rs `ClashFlavor::from_str`.
197
+ */
198
+ declare function parseClashFlavor(value: string | undefined | null): ClashFlavor;
192
199
  /** A regex/script rewrite rule, mirroring `RegexMatchConfig`. */
193
200
  interface RegexMatchConfig {
194
201
  match: string;
@@ -228,15 +235,24 @@ interface ExtraSettings {
228
235
  nameRemove: string[];
229
236
  addEmoji: boolean;
230
237
  removeEmoji: boolean;
231
- /** Prefix node names with the server's country/region when the name lacks one. */
238
+ /** Prefix node names with the server's ISO country code when the name lacks one. */
232
239
  autoCountry: boolean;
233
- /** Locale used for `Intl.DisplayNames` country names (default `zh-CN`). */
234
- countryLocale: string;
235
240
  /**
236
241
  * Resolve a node's ISO 3166-1 alpha-2 country code. Platform-free: the Node
237
242
  * adapter supplies a GeoIP-backed lookup; browsers may supply their own.
243
+ * Required by `autoCountry` and the country filters below.
238
244
  */
239
245
  countryResolver?: (node: Proxy) => string | undefined;
246
+ /** Keep only nodes whose GeoIP country is in this ISO code list. */
247
+ includeCountries: string[];
248
+ /** Drop nodes whose GeoIP country is in this ISO code list. */
249
+ excludeCountries: string[];
250
+ /** Keep only nodes matching one of these remark rules (empty keeps all). */
251
+ includeRemarks: string[];
252
+ /** Drop nodes matching one of these remark rules. */
253
+ excludeRemarks: string[];
254
+ /** `false` keeps remote rulesets as `RULE-SET` references (Surge-family). */
255
+ expandRulesets: boolean;
240
256
  appendProxyType: boolean;
241
257
  nodeList: boolean;
242
258
  sortFlag: boolean;
@@ -244,6 +260,10 @@ interface ExtraSettings {
244
260
  clashNewFieldName: boolean;
245
261
  clashScript: boolean;
246
262
  clashClassicalRuleset: boolean;
263
+ /** Target Clash kernel: dropped protocols/fields follow its capabilities. */
264
+ clashFlavor: ClashFlavor;
265
+ /** Template variables applied to `{{ var }}` placeholders in base configs. */
266
+ templateVars: Record<string, string>;
247
267
  dedupe: boolean;
248
268
  surgeSsrPath: string;
249
269
  managedConfigPrefix: string;
@@ -273,6 +293,10 @@ interface RequestSettings {
273
293
  nameRemove: string[];
274
294
  includeRemarks: string[];
275
295
  excludeRemarks: string[];
296
+ /** Keep only nodes whose GeoIP country is in this ISO code list. */
297
+ includeCountries: string[];
298
+ /** Drop nodes whose GeoIP country is in this ISO code list. */
299
+ excludeCountries: string[];
276
300
  addEmoji: boolean;
277
301
  removeEmoji: boolean;
278
302
  autoCountry: boolean;
@@ -288,6 +312,16 @@ interface RequestSettings {
288
312
  tls13: TriBool;
289
313
  newFieldName: boolean;
290
314
  classicalRuleset: boolean;
315
+ /** Target Clash kernel (`flavor=`): mihomo (default), premium, or stash. */
316
+ clashFlavor: ClashFlavor;
317
+ /** `false` keeps remote rulesets as `RULE-SET` references (Surge-family). */
318
+ expand: boolean;
319
+ /** Managed-config `strict=` flag for Surge-family `#!MANAGED-CONFIG`. */
320
+ strict: boolean;
321
+ /** Download filename override (`filename=`). */
322
+ filename: string;
323
+ /** Quantumult X device ID for remote-script signatures (`dev_id=`). */
324
+ devId: string;
291
325
  insert: boolean;
292
326
  mixin: string;
293
327
  interval: number;
@@ -365,7 +399,7 @@ declare function trim(input: string): string;
365
399
  declare function trimLowerCase(input: string): string;
366
400
  /** Parse the leading integer of a string; `0` when none is present. */
367
401
  declare function toInt(value: string | number | undefined | null): number;
368
- /** Parse a boolean-ish value ("true"/"false"/"1"/"0"). */
402
+ /** Parse a boolean-ish value ("true"/"yes"/"1"/"on" and the matching negatives). */
369
403
  declare function toBool(value: string | undefined | null): boolean;
370
404
  /** `true` when `needle` occurs in `haystack`. */
371
405
  declare function strFind(haystack: string, needle: string): boolean;
@@ -449,6 +483,13 @@ declare function hasTemplatePlaceholders(content: string): boolean;
449
483
  /** Collect the variable names referenced by a template body. */
450
484
  declare function templateVariableNames(content: string): string[];
451
485
 
486
+ /** `ruleset=` dialect prefixes (`surge:`, `quanx:`, `clash-domain:`, …). */
487
+ declare const RULESET_TYPE_PREFIXES: ReadonlyArray<readonly [string, RulesetType]>;
488
+ /** Split a ruleset source into its dialect prefix plus the bare URL/content. */
489
+ declare function parseRulesetSource(source: string): {
490
+ url: string;
491
+ type?: RulesetType;
492
+ };
452
493
  /** A parsed subconverter external configuration file. */
453
494
  interface ExternalConfig {
454
495
  groups: ProxyGroupConfig[];
@@ -459,6 +500,8 @@ interface ExternalConfig {
459
500
  nameRemove: string[];
460
501
  includeRemarks: string[];
461
502
  excludeRemarks: string[];
503
+ includeCountries: string[];
504
+ excludeCountries: string[];
462
505
  addEmoji: boolean;
463
506
  removeEmoji: boolean;
464
507
  autoCountry: boolean;
@@ -879,6 +922,12 @@ declare function explodeTrojan(trojan: string, node: Proxy): void;
879
922
  declare function explodeHysteria2(link: string, node: Proxy): void;
880
923
  /** Parse an `anytls://` link. */
881
924
  declare function explodeAnyTls(link: string, node: Proxy): void;
925
+ /** Parse a `snell://psk@host:port?...` link. */
926
+ declare function explodeSnell(link: string, node: Proxy): void;
927
+ /** Parse a `hysteria://host:port?...` (v1) link. */
928
+ declare function explodeHysteria(link: string, node: Proxy): void;
929
+ /** Parse a `wg://` / `wireguard://host:port?...` link. */
930
+ declare function explodeWireguard(link: string, node: Proxy): void;
882
931
  /** Parse a `vless://` link. */
883
932
  declare function explodeVless(link: string, node: Proxy): void;
884
933
  /** Parse a `tuic://` link. */
@@ -967,13 +1016,13 @@ declare function convertRuleset(content: string, type: RulesetType): string;
967
1016
  /** Rewrite `TYPE,VALUE[,flag]` into `TYPE,VALUE,GROUP[,flag]`. */
968
1017
  declare function transformRuleToCommon(input: string, group: string, noResolveOnly?: boolean): string;
969
1018
  /** Convert rulesets into an ordered list of Clash rule strings. */
970
- declare function rulesetToClashRules(rulesets: RulesetContent[]): string[];
1019
+ declare function rulesetToClashRules(rulesets: RulesetContent[], classical?: boolean): string[];
971
1020
  interface SurgeRulesetResult {
972
1021
  section: string;
973
1022
  lines: string[];
974
1023
  }
975
1024
  /** Convert rulesets into Surge/QuanX/Quan/Loon rule lines. */
976
- declare function rulesetToSurgeRules(rulesets: RulesetContent[], surgeVersion: number): SurgeRulesetResult;
1025
+ declare function rulesetToSurgeRules(rulesets: RulesetContent[], surgeVersion: number, expand?: boolean): SurgeRulesetResult;
977
1026
  declare const SING_BOX_RULE_TYPES: string[];
978
1027
  /** A sing-box `route` fragment produced from rulesets. */
979
1028
  interface SingBoxRoute {
@@ -1093,6 +1142,13 @@ declare function proxyToSsSub(nodes: Proxy[], baseConf: string): string;
1093
1142
  /** Export Shadowsocks nodes as an `ssd://` document. */
1094
1143
  declare function proxyToSsd(nodes: Proxy[], group: string, userinfo: string): string;
1095
1144
 
1145
+ /**
1146
+ * Patterns known to blow up the regex engine (mirrors subconverter-rs
1147
+ * `REGEX_BLACK_LIST`); requests carrying them are rejected outright.
1148
+ */
1149
+ declare const REGEX_BLACKLIST: readonly string[];
1150
+ /** `true` when `pattern` exactly matches a blacklisted catastrophic pattern. */
1151
+ declare function isBlacklistedPattern(pattern: string): boolean;
1096
1152
  /** Does `target` fall within a subconverter range expression like `1-5,8,!3`? */
1097
1153
  declare function matchRange(range: string, target: number): boolean;
1098
1154
  /**
@@ -1128,13 +1184,19 @@ declare function nodeNameRemove(node: Proxy, removeList: string[]): void;
1128
1184
  /** Apply rename rules to a node's remark (script rules are ignored). */
1129
1185
  declare function nodeRename(node: Proxy, renameArray: RegexMatchConfig[]): void;
1130
1186
  /**
1131
- * Prefix a node's remark with its server country/region when the remark does
1132
- * not already mention one (e.g. `server1` -> `美国-server1`).
1187
+ * Prefix a node's remark with its ISO server country when the remark does
1188
+ * not already mention one (e.g. `server1` -> `US-server1`).
1133
1189
  *
1134
1190
  * `resolve` returns an ISO 3166-1 alpha-2 code; a missing/unknown code leaves
1135
1191
  * the remark untouched. Mirrors the request `auto_country` switch.
1136
1192
  */
1137
- declare function addCountryPrefix(node: Proxy, resolve: (node: Proxy) => string | undefined, locale?: string): string;
1193
+ declare function addCountryPrefix(node: Proxy, resolve: (node: Proxy) => string | undefined): string;
1194
+ /**
1195
+ * Drop nodes by GeoIP country: keep only `include` codes (unknown countries
1196
+ * never match, so they are dropped), then drop `exclude` codes (unknown
1197
+ * countries are kept). Invalid codes are ignored.
1198
+ */
1199
+ declare function filterNodesByCountry(nodes: Proxy[], resolve: ((node: Proxy) => string | undefined) | undefined, include: string[], exclude: string[]): void;
1138
1200
  interface PreprocessOptions {
1139
1201
  removeEmoji: boolean;
1140
1202
  addEmoji: boolean;
@@ -1146,8 +1208,15 @@ interface PreprocessOptions {
1146
1208
  /** Literal fragments stripped from names before every other naming rule. */
1147
1209
  nameRemove?: string[];
1148
1210
  autoCountry?: boolean;
1149
- countryLocale?: string;
1150
1211
  countryResolver?: (node: Proxy) => string | undefined;
1212
+ /** Keep only nodes whose GeoIP country is in this ISO code list. */
1213
+ includeCountries?: string[];
1214
+ /** Drop nodes whose GeoIP country is in this ISO code list. */
1215
+ excludeCountries?: string[];
1216
+ /** Keep only nodes matching one of these remark rules (empty keeps all). */
1217
+ includeRemarks?: string[];
1218
+ /** Drop nodes matching one of these remark rules. */
1219
+ excludeRemarks?: string[];
1151
1220
  }
1152
1221
  /** Apply name cleanup, emoji removal, renaming, emoji insertion, and optional sorting. */
1153
1222
  declare function preprocessNodes(nodes: Proxy[], options: PreprocessOptions): void;
@@ -1155,16 +1224,18 @@ declare function preprocessNodes(nodes: Proxy[], options: PreprocessOptions): vo
1155
1224
  declare function dedupeNodes(nodes: Proxy[]): number;
1156
1225
 
1157
1226
  /**
1158
- * ISO 3166-1 alpha-2 region helpers used when a proxy name has no country.
1227
+ * ISO 3166-1 alpha-2 region helpers.
1159
1228
  *
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.
1229
+ * Emitted prefixes are always the uppercase ISO code (`US-server1`) so node
1230
+ * names stay stable across locales. Multilingual names (Chinese/English
1231
+ * spellings, flag emoji) are only recognized by `hasRegionName` so existing
1232
+ * names are never double-prefixed.
1233
+ */
1234
+ /**
1235
+ * Normalize user input to an ISO 3166-1 alpha-2 code (`"us"` -> `"US"`),
1236
+ * or `undefined` when it is not a known region. Used for country filters.
1163
1237
  */
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;
1238
+ declare function normalizeCountryCode(code: string): string | undefined;
1168
1239
  /** `true` when the code is a known ISO 3166-1 alpha-2 region. */
1169
1240
  declare function isRegionCode(code: string): boolean;
1170
1241
  /**
@@ -1174,9 +1245,10 @@ declare function isRegionCode(code: string): boolean;
1174
1245
  */
1175
1246
  declare function hasRegionName(remark: string): boolean;
1176
1247
  /**
1177
- * Prepend `name-` to a node remark (e.g. `server1` -> `美国-server1`).
1178
- * An empty remark becomes just the country name.
1248
+ * Prefix a remark with the ISO country code (e.g. `server1` -> `US-server1`).
1249
+ * An empty remark becomes just the code. Invalid codes leave the remark
1250
+ * unchanged.
1179
1251
  */
1180
- declare function formatCountryRemark(remark: string, code: string, locale?: string): string;
1252
+ declare function formatCountryRemark(remark: string, code: string): string;
1181
1253
 
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 };
1254
+ export { BalanceStrategy, CLASH_RULE_TYPES, type ClashFlavor, 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, REGEX_BLACKLIST, RULESET_TYPE_PREFIXES, 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, explodeHysteria, explodeHysteria2, explodeKitsunebi, explodeNetch, explodeNetchConf, explodeQuan, explodeShadowrocket, explodeSnell, explodeSocks, explodeSs, explodeSsAndroid, explodeSsConf, explodeSsd, explodeSsr, explodeSsrConf, explodeSstap, explodeStdVmess, explodeSub, explodeSurge, explodeTrojan, explodeTuic, explodeVless, explodeVmess, explodeVmessConf, explodeWireguard, filterNodes, filterNodesByCountry, findSection, fnv1a64, fnv1a64Hex, formatCountryRemark, formatSingBoxInterval, formatSubscriptionUserinfo, generate, generatePeer, getAllUrlArgs, getDefaultProxyGroups, getDefaultRulesetConfigs, getDefaultRulesets, getSectionItems, getUrlArg, groupGenerate, hasRegionName, hasTemplatePlaceholders, httpConstruct, hysteria2Construct, hysteriaConstruct, inferUserinfoProviderFromUrl, isBlacklistedPattern, isBlank, isFlattenableSsr, isIp, isIpv4, isIpv6, isLink, isRegionCode, isSsCipher, matchRange, nextMonthlyResetTimestamp, nodeNameRegex, nodeNameRemove, nodeRename, normalizeCountryCode, normalizeQueryKey, normalizeUserinfoProvider, pad2, parseClashFlavor, parseClashText, parseConfContent, parseCustomProxyGroup, parseExternalConfig, parseGroupTimes, parseIni, parseJmsUserinfo, parseLink, parsePeers, parseProxyGroupType, parseRawIni, parseRegexMatch, parseRequestSettings, parseRulesetConfig, parseRulesetSource, parseSubscription, parseSubscriptionUserinfo, parseTriBool, preprocessNodes, processRemark, proxyToSingle, proxyToSsSub, proxyToSsd, proxyTypeName, queryBoolFlag, regMatch, regReplace, 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 };
package/dist/index.d.ts CHANGED
@@ -189,6 +189,13 @@ interface RulesetContent {
189
189
  /** Create a ruleset config with subconverter's defaults. */
190
190
  declare function createRulesetConfig(): RulesetConfig;
191
191
 
192
+ /** Clash kernel flavor targeted by Clash output (`flavor=`). */
193
+ type ClashFlavor = "mihomo" | "premium" | "stash";
194
+ /**
195
+ * Parse a `flavor=` value (case-insensitive); unknown values fall back to
196
+ * `mihomo`, mirroring subconverter-rs `ClashFlavor::from_str`.
197
+ */
198
+ declare function parseClashFlavor(value: string | undefined | null): ClashFlavor;
192
199
  /** A regex/script rewrite rule, mirroring `RegexMatchConfig`. */
193
200
  interface RegexMatchConfig {
194
201
  match: string;
@@ -228,15 +235,24 @@ interface ExtraSettings {
228
235
  nameRemove: string[];
229
236
  addEmoji: boolean;
230
237
  removeEmoji: boolean;
231
- /** Prefix node names with the server's country/region when the name lacks one. */
238
+ /** Prefix node names with the server's ISO country code when the name lacks one. */
232
239
  autoCountry: boolean;
233
- /** Locale used for `Intl.DisplayNames` country names (default `zh-CN`). */
234
- countryLocale: string;
235
240
  /**
236
241
  * Resolve a node's ISO 3166-1 alpha-2 country code. Platform-free: the Node
237
242
  * adapter supplies a GeoIP-backed lookup; browsers may supply their own.
243
+ * Required by `autoCountry` and the country filters below.
238
244
  */
239
245
  countryResolver?: (node: Proxy) => string | undefined;
246
+ /** Keep only nodes whose GeoIP country is in this ISO code list. */
247
+ includeCountries: string[];
248
+ /** Drop nodes whose GeoIP country is in this ISO code list. */
249
+ excludeCountries: string[];
250
+ /** Keep only nodes matching one of these remark rules (empty keeps all). */
251
+ includeRemarks: string[];
252
+ /** Drop nodes matching one of these remark rules. */
253
+ excludeRemarks: string[];
254
+ /** `false` keeps remote rulesets as `RULE-SET` references (Surge-family). */
255
+ expandRulesets: boolean;
240
256
  appendProxyType: boolean;
241
257
  nodeList: boolean;
242
258
  sortFlag: boolean;
@@ -244,6 +260,10 @@ interface ExtraSettings {
244
260
  clashNewFieldName: boolean;
245
261
  clashScript: boolean;
246
262
  clashClassicalRuleset: boolean;
263
+ /** Target Clash kernel: dropped protocols/fields follow its capabilities. */
264
+ clashFlavor: ClashFlavor;
265
+ /** Template variables applied to `{{ var }}` placeholders in base configs. */
266
+ templateVars: Record<string, string>;
247
267
  dedupe: boolean;
248
268
  surgeSsrPath: string;
249
269
  managedConfigPrefix: string;
@@ -273,6 +293,10 @@ interface RequestSettings {
273
293
  nameRemove: string[];
274
294
  includeRemarks: string[];
275
295
  excludeRemarks: string[];
296
+ /** Keep only nodes whose GeoIP country is in this ISO code list. */
297
+ includeCountries: string[];
298
+ /** Drop nodes whose GeoIP country is in this ISO code list. */
299
+ excludeCountries: string[];
276
300
  addEmoji: boolean;
277
301
  removeEmoji: boolean;
278
302
  autoCountry: boolean;
@@ -288,6 +312,16 @@ interface RequestSettings {
288
312
  tls13: TriBool;
289
313
  newFieldName: boolean;
290
314
  classicalRuleset: boolean;
315
+ /** Target Clash kernel (`flavor=`): mihomo (default), premium, or stash. */
316
+ clashFlavor: ClashFlavor;
317
+ /** `false` keeps remote rulesets as `RULE-SET` references (Surge-family). */
318
+ expand: boolean;
319
+ /** Managed-config `strict=` flag for Surge-family `#!MANAGED-CONFIG`. */
320
+ strict: boolean;
321
+ /** Download filename override (`filename=`). */
322
+ filename: string;
323
+ /** Quantumult X device ID for remote-script signatures (`dev_id=`). */
324
+ devId: string;
291
325
  insert: boolean;
292
326
  mixin: string;
293
327
  interval: number;
@@ -365,7 +399,7 @@ declare function trim(input: string): string;
365
399
  declare function trimLowerCase(input: string): string;
366
400
  /** Parse the leading integer of a string; `0` when none is present. */
367
401
  declare function toInt(value: string | number | undefined | null): number;
368
- /** Parse a boolean-ish value ("true"/"false"/"1"/"0"). */
402
+ /** Parse a boolean-ish value ("true"/"yes"/"1"/"on" and the matching negatives). */
369
403
  declare function toBool(value: string | undefined | null): boolean;
370
404
  /** `true` when `needle` occurs in `haystack`. */
371
405
  declare function strFind(haystack: string, needle: string): boolean;
@@ -449,6 +483,13 @@ declare function hasTemplatePlaceholders(content: string): boolean;
449
483
  /** Collect the variable names referenced by a template body. */
450
484
  declare function templateVariableNames(content: string): string[];
451
485
 
486
+ /** `ruleset=` dialect prefixes (`surge:`, `quanx:`, `clash-domain:`, …). */
487
+ declare const RULESET_TYPE_PREFIXES: ReadonlyArray<readonly [string, RulesetType]>;
488
+ /** Split a ruleset source into its dialect prefix plus the bare URL/content. */
489
+ declare function parseRulesetSource(source: string): {
490
+ url: string;
491
+ type?: RulesetType;
492
+ };
452
493
  /** A parsed subconverter external configuration file. */
453
494
  interface ExternalConfig {
454
495
  groups: ProxyGroupConfig[];
@@ -459,6 +500,8 @@ interface ExternalConfig {
459
500
  nameRemove: string[];
460
501
  includeRemarks: string[];
461
502
  excludeRemarks: string[];
503
+ includeCountries: string[];
504
+ excludeCountries: string[];
462
505
  addEmoji: boolean;
463
506
  removeEmoji: boolean;
464
507
  autoCountry: boolean;
@@ -879,6 +922,12 @@ declare function explodeTrojan(trojan: string, node: Proxy): void;
879
922
  declare function explodeHysteria2(link: string, node: Proxy): void;
880
923
  /** Parse an `anytls://` link. */
881
924
  declare function explodeAnyTls(link: string, node: Proxy): void;
925
+ /** Parse a `snell://psk@host:port?...` link. */
926
+ declare function explodeSnell(link: string, node: Proxy): void;
927
+ /** Parse a `hysteria://host:port?...` (v1) link. */
928
+ declare function explodeHysteria(link: string, node: Proxy): void;
929
+ /** Parse a `wg://` / `wireguard://host:port?...` link. */
930
+ declare function explodeWireguard(link: string, node: Proxy): void;
882
931
  /** Parse a `vless://` link. */
883
932
  declare function explodeVless(link: string, node: Proxy): void;
884
933
  /** Parse a `tuic://` link. */
@@ -967,13 +1016,13 @@ declare function convertRuleset(content: string, type: RulesetType): string;
967
1016
  /** Rewrite `TYPE,VALUE[,flag]` into `TYPE,VALUE,GROUP[,flag]`. */
968
1017
  declare function transformRuleToCommon(input: string, group: string, noResolveOnly?: boolean): string;
969
1018
  /** Convert rulesets into an ordered list of Clash rule strings. */
970
- declare function rulesetToClashRules(rulesets: RulesetContent[]): string[];
1019
+ declare function rulesetToClashRules(rulesets: RulesetContent[], classical?: boolean): string[];
971
1020
  interface SurgeRulesetResult {
972
1021
  section: string;
973
1022
  lines: string[];
974
1023
  }
975
1024
  /** Convert rulesets into Surge/QuanX/Quan/Loon rule lines. */
976
- declare function rulesetToSurgeRules(rulesets: RulesetContent[], surgeVersion: number): SurgeRulesetResult;
1025
+ declare function rulesetToSurgeRules(rulesets: RulesetContent[], surgeVersion: number, expand?: boolean): SurgeRulesetResult;
977
1026
  declare const SING_BOX_RULE_TYPES: string[];
978
1027
  /** A sing-box `route` fragment produced from rulesets. */
979
1028
  interface SingBoxRoute {
@@ -1093,6 +1142,13 @@ declare function proxyToSsSub(nodes: Proxy[], baseConf: string): string;
1093
1142
  /** Export Shadowsocks nodes as an `ssd://` document. */
1094
1143
  declare function proxyToSsd(nodes: Proxy[], group: string, userinfo: string): string;
1095
1144
 
1145
+ /**
1146
+ * Patterns known to blow up the regex engine (mirrors subconverter-rs
1147
+ * `REGEX_BLACK_LIST`); requests carrying them are rejected outright.
1148
+ */
1149
+ declare const REGEX_BLACKLIST: readonly string[];
1150
+ /** `true` when `pattern` exactly matches a blacklisted catastrophic pattern. */
1151
+ declare function isBlacklistedPattern(pattern: string): boolean;
1096
1152
  /** Does `target` fall within a subconverter range expression like `1-5,8,!3`? */
1097
1153
  declare function matchRange(range: string, target: number): boolean;
1098
1154
  /**
@@ -1128,13 +1184,19 @@ declare function nodeNameRemove(node: Proxy, removeList: string[]): void;
1128
1184
  /** Apply rename rules to a node's remark (script rules are ignored). */
1129
1185
  declare function nodeRename(node: Proxy, renameArray: RegexMatchConfig[]): void;
1130
1186
  /**
1131
- * Prefix a node's remark with its server country/region when the remark does
1132
- * not already mention one (e.g. `server1` -> `美国-server1`).
1187
+ * Prefix a node's remark with its ISO server country when the remark does
1188
+ * not already mention one (e.g. `server1` -> `US-server1`).
1133
1189
  *
1134
1190
  * `resolve` returns an ISO 3166-1 alpha-2 code; a missing/unknown code leaves
1135
1191
  * the remark untouched. Mirrors the request `auto_country` switch.
1136
1192
  */
1137
- declare function addCountryPrefix(node: Proxy, resolve: (node: Proxy) => string | undefined, locale?: string): string;
1193
+ declare function addCountryPrefix(node: Proxy, resolve: (node: Proxy) => string | undefined): string;
1194
+ /**
1195
+ * Drop nodes by GeoIP country: keep only `include` codes (unknown countries
1196
+ * never match, so they are dropped), then drop `exclude` codes (unknown
1197
+ * countries are kept). Invalid codes are ignored.
1198
+ */
1199
+ declare function filterNodesByCountry(nodes: Proxy[], resolve: ((node: Proxy) => string | undefined) | undefined, include: string[], exclude: string[]): void;
1138
1200
  interface PreprocessOptions {
1139
1201
  removeEmoji: boolean;
1140
1202
  addEmoji: boolean;
@@ -1146,8 +1208,15 @@ interface PreprocessOptions {
1146
1208
  /** Literal fragments stripped from names before every other naming rule. */
1147
1209
  nameRemove?: string[];
1148
1210
  autoCountry?: boolean;
1149
- countryLocale?: string;
1150
1211
  countryResolver?: (node: Proxy) => string | undefined;
1212
+ /** Keep only nodes whose GeoIP country is in this ISO code list. */
1213
+ includeCountries?: string[];
1214
+ /** Drop nodes whose GeoIP country is in this ISO code list. */
1215
+ excludeCountries?: string[];
1216
+ /** Keep only nodes matching one of these remark rules (empty keeps all). */
1217
+ includeRemarks?: string[];
1218
+ /** Drop nodes matching one of these remark rules. */
1219
+ excludeRemarks?: string[];
1151
1220
  }
1152
1221
  /** Apply name cleanup, emoji removal, renaming, emoji insertion, and optional sorting. */
1153
1222
  declare function preprocessNodes(nodes: Proxy[], options: PreprocessOptions): void;
@@ -1155,16 +1224,18 @@ declare function preprocessNodes(nodes: Proxy[], options: PreprocessOptions): vo
1155
1224
  declare function dedupeNodes(nodes: Proxy[]): number;
1156
1225
 
1157
1226
  /**
1158
- * ISO 3166-1 alpha-2 region helpers used when a proxy name has no country.
1227
+ * ISO 3166-1 alpha-2 region helpers.
1159
1228
  *
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.
1229
+ * Emitted prefixes are always the uppercase ISO code (`US-server1`) so node
1230
+ * names stay stable across locales. Multilingual names (Chinese/English
1231
+ * spellings, flag emoji) are only recognized by `hasRegionName` so existing
1232
+ * names are never double-prefixed.
1233
+ */
1234
+ /**
1235
+ * Normalize user input to an ISO 3166-1 alpha-2 code (`"us"` -> `"US"`),
1236
+ * or `undefined` when it is not a known region. Used for country filters.
1163
1237
  */
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;
1238
+ declare function normalizeCountryCode(code: string): string | undefined;
1168
1239
  /** `true` when the code is a known ISO 3166-1 alpha-2 region. */
1169
1240
  declare function isRegionCode(code: string): boolean;
1170
1241
  /**
@@ -1174,9 +1245,10 @@ declare function isRegionCode(code: string): boolean;
1174
1245
  */
1175
1246
  declare function hasRegionName(remark: string): boolean;
1176
1247
  /**
1177
- * Prepend `name-` to a node remark (e.g. `server1` -> `美国-server1`).
1178
- * An empty remark becomes just the country name.
1248
+ * Prefix a remark with the ISO country code (e.g. `server1` -> `US-server1`).
1249
+ * An empty remark becomes just the code. Invalid codes leave the remark
1250
+ * unchanged.
1179
1251
  */
1180
- declare function formatCountryRemark(remark: string, code: string, locale?: string): string;
1252
+ declare function formatCountryRemark(remark: string, code: string): string;
1181
1253
 
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 };
1254
+ export { BalanceStrategy, CLASH_RULE_TYPES, type ClashFlavor, 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, REGEX_BLACKLIST, RULESET_TYPE_PREFIXES, 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, explodeHysteria, explodeHysteria2, explodeKitsunebi, explodeNetch, explodeNetchConf, explodeQuan, explodeShadowrocket, explodeSnell, explodeSocks, explodeSs, explodeSsAndroid, explodeSsConf, explodeSsd, explodeSsr, explodeSsrConf, explodeSstap, explodeStdVmess, explodeSub, explodeSurge, explodeTrojan, explodeTuic, explodeVless, explodeVmess, explodeVmessConf, explodeWireguard, filterNodes, filterNodesByCountry, findSection, fnv1a64, fnv1a64Hex, formatCountryRemark, formatSingBoxInterval, formatSubscriptionUserinfo, generate, generatePeer, getAllUrlArgs, getDefaultProxyGroups, getDefaultRulesetConfigs, getDefaultRulesets, getSectionItems, getUrlArg, groupGenerate, hasRegionName, hasTemplatePlaceholders, httpConstruct, hysteria2Construct, hysteriaConstruct, inferUserinfoProviderFromUrl, isBlacklistedPattern, isBlank, isFlattenableSsr, isIp, isIpv4, isIpv6, isLink, isRegionCode, isSsCipher, matchRange, nextMonthlyResetTimestamp, nodeNameRegex, nodeNameRemove, nodeRename, normalizeCountryCode, normalizeQueryKey, normalizeUserinfoProvider, pad2, parseClashFlavor, parseClashText, parseConfContent, parseCustomProxyGroup, parseExternalConfig, parseGroupTimes, parseIni, parseJmsUserinfo, parseLink, parsePeers, parseProxyGroupType, parseRawIni, parseRegexMatch, parseRequestSettings, parseRulesetConfig, parseRulesetSource, parseSubscription, parseSubscriptionUserinfo, parseTriBool, preprocessNodes, processRemark, proxyToSingle, proxyToSsSub, proxyToSsd, proxyTypeName, queryBoolFlag, regMatch, regReplace, 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 };