1
0

index.d.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import { metas as fMetas } from "./shape";
  2. import type { BoardData, BoardShapeData, TableShapeData } from "@/store/case";
  3. import type { Emitter } from "mitt";
  4. import type { shapes } from "./shapes";
  5. import {
  6. brokenLine,
  7. text,
  8. table,
  9. rect,
  10. circular,
  11. arrow,
  12. icon,
  13. cigarette,
  14. fireoint,
  15. footPrint,
  16. shoePrint,
  17. fingerPrint,
  18. corpse,
  19. theBlood,
  20. compass,
  21. title,
  22. bgImage,
  23. customImage,
  24. } from "./shape";
  25. type Metas = typeof fMetas;
  26. export type ShapeType =
  27. | typeof brokenLine
  28. | typeof customImage
  29. | typeof text
  30. | typeof table
  31. | typeof rect
  32. | typeof circular
  33. | typeof arrow
  34. | typeof icon
  35. | typeof cigarette
  36. | typeof fireoint
  37. | typeof footPrint
  38. | typeof shoePrint
  39. | typeof fingerPrint
  40. | typeof corpse
  41. | typeof theBlood
  42. | typeof compass
  43. | typeof title
  44. | typeof bgImage;
  45. export type MetaShapeType = keyof Metas;
  46. export interface Pos {
  47. x: number;
  48. y: number;
  49. }
  50. // 形状通用对象
  51. export type BoardShape<T = BoardShapeData, K = keyof T> = IntersectionFromUnion<
  52. K extends "type"
  53. ? { data: { [key in K]: T[K] } }
  54. : { data: { [key in K]: T[K] } } & {
  55. [key in `set${Capitalize<K>}`]: (val: T[K]) => void;
  56. }
  57. > & { delete: () => void; autoSet?: boolean };
  58. export type ExtractShape<T extends string, D = BoardShapeData> = BoardShape<
  59. D extends object ? (T extends keyof D ? D : never) : never
  60. >;
  61. export type Board = {
  62. el: HTMLCanvasElement;
  63. bus: Emitter<{
  64. storeChange: undefined;
  65. selectShape: BoardShape | null;
  66. backDisabled: boolean;
  67. exixtsBgImage: boolean
  68. forwardDisabled: boolean;
  69. }>;
  70. clear(): void;
  71. unSelectShape(): void;
  72. readyAddShape(type: MetaShapeType, data: any, onFinish?: () => void): () => void;
  73. back(): void;
  74. forward(): void;
  75. viewInit(): void;
  76. setImage(url: string): void;
  77. getStore(): Promise<BoardData>;
  78. calcTableShape(data: string[][]): Promise<TableShapeData>;
  79. initHistory(): void;
  80. setDefaultTable(
  81. bottomData: TableShapeData["content"] | null,
  82. topData: setDefaultTable["content"] | null
  83. );
  84. export(): Promise<Blob>;
  85. destroy(): void;
  86. };
  87. function create(store: BoardData, canvas: HTMLCanvasElement): Board;
  88. export { BoardShapeData };
  89. export const metas: Metas;
  90. export const images: MetaShapeType[];
  91. export const labels: MetaShapeType[];
  92. export {
  93. brokenLine,
  94. text,
  95. table,
  96. shapes,
  97. rect,
  98. circular,
  99. arrow,
  100. icon,
  101. cigarette,
  102. fireoint,
  103. footPrint,
  104. customImage,
  105. shoePrint,
  106. fingerPrint,
  107. corpse,
  108. theBlood,
  109. compass,
  110. title,
  111. bgImage,
  112. } from "./shape";
  113. export default create;