ruleset.ts 1.1 KB

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