transform.d.cts 1007 B

123456789101112131415161718192021222324252627282930313233343536
  1. import MagicString from 'magic-string';
  2. interface TransformerOptions {
  3. /**
  4. * The function names to be transformed.
  5. *
  6. * @default ['withAsyncContext']
  7. */
  8. asyncFunctions?: string[];
  9. /**
  10. * @default 'unctx'
  11. */
  12. helperModule?: string;
  13. /**
  14. * @default 'executeAsync'
  15. */
  16. helperName?: string;
  17. /**
  18. * Whether to transform properties of an object defined with a helper function. For example,
  19. * to transform key `middleware` within the object defined with function `defineMeta`, you would pass:
  20. * `{ defineMeta: ['middleware'] }`.
  21. * @default {}
  22. */
  23. objectDefinitions?: Record<string, string[]>;
  24. }
  25. declare function createTransformer(options?: TransformerOptions): {
  26. transform: (code: string, options_?: {
  27. force?: false;
  28. }) => {
  29. code: string;
  30. magicString: MagicString;
  31. } | undefined;
  32. shouldTransform: (code: string) => boolean;
  33. };
  34. export { type TransformerOptions, createTransformer };