@docmentis/udoc-viewer 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/dist/wasm/udoc_bg.wasm +0 -0
  2. package/dist/worker/WorkerClient.js +1 -1
  3. package/package.json +11 -3
  4. package/dist/WorkerClient.d.ts +0 -36
  5. package/dist/WorkerClient.d.ts.map +0 -1
  6. package/dist/WorkerClient.js +0 -121
  7. package/dist/WorkerClient.js.map +0 -1
  8. package/dist/annotation/AnnotationLayer.d.ts +0 -166
  9. package/dist/annotation/AnnotationLayer.d.ts.map +0 -1
  10. package/dist/annotation/AnnotationLayer.js +0 -1090
  11. package/dist/annotation/AnnotationLayer.js.map +0 -1
  12. package/dist/annotation/index.d.ts +0 -6
  13. package/dist/annotation/index.d.ts.map +0 -1
  14. package/dist/annotation/index.js +0 -6
  15. package/dist/annotation/index.js.map +0 -1
  16. package/dist/components/FloatingBar.d.ts +0 -102
  17. package/dist/components/FloatingBar.d.ts.map +0 -1
  18. package/dist/components/FloatingBar.js +0 -513
  19. package/dist/components/FloatingBar.js.map +0 -1
  20. package/dist/components/Header.d.ts +0 -46
  21. package/dist/components/Header.d.ts.map +0 -1
  22. package/dist/components/Header.js +0 -93
  23. package/dist/components/Header.js.map +0 -1
  24. package/dist/components/index.d.ts +0 -6
  25. package/dist/components/index.d.ts.map +0 -1
  26. package/dist/components/index.js +0 -4
  27. package/dist/components/index.js.map +0 -1
  28. package/dist/components/panels/CommentsPanel.d.ts +0 -33
  29. package/dist/components/panels/CommentsPanel.d.ts.map +0 -1
  30. package/dist/components/panels/CommentsPanel.js +0 -176
  31. package/dist/components/panels/CommentsPanel.js.map +0 -1
  32. package/dist/components/panels/OutlinePanel.d.ts +0 -30
  33. package/dist/components/panels/OutlinePanel.d.ts.map +0 -1
  34. package/dist/components/panels/OutlinePanel.js +0 -144
  35. package/dist/components/panels/OutlinePanel.js.map +0 -1
  36. package/dist/components/panels/ThumbnailsPanel.d.ts +0 -51
  37. package/dist/components/panels/ThumbnailsPanel.d.ts.map +0 -1
  38. package/dist/components/panels/ThumbnailsPanel.js +0 -160
  39. package/dist/components/panels/ThumbnailsPanel.js.map +0 -1
  40. package/dist/components/panels/index.d.ts +0 -7
  41. package/dist/components/panels/index.d.ts.map +0 -1
  42. package/dist/components/panels/index.js +0 -4
  43. package/dist/components/panels/index.js.map +0 -1
  44. package/dist/constants.d.ts +0 -25
  45. package/dist/constants.d.ts.map +0 -1
  46. package/dist/constants.js +0 -46
  47. package/dist/constants.js.map +0 -1
  48. package/dist/core/NavigationController.d.ts +0 -54
  49. package/dist/core/NavigationController.d.ts.map +0 -1
  50. package/dist/core/NavigationController.js +0 -145
  51. package/dist/core/NavigationController.js.map +0 -1
  52. package/dist/core/PerfTimer.d.ts +0 -12
  53. package/dist/core/PerfTimer.d.ts.map +0 -1
  54. package/dist/core/PerfTimer.js +0 -32
  55. package/dist/core/PerfTimer.js.map +0 -1
  56. package/dist/core/ViewerState.d.ts +0 -108
  57. package/dist/core/ViewerState.d.ts.map +0 -1
  58. package/dist/core/ViewerState.js +0 -179
  59. package/dist/core/ViewerState.js.map +0 -1
  60. package/dist/core/constants.d.ts +0 -24
  61. package/dist/core/constants.d.ts.map +0 -1
  62. package/dist/core/constants.js +0 -42
  63. package/dist/core/constants.js.map +0 -1
  64. package/dist/core/index.d.ts +0 -8
  65. package/dist/core/index.d.ts.map +0 -1
  66. package/dist/core/index.js +0 -11
  67. package/dist/core/index.js.map +0 -1
  68. package/dist/core/types.d.ts +0 -573
  69. package/dist/core/types.d.ts.map +0 -1
  70. package/dist/core/types.js +0 -5
  71. package/dist/core/types.js.map +0 -1
  72. package/dist/icons/icons.d.ts +0 -41
  73. package/dist/icons/icons.d.ts.map +0 -1
  74. package/dist/icons/icons.js +0 -51
  75. package/dist/icons/icons.js.map +0 -1
  76. package/dist/icons/index.d.ts +0 -3
  77. package/dist/icons/index.d.ts.map +0 -1
  78. package/dist/icons/index.js +0 -2
  79. package/dist/icons/index.js.map +0 -1
  80. package/dist/layout/BandManager.d.ts +0 -87
  81. package/dist/layout/BandManager.d.ts.map +0 -1
  82. package/dist/layout/BandManager.js +0 -185
  83. package/dist/layout/BandManager.js.map +0 -1
  84. package/dist/layout/LayoutCalculator.d.ts +0 -42
  85. package/dist/layout/LayoutCalculator.d.ts.map +0 -1
  86. package/dist/layout/LayoutCalculator.js +0 -180
  87. package/dist/layout/LayoutCalculator.js.map +0 -1
  88. package/dist/layout/LayoutState.d.ts +0 -46
  89. package/dist/layout/LayoutState.d.ts.map +0 -1
  90. package/dist/layout/LayoutState.js +0 -109
  91. package/dist/layout/LayoutState.js.map +0 -1
  92. package/dist/layout/TransitionCoordinator.d.ts +0 -11
  93. package/dist/layout/TransitionCoordinator.d.ts.map +0 -1
  94. package/dist/layout/TransitionCoordinator.js +0 -22
  95. package/dist/layout/TransitionCoordinator.js.map +0 -1
  96. package/dist/layout/index.d.ts +0 -7
  97. package/dist/layout/index.d.ts.map +0 -1
  98. package/dist/layout/index.js +0 -4
  99. package/dist/layout/index.js.map +0 -1
  100. package/dist/rendering/BandManager.d.ts +0 -87
  101. package/dist/rendering/BandManager.d.ts.map +0 -1
  102. package/dist/rendering/BandManager.js +0 -185
  103. package/dist/rendering/BandManager.js.map +0 -1
  104. package/dist/rendering/PageCache.d.ts +0 -75
  105. package/dist/rendering/PageCache.d.ts.map +0 -1
  106. package/dist/rendering/PageCache.js +0 -122
  107. package/dist/rendering/PageCache.js.map +0 -1
  108. package/dist/rendering/RenderQueue.d.ts +0 -75
  109. package/dist/rendering/RenderQueue.d.ts.map +0 -1
  110. package/dist/rendering/RenderQueue.js +0 -105
  111. package/dist/rendering/RenderQueue.js.map +0 -1
  112. package/dist/rendering/ThumbnailQueue.d.ts +0 -57
  113. package/dist/rendering/ThumbnailQueue.d.ts.map +0 -1
  114. package/dist/rendering/ThumbnailQueue.js +0 -85
  115. package/dist/rendering/ThumbnailQueue.js.map +0 -1
  116. package/dist/rendering/index.d.ts +0 -13
  117. package/dist/rendering/index.d.ts.map +0 -1
  118. package/dist/rendering/index.js +0 -10
  119. package/dist/rendering/index.js.map +0 -1
  120. package/dist/rendering/types.d.ts +0 -72
  121. package/dist/rendering/types.d.ts.map +0 -1
  122. package/dist/rendering/types.js +0 -5
  123. package/dist/rendering/types.js.map +0 -1
  124. package/dist/styles/index.d.ts +0 -6
  125. package/dist/styles/index.d.ts.map +0 -1
  126. package/dist/styles/index.js +0 -1221
  127. package/dist/styles/index.js.map +0 -1
  128. package/dist/types.d.ts +0 -6
  129. package/dist/types.d.ts.map +0 -1
  130. package/dist/types.js +0 -6
  131. package/dist/types.js.map +0 -1
  132. package/dist/ui/Component.d.ts +0 -127
  133. package/dist/ui/Component.d.ts.map +0 -1
  134. package/dist/ui/Component.js +0 -201
  135. package/dist/ui/Component.js.map +0 -1
  136. package/dist/ui/annotation/AnnotationLayer.d.ts +0 -90
  137. package/dist/ui/annotation/AnnotationLayer.d.ts.map +0 -1
  138. package/dist/ui/annotation/AnnotationLayer.js +0 -322
  139. package/dist/ui/annotation/AnnotationLayer.js.map +0 -1
  140. package/dist/ui/annotation/LinkRenderer.d.ts +0 -32
  141. package/dist/ui/annotation/LinkRenderer.d.ts.map +0 -1
  142. package/dist/ui/annotation/LinkRenderer.js +0 -74
  143. package/dist/ui/annotation/LinkRenderer.js.map +0 -1
  144. package/dist/ui/annotation/MarkupRenderer.d.ts +0 -40
  145. package/dist/ui/annotation/MarkupRenderer.d.ts.map +0 -1
  146. package/dist/ui/annotation/MarkupRenderer.js +0 -154
  147. package/dist/ui/annotation/MarkupRenderer.js.map +0 -1
  148. package/dist/ui/annotation/ShapeRenderer.d.ts +0 -46
  149. package/dist/ui/annotation/ShapeRenderer.d.ts.map +0 -1
  150. package/dist/ui/annotation/ShapeRenderer.js +0 -376
  151. package/dist/ui/annotation/ShapeRenderer.js.map +0 -1
  152. package/dist/ui/annotation/TextRenderer.d.ts +0 -36
  153. package/dist/ui/annotation/TextRenderer.d.ts.map +0 -1
  154. package/dist/ui/annotation/TextRenderer.js +0 -199
  155. package/dist/ui/annotation/TextRenderer.js.map +0 -1
  156. package/dist/ui/annotation/index.d.ts +0 -17
  157. package/dist/ui/annotation/index.d.ts.map +0 -1
  158. package/dist/ui/annotation/index.js +0 -13
  159. package/dist/ui/annotation/index.js.map +0 -1
  160. package/dist/ui/annotation/utils.d.ts +0 -40
  161. package/dist/ui/annotation/utils.d.ts.map +0 -1
  162. package/dist/ui/annotation/utils.js +0 -62
  163. package/dist/ui/annotation/utils.js.map +0 -1
  164. package/dist/ui/components/CommentsContent.d.ts +0 -35
  165. package/dist/ui/components/CommentsContent.d.ts.map +0 -1
  166. package/dist/ui/components/CommentsContent.js +0 -203
  167. package/dist/ui/components/CommentsContent.js.map +0 -1
  168. package/dist/ui/components/FloatingBar.d.ts +0 -55
  169. package/dist/ui/components/FloatingBar.d.ts.map +0 -1
  170. package/dist/ui/components/FloatingBar.js +0 -585
  171. package/dist/ui/components/FloatingBar.js.map +0 -1
  172. package/dist/ui/components/Header.d.ts +0 -29
  173. package/dist/ui/components/Header.d.ts.map +0 -1
  174. package/dist/ui/components/Header.js +0 -127
  175. package/dist/ui/components/Header.js.map +0 -1
  176. package/dist/ui/components/LeftPanel.d.ts +0 -54
  177. package/dist/ui/components/LeftPanel.d.ts.map +0 -1
  178. package/dist/ui/components/LeftPanel.js +0 -202
  179. package/dist/ui/components/LeftPanel.js.map +0 -1
  180. package/dist/ui/components/OutlineContent.d.ts +0 -34
  181. package/dist/ui/components/OutlineContent.d.ts.map +0 -1
  182. package/dist/ui/components/OutlineContent.js +0 -147
  183. package/dist/ui/components/OutlineContent.js.map +0 -1
  184. package/dist/ui/components/RightPanel.d.ts +0 -52
  185. package/dist/ui/components/RightPanel.d.ts.map +0 -1
  186. package/dist/ui/components/RightPanel.js +0 -142
  187. package/dist/ui/components/RightPanel.js.map +0 -1
  188. package/dist/ui/components/Viewport.d.ts +0 -70
  189. package/dist/ui/components/Viewport.d.ts.map +0 -1
  190. package/dist/ui/components/Viewport.js +0 -173
  191. package/dist/ui/components/Viewport.js.map +0 -1
  192. package/dist/ui/components/index.d.ts +0 -11
  193. package/dist/ui/components/index.d.ts.map +0 -1
  194. package/dist/ui/components/index.js +0 -10
  195. package/dist/ui/components/index.js.map +0 -1
  196. package/dist/ui/icons/icons.d.ts +0 -43
  197. package/dist/ui/icons/icons.d.ts.map +0 -1
  198. package/dist/ui/icons/icons.js +0 -46
  199. package/dist/ui/icons/icons.js.map +0 -1
  200. package/dist/ui/icons/index.d.ts +0 -11
  201. package/dist/ui/icons/index.d.ts.map +0 -1
  202. package/dist/ui/icons/index.js +0 -18
  203. package/dist/ui/icons/index.js.map +0 -1
  204. package/dist/ui/index.d.ts +0 -7
  205. package/dist/ui/index.d.ts.map +0 -1
  206. package/dist/ui/index.js +0 -9
  207. package/dist/ui/index.js.map +0 -1
  208. package/dist/ui/styles/base.css.d.ts +0 -5
  209. package/dist/ui/styles/base.css.d.ts.map +0 -1
  210. package/dist/ui/styles/base.css.js +0 -49
  211. package/dist/ui/styles/base.css.js.map +0 -1
  212. package/dist/ui/styles/floating-bar.css.d.ts +0 -5
  213. package/dist/ui/styles/floating-bar.css.d.ts.map +0 -1
  214. package/dist/ui/styles/floating-bar.css.js +0 -417
  215. package/dist/ui/styles/floating-bar.css.js.map +0 -1
  216. package/dist/ui/styles/header.css.d.ts +0 -5
  217. package/dist/ui/styles/header.css.d.ts.map +0 -1
  218. package/dist/ui/styles/header.css.js +0 -49
  219. package/dist/ui/styles/header.css.js.map +0 -1
  220. package/dist/ui/styles/index.d.ts +0 -21
  221. package/dist/ui/styles/index.d.ts.map +0 -1
  222. package/dist/ui/styles/index.js +0 -48
  223. package/dist/ui/styles/index.js.map +0 -1
  224. package/dist/ui/styles/panels.css.d.ts +0 -5
  225. package/dist/ui/styles/panels.css.d.ts.map +0 -1
  226. package/dist/ui/styles/panels.css.js +0 -446
  227. package/dist/ui/styles/panels.css.js.map +0 -1
  228. package/dist/ui/styles/responsive.css.d.ts +0 -5
  229. package/dist/ui/styles/responsive.css.d.ts.map +0 -1
  230. package/dist/ui/styles/responsive.css.js +0 -201
  231. package/dist/ui/styles/responsive.css.js.map +0 -1
  232. package/dist/ui/styles/variables.css.d.ts +0 -6
  233. package/dist/ui/styles/variables.css.d.ts.map +0 -1
  234. package/dist/ui/styles/variables.css.js +0 -75
  235. package/dist/ui/styles/variables.css.js.map +0 -1
  236. package/dist/ui/styles/viewport.css.d.ts +0 -5
  237. package/dist/ui/styles/viewport.css.d.ts.map +0 -1
  238. package/dist/ui/styles/viewport.css.js +0 -87
  239. package/dist/ui/styles/viewport.css.js.map +0 -1
  240. package/dist/view/LayoutCalculator.d.ts +0 -42
  241. package/dist/view/LayoutCalculator.d.ts.map +0 -1
  242. package/dist/view/LayoutCalculator.js +0 -180
  243. package/dist/view/LayoutCalculator.js.map +0 -1
  244. package/dist/view/TransitionCoordinator.d.ts +0 -11
  245. package/dist/view/TransitionCoordinator.d.ts.map +0 -1
  246. package/dist/view/TransitionCoordinator.js +0 -22
  247. package/dist/view/TransitionCoordinator.js.map +0 -1
  248. package/dist/view/ViewState.d.ts +0 -46
  249. package/dist/view/ViewState.d.ts.map +0 -1
  250. package/dist/view/ViewState.js +0 -109
  251. package/dist/view/ViewState.js.map +0 -1
  252. package/dist/view/index.d.ts +0 -7
  253. package/dist/view/index.d.ts.map +0 -1
  254. package/dist/view/index.js +0 -4
  255. package/dist/view/index.js.map +0 -1
  256. package/dist/worker/types.d.ts +0 -81
  257. package/dist/worker/types.d.ts.map +0 -1
  258. package/dist/worker/types.js +0 -6
  259. package/dist/worker/types.js.map +0 -1
  260. package/dist/worker.d.ts +0 -2
  261. package/dist/worker.d.ts.map +0 -1
  262. package/dist/worker.js +0 -205
  263. package/dist/worker.js.map +0 -1
Binary file
@@ -19,7 +19,7 @@ export class WorkerClient {
19
19
  */
20
20
  static create() {
21
21
  // This pattern allows vite to statically analyze and bundle the worker
22
- const worker = new Worker(new URL("./worker.ts", import.meta.url), { type: "module" });
22
+ const worker = new Worker(new URL("./worker.js", import.meta.url), { type: "module" });
23
23
  return new WorkerClient(worker);
24
24
  }
25
25
  /**
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@docmentis/udoc-viewer",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Universal document viewer for PDF and PPTX files",
7
- "keywords": ["pdf", "viewer", "document", "wasm"],
7
+ "keywords": [
8
+ "pdf",
9
+ "viewer",
10
+ "document",
11
+ "wasm"
12
+ ],
8
13
  "main": "dist/index.js",
9
14
  "types": "dist/index.d.ts",
10
15
  "exports": {
@@ -17,13 +22,16 @@
17
22
  "import": "./dist/worker.js"
18
23
  }
19
24
  },
20
- "files": ["dist"],
25
+ "files": [
26
+ "dist"
27
+ ],
21
28
  "sideEffects": false,
22
29
  "engines": {
23
30
  "node": ">=18"
24
31
  },
25
32
  "scripts": {
26
33
  "build": "tsc && cp -r src/wasm dist/wasm",
34
+ "clean": "rm -rf dist",
27
35
  "dev": "tsc --watch"
28
36
  },
29
37
  "devDependencies": {
@@ -1,36 +0,0 @@
1
- import type { Annotation, OutlineItem } from './types';
2
- export interface PageInfo {
3
- width: number;
4
- height: number;
5
- }
6
- export type PageLayout = 'default' | 'odd-pages-right' | 'odd-pages-left';
7
- export interface LoadResult {
8
- pageCount: number;
9
- pageWidths: number[];
10
- pageHeights: number[];
11
- pageLayout: PageLayout;
12
- }
13
- export declare class WorkerClient {
14
- private worker;
15
- private nextId;
16
- private pending;
17
- private _pageCount;
18
- private _pageWidths;
19
- private _pageHeights;
20
- constructor();
21
- private handleMessage;
22
- private handleError;
23
- private send;
24
- load(data: Uint8Array): Promise<LoadResult>;
25
- renderPage(pageIndex: number, width: number, height: number, format?: 'png' | 'rgba'): Promise<Uint8Array>;
26
- close(): Promise<void>;
27
- getOutline(): Promise<OutlineItem[]>;
28
- getPageAnnotations(pageIndex: number): Promise<Annotation[]>;
29
- getAllAnnotations(): Promise<Map<number, Annotation[]>>;
30
- terminate(): void;
31
- hasPending(): boolean;
32
- get pageCount(): number;
33
- pageWidth(pageIndex: number): number;
34
- pageHeight(pageIndex: number): number;
35
- }
36
- //# sourceMappingURL=WorkerClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WorkerClient.d.ts","sourceRoot":"","sources":["../src/WorkerClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEvD,MAAM,WAAW,QAAQ;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AAE1E,MAAM,WAAW,UAAU;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;CAC1B;AAOD,qBAAa,YAAY;IACrB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,OAAO,CAAqC;IACpD,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,YAAY,CAAgB;;IAQpC,OAAO,CAAC,aAAa;IAkBrB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,IAAI;IAYN,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAwB3C,UAAU,CACZ,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,KAAK,GAAG,MAAc,GAC/B,OAAO,CAAC,UAAU,CAAC;IAWhB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,UAAU,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAOpC,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAQ5D,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IAY7D,SAAS,IAAI,IAAI;IASjB,UAAU,IAAI,OAAO;IAIrB,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAIpC,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;CAGxC"}
@@ -1,121 +0,0 @@
1
- export class WorkerClient {
2
- worker;
3
- nextId = 0;
4
- pending = new Map();
5
- _pageCount = 0;
6
- _pageWidths = [];
7
- _pageHeights = [];
8
- constructor() {
9
- this.worker = new Worker(new URL('./worker.js', import.meta.url), { type: 'module' });
10
- this.worker.onmessage = this.handleMessage.bind(this);
11
- this.worker.onerror = this.handleError.bind(this);
12
- }
13
- handleMessage(event) {
14
- const response = event.data;
15
- const pending = this.pending.get(response.id);
16
- if (!pending) {
17
- console.warn('Received response for unknown request:', response.id);
18
- return;
19
- }
20
- this.pending.delete(response.id);
21
- if (response.type === 'error') {
22
- pending.reject(new Error(response.message));
23
- }
24
- else {
25
- pending.resolve(response);
26
- }
27
- }
28
- handleError(error) {
29
- console.error('Worker error:', error);
30
- // Reject all pending requests
31
- for (const [id, pending] of this.pending) {
32
- pending.reject(new Error('Worker error: ' + error.message));
33
- this.pending.delete(id);
34
- }
35
- }
36
- send(message, transfer) {
37
- return new Promise((resolve, reject) => {
38
- const id = this.nextId++;
39
- this.pending.set(id, { resolve: resolve, reject });
40
- if (transfer) {
41
- this.worker.postMessage({ ...message, id }, transfer);
42
- }
43
- else {
44
- this.worker.postMessage({ ...message, id });
45
- }
46
- });
47
- }
48
- async load(data) {
49
- const response = await this.send({
50
- type: 'load',
51
- data,
52
- }, [data.buffer]);
53
- this._pageCount = response.pageCount;
54
- this._pageWidths = response.pageWidths;
55
- this._pageHeights = response.pageHeights;
56
- return {
57
- pageCount: response.pageCount,
58
- pageWidths: response.pageWidths,
59
- pageHeights: response.pageHeights,
60
- pageLayout: response.pageLayout,
61
- };
62
- }
63
- async renderPage(pageIndex, width, height, format = 'png') {
64
- const response = await this.send({
65
- type: 'render',
66
- pageIndex,
67
- width,
68
- height,
69
- format,
70
- });
71
- return response.data;
72
- }
73
- async close() {
74
- await this.send({ type: 'close' });
75
- }
76
- async getOutline() {
77
- const response = await this.send({
78
- type: 'getOutline',
79
- });
80
- return response.items;
81
- }
82
- async getPageAnnotations(pageIndex) {
83
- const response = await this.send({
84
- type: 'getPageAnnotations',
85
- pageIndex,
86
- });
87
- return response.annotations;
88
- }
89
- async getAllAnnotations() {
90
- const response = await this.send({
91
- type: 'getAllAnnotations',
92
- });
93
- // Convert from Record<string, Annotation[]> to Map<number, Annotation[]>
94
- const result = new Map();
95
- for (const [pageIndex, annotations] of Object.entries(response.annotationsByPage)) {
96
- result.set(parseInt(pageIndex, 10), annotations);
97
- }
98
- return result;
99
- }
100
- terminate() {
101
- this.worker.terminate();
102
- // Reject all pending requests
103
- for (const [id, pending] of this.pending) {
104
- pending.reject(new Error('Worker terminated'));
105
- this.pending.delete(id);
106
- }
107
- }
108
- hasPending() {
109
- return this.pending.size > 0;
110
- }
111
- get pageCount() {
112
- return this._pageCount;
113
- }
114
- pageWidth(pageIndex) {
115
- return this._pageWidths[pageIndex] ?? 0;
116
- }
117
- pageHeight(pageIndex) {
118
- return this._pageHeights[pageIndex] ?? 0;
119
- }
120
- }
121
- //# sourceMappingURL=WorkerClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WorkerClient.js","sourceRoot":"","sources":["../src/WorkerClient.ts"],"names":[],"mappings":"AAqBA,MAAM,OAAO,YAAY;IACb,MAAM,CAAS;IACf,MAAM,GAAG,CAAC,CAAC;IACX,OAAO,GAAG,IAAI,GAA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AC,EAAE,WAAW,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,SAAS;QACL,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACxB,8BAA8B;QAC9B,KAAK,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACvC,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;YAC/C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC5B,CAAC;IACL,CAAC;IAED,UAAU;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;IACjC,CAAC;IAED,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,SAAS,CAAC,SAAiB;QACvB,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,UAAU,CAAC,SAAiB;QACxB,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;CACJ"}
@@ -1,166 +0,0 @@
1
- import type { Annotation, Destination } from '../types';
2
- /**
3
- * Manages annotation rendering and interaction for a document viewer.
4
- *
5
- * Annotations are rendered directly inside page slot elements for accurate positioning.
6
- */
7
- export declare class AnnotationLayer {
8
- /** Annotations indexed by page index */
9
- private pageAnnotations;
10
- /** Overlay elements indexed by page index */
11
- private overlays;
12
- /** Callback for internal link navigation */
13
- private onNavigate?;
14
- /** Callback for external link activation */
15
- private onOpenUri?;
16
- /** Current zoom level */
17
- private zoom;
18
- /** Currently active popup element */
19
- private activePopup;
20
- /** Bound handler for clicking outside popup */
21
- private boundHandleDocumentClick;
22
- /** Bound handler for escape key */
23
- private boundHandleEscapeKey;
24
- /**
25
- * Set the callback for internal link navigation.
26
- */
27
- setNavigateCallback(callback: (destination: Destination) => void): void;
28
- /**
29
- * Set the callback for external URI links.
30
- */
31
- setOpenUriCallback(callback: (uri: string) => void): void;
32
- /**
33
- * Set annotations for a specific page.
34
- */
35
- setPageAnnotations(pageIndex: number, annotations: Annotation[]): void;
36
- /**
37
- * Get annotations for a specific page.
38
- */
39
- getPageAnnotations(pageIndex: number): Annotation[];
40
- /**
41
- * Get all annotations with metadata, grouped by page.
42
- * Returns only annotations that have metadata (comments).
43
- */
44
- getAllAnnotationsWithMetadata(): Map<number, Annotation[]>;
45
- /**
46
- * Clear all annotations and overlays.
47
- */
48
- clear(): void;
49
- /**
50
- * Set the current zoom level.
51
- */
52
- setZoom(zoom: number): void;
53
- /**
54
- * Show a popup for an annotation.
55
- * @param anchorElement The element to anchor the popup to
56
- * @param metadata The annotation metadata to display
57
- * @param color The annotation color for styling
58
- */
59
- private showPopup;
60
- /**
61
- * Hide the currently active popup.
62
- */
63
- private hidePopup;
64
- /**
65
- * Create or get an annotation overlay for a slot element.
66
- * The overlay is positioned absolutely within the slot.
67
- *
68
- * @param slotEl The slot element to attach the overlay to
69
- * @param pageIndex The page index for this slot
70
- * @returns The overlay element
71
- */
72
- getOrCreateOverlay(slotEl: HTMLElement, pageIndex: number): HTMLDivElement;
73
- /**
74
- * Render annotations for a specific page into its slot overlay.
75
- *
76
- * @param slotEl The slot element containing the page
77
- * @param pageIndex The page index
78
- */
79
- renderPageAnnotations(slotEl: HTMLElement, pageIndex: number): void;
80
- /**
81
- * Render a link annotation as a clickable box.
82
- */
83
- private renderLinkAnnotation;
84
- /**
85
- * Render a highlight annotation as a colored overlay.
86
- */
87
- private renderHighlightAnnotation;
88
- /**
89
- * Add a clickable overlay for text markup annotations when metadata exists.
90
- */
91
- private addTextMarkupClickHandler;
92
- /**
93
- * Render an underline annotation as lines along the bottom of text.
94
- */
95
- private renderUnderlineAnnotation;
96
- /**
97
- * Render a strikeout annotation as lines through the middle of text.
98
- */
99
- private renderStrikeOutAnnotation;
100
- /**
101
- * Render a squiggly annotation as wavy lines under text.
102
- */
103
- private renderSquigglyAnnotation;
104
- /**
105
- * Render a text (sticky note) annotation as an icon.
106
- */
107
- private renderTextAnnotation;
108
- /**
109
- * Render a free text (typewriter/text box) annotation.
110
- */
111
- private renderFreeTextAnnotation;
112
- /**
113
- * Render a stamp annotation as a bordered text label.
114
- */
115
- private renderStampAnnotation;
116
- /**
117
- * Render a line annotation with optional line endings.
118
- */
119
- private renderLineAnnotation;
120
- /**
121
- * Draw a line ending at a point.
122
- */
123
- private drawLineEnding;
124
- /**
125
- * Render a square/rectangle annotation.
126
- */
127
- private renderSquareAnnotation;
128
- /**
129
- * Render a circle/ellipse annotation.
130
- */
131
- private renderCircleAnnotation;
132
- /**
133
- * Render a polygon annotation (closed shape).
134
- */
135
- private renderPolygonAnnotation;
136
- /**
137
- * Render a polyline annotation (open path).
138
- */
139
- private renderPolyLineAnnotation;
140
- /**
141
- * Render an ink (freehand) annotation.
142
- */
143
- private renderInkAnnotation;
144
- /**
145
- * Render a caret (text insertion point) annotation.
146
- */
147
- private renderCaretAnnotation;
148
- /**
149
- * Render a redact annotation (marks content for removal).
150
- */
151
- private renderRedactAnnotation;
152
- /**
153
- * Create an SVG element sized to cover the annotation overlay.
154
- */
155
- private createSvgOverlay;
156
- /**
157
- * Scale quad points from PDF coordinates to screen pixels.
158
- */
159
- private scaleQuadPoints;
160
- /**
161
- * Convert annotation color to CSS rgb() string.
162
- */
163
- private colorToRgb;
164
- private handleLinkAction;
165
- }
166
- //# sourceMappingURL=AnnotationLayer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AnnotationLayer.d.ts","sourceRoot":"","sources":["../../src/annotation/AnnotationLayer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,UAAU,EAIV,WAAW,EAmBd,MAAM,UAAU,CAAC;AAKlB;;;;GAIG;AACH,qBAAa,eAAe;IACxB,wCAAwC;IACxC,OAAO,CAAC,eAAe,CAAwC;IAE/D,6CAA6C;IAC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