ruleset.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import type { Span } from '../../trace';
  2. import { ClashClassicRuleSet } from '../writing-strategy/clash';
  3. import { LegacyClashPremiumClassicRuleSet } from '../writing-strategy/legacy-clash-premium';
  4. import { SingboxSource } from '../writing-strategy/singbox';
  5. import { SurgeRuleSet } from '../writing-strategy/surge';
  6. import { FileOutput } from './base';
  7. export class RulesetOutput extends FileOutput {
  8. constructor(span: Span, id: string, type: 'non_ip' | 'ip') {
  9. super(span, id);
  10. this.strategies = [
  11. new SurgeRuleSet(type),
  12. new ClashClassicRuleSet(type),
  13. new LegacyClashPremiumClassicRuleSet(type),
  14. new SingboxSource(type)
  15. ];
  16. }
  17. }
  18. export class SurgeOnlyRulesetOutput extends FileOutput {
  19. constructor(
  20. span: Span,
  21. id: string,
  22. type: 'non_ip' | 'ip' | (string & {}),
  23. overrideOutputDir?: string
  24. ) {
  25. super(span, id);
  26. this.strategies = [
  27. new SurgeRuleSet(type, overrideOutputDir)
  28. ];
  29. }
  30. }
  31. export class ClashOnlyRulesetOutput extends FileOutput {
  32. constructor(
  33. span: Span,
  34. id: string,
  35. type: 'non_ip' | 'ip'
  36. ) {
  37. super(span, id);
  38. this.strategies = [
  39. new ClashClassicRuleSet(type),
  40. new LegacyClashPremiumClassicRuleSet(type)
  41. ];
  42. }
  43. }