global.d.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. declare type Docs = {
  2. [key: string]: unknown;
  3. };
  4. type Megabit = number;
  5. type Millisecond = number;
  6. type EffectiveConnectionType = "2g" | "3g" | "4g" | "5g" | "slow-2g";
  7. type ConnectionType =
  8. | "bluetooth"
  9. | "cellular"
  10. | "ethernet"
  11. | "mixed"
  12. | "none"
  13. | "other"
  14. | "unknown"
  15. | "wifi"
  16. | "wimax";
  17. interface NetworkInformation extends EventTarget {
  18. readonly type?: ConnectionType;
  19. readonly effectiveType?: EffectiveConnectionType;
  20. readonly downlinkMax?: Megabit;
  21. readonly downlink?: Megabit;
  22. readonly rtt?: Millisecond;
  23. readonly saveData?: boolean;
  24. onchange?: EventListener;
  25. }
  26. declare interface Window {
  27. readonly PalfishBridgeAndroid?: Docs;
  28. readonly webkit?: {
  29. readonly messageHandlers?: {
  30. readonly PalfishBridgeIOS: Docs;
  31. };
  32. };
  33. readonly mozRequestAnimationFrame: typeof requestAnimationFrame;
  34. readonly webkitRequestAnimationFrame: typeof requestAnimationFrame;
  35. readonly msRequestAnimationFrame: typeof requestAnimationFrame;
  36. readonly SENTRY_RELEASE?: { id: string };
  37. /**
  38. * iOS微信6.5.3及其之后的版本 window.__wxjs_is_wkwebview 为true时是使用WKWebview,为 false或者 “undefine”时是 UIWebview
  39. */
  40. readonly __wxjs_is_wkwebview?: boolean | undefined;
  41. wx: WX;
  42. WeixinJSBridge: {
  43. invoke: (name: string, config: Docs, callback?: AnyNoop) => void;
  44. on: (eventName: string, callback: AnyNoop) => void;
  45. call: (name: string) => void;
  46. };
  47. }
  48. declare interface Navigator {
  49. readonly connection?: NetworkInformation;
  50. }
  51. declare type Noop = () => void;
  52. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  53. declare type AnyNoop = (...args: any[]) => any;
  54. declare interface Document {
  55. attachEvent: (eventName: string, callback: AnyNoop) => void;
  56. }
  57. declare const ROUTES = [];