global.d.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. export {};
  2. declare global {
  3. declare const Bridge: typeof import('./bridge').Bridge;
  4. export interface Platform extends EventTarget {
  5. pulse(userId?: string): Promise<{
  6. id: string;
  7. url: string;
  8. date?: string;
  9. result?: string;
  10. }>;
  11. injection(config?: { callbackFn?: (key: string) => string }): void;
  12. __execution__map__: Map<string, any>;
  13. __execution__<M>(key: keyof PlatformAIO, ...args: any[]): Promise<M>;
  14. }
  15. /**
  16. * webview 设备注入的 全局对象
  17. */
  18. export interface PlatformAIO {
  19. pulse(callback: string, userId?: string): boolean;
  20. }
  21. interface Window {
  22. /* six-aio 设备注入 */
  23. bridge: InstanceType<typeof import('./bridge').Bridge>;
  24. platform: Platform;
  25. /**
  26. * webview 设备注入的 全局对象
  27. */
  28. platformAIO: PlatformAIO;
  29. }
  30. declare var platform: Platform;
  31. /**
  32. * Promise 扩展
  33. */
  34. interface PromiseConstructor {
  35. withResolvers<T>(): {
  36. promise: Promise<T>;
  37. resolve: (value: T | PromiseLike<T>) => void;
  38. reject: (reason?: any) => void;
  39. };
  40. }
  41. }