bridge.d.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. interface HandSummary {
  2. chi: string;
  3. cun: string;
  4. guan: string;
  5. summary: string[];
  6. }
  7. type HandKeys = 'chen' | 'chi' | 'fu' | 'hua' | 'kong' | 'ruan' | 'shi' | 'shu' | 'xi' | 'xian';
  8. interface ScanData {
  9. code: string;
  10. state: number;
  11. type: number;
  12. }
  13. export interface BridgeEventMap {
  14. scan: CustomEvent<{code: number, data?: ScanData, message?: string}>;
  15. }
  16. export class Bridge extends EventTarget {
  17. public static getInstance(): Bridge;
  18. public static pulse(userId: string): Promise<{
  19. measureId: string;
  20. summaryLabel: {
  21. summary?: HandSummary['summary'];
  22. left?: HandSummary;
  23. right?: HandSummary;
  24. };
  25. summaryValue: Record<HandKeys, number[]>;
  26. time: string;
  27. appId?: string;
  28. userId?: string;
  29. url: string;
  30. report: string;
  31. }>;
  32. public static print(): Promise<void>;
  33. public static print(params: { url?: string }): Promise<void>;
  34. /**
  35. * 监听扫码事件
  36. * @param type 事件类型 'scan'
  37. * @param listener 事件回调,参数为 ScanEvent
  38. * @param options
  39. */
  40. addEventListener<T extends keyof BridgeEventMap>(type: T, listener: (event: BridgeEventMap[T]) => void, options?: boolean | AddEventListenerOptions): () => void;
  41. removeEventListener<T extends keyof BridgeEventMap>(type: T, listener: (event: BridgeEventMap[T]) => void, options?: boolean | AddEventListenerOptions): () => void;
  42. }
  43. export interface globalAIO {
  44. scan(value: string): number;
  45. print(value: string): void;
  46. }