@docmentis/udoc-viewer 0.5.18 → 0.5.20

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 (46) hide show
  1. package/README.md +199 -84
  2. package/dist/package.json +5 -2
  3. package/dist/src/UDocClient.d.ts +73 -0
  4. package/dist/src/UDocClient.d.ts.map +1 -1
  5. package/dist/src/UDocClient.js +4 -2
  6. package/dist/src/UDocClient.js.map +1 -1
  7. package/dist/src/UDocViewer.d.ts +121 -1
  8. package/dist/src/UDocViewer.d.ts.map +1 -1
  9. package/dist/src/UDocViewer.js +335 -2
  10. package/dist/src/UDocViewer.js.map +1 -1
  11. package/dist/src/index.d.ts +2 -1
  12. package/dist/src/index.d.ts.map +1 -1
  13. package/dist/src/index.js.map +1 -1
  14. package/dist/src/telemetry.d.ts +23 -0
  15. package/dist/src/telemetry.d.ts.map +1 -0
  16. package/dist/src/telemetry.js +45 -0
  17. package/dist/src/telemetry.js.map +1 -0
  18. package/dist/src/ui/viewer/actions.d.ts +19 -0
  19. package/dist/src/ui/viewer/actions.d.ts.map +1 -1
  20. package/dist/src/ui/viewer/components/FloatingToolbar.d.ts.map +1 -1
  21. package/dist/src/ui/viewer/components/FloatingToolbar.js +7 -1
  22. package/dist/src/ui/viewer/components/FloatingToolbar.js.map +1 -1
  23. package/dist/src/ui/viewer/components/LeftPanel.d.ts.map +1 -1
  24. package/dist/src/ui/viewer/components/LeftPanel.js +15 -2
  25. package/dist/src/ui/viewer/components/LeftPanel.js.map +1 -1
  26. package/dist/src/ui/viewer/components/RightPanel.d.ts.map +1 -1
  27. package/dist/src/ui/viewer/components/RightPanel.js +12 -2
  28. package/dist/src/ui/viewer/components/RightPanel.js.map +1 -1
  29. package/dist/src/ui/viewer/components/Toolbar.d.ts.map +1 -1
  30. package/dist/src/ui/viewer/components/Toolbar.js +320 -18
  31. package/dist/src/ui/viewer/components/Toolbar.js.map +1 -1
  32. package/dist/src/ui/viewer/reducer.d.ts.map +1 -1
  33. package/dist/src/ui/viewer/reducer.js +58 -1
  34. package/dist/src/ui/viewer/reducer.js.map +1 -1
  35. package/dist/src/ui/viewer/shell.d.ts.map +1 -1
  36. package/dist/src/ui/viewer/shell.js +9 -0
  37. package/dist/src/ui/viewer/shell.js.map +1 -1
  38. package/dist/src/ui/viewer/state.d.ts +12 -0
  39. package/dist/src/ui/viewer/state.d.ts.map +1 -1
  40. package/dist/src/ui/viewer/state.js +6 -0
  41. package/dist/src/ui/viewer/state.js.map +1 -1
  42. package/dist/src/ui/viewer/styles-inline.d.ts +1 -1
  43. package/dist/src/ui/viewer/styles-inline.d.ts.map +1 -1
  44. package/dist/src/ui/viewer/styles-inline.js +78 -0
  45. package/dist/src/ui/viewer/styles-inline.js.map +1 -1
  46. package/package.json +5 -2
@@ -9,6 +9,7 @@ import type { ViewerOptions } from "./UDocClient.js";
9
9
  import type { Destination, OutlineItem } from "./ui/viewer/navigation.js";
10
10
  import type { Annotation } from "./ui/viewer/annotation/index.js";
11
11
  export type { Annotation } from "./ui/viewer/annotation/index.js";
12
+ import { type PanelTab, type ScrollMode, type LayoutMode, type ZoomMode, type PageRotation, type SpacingMode } from "./ui/viewer/state.js";
12
13
  import { type IPerformanceCounter } from "./performance/index.js";
13
14
  /**
14
15
  * Options for rendering a page.
@@ -86,6 +87,10 @@ export interface DownloadProgress {
86
87
  /** Progress percentage 0-100 (null if total unknown). */
87
88
  percent: number | null;
88
89
  }
90
+ /**
91
+ * UI component identifier for visibility events.
92
+ */
93
+ export type UIComponent = "toolbar" | "floatingToolbar" | "leftPanel" | "rightPanel" | "fullscreen" | PanelTab;
89
94
  /**
90
95
  * Event map for viewer events.
91
96
  */
@@ -99,6 +104,18 @@ export interface ViewerEventMap {
99
104
  error: Error;
100
105
  phase: "fetch" | "parse" | "render";
101
106
  };
107
+ "page:change": {
108
+ page: number;
109
+ previousPage: number;
110
+ };
111
+ "ui:visibilityChange": {
112
+ component: UIComponent;
113
+ visible: boolean;
114
+ };
115
+ "panel:change": {
116
+ panel: PanelTab | null;
117
+ previousPanel: PanelTab | null;
118
+ };
102
119
  }
103
120
  type EventHandler<K extends keyof ViewerEventMap> = (payload: ViewerEventMap[K]) => void;
104
121
  /**
@@ -120,11 +137,14 @@ export declare class UDocViewer {
120
137
  private googleFontsEnabled;
121
138
  private viewOverrides;
122
139
  private currentFormat;
140
+ private storeUnsub;
141
+ private telemetryEnabled;
142
+ private sdkVersion;
123
143
  /**
124
144
  * @internal
125
145
  * Use `client.createViewer()` instead.
126
146
  */
127
- constructor(workerClient: WorkerClient, options?: ViewerOptions, showAttribution?: boolean);
147
+ constructor(workerClient: WorkerClient, options?: ViewerOptions, showAttribution?: boolean, telemetryEnabled?: boolean, sdkVersion?: string);
128
148
  /**
129
149
  * Performance counter for tracking operation timings.
130
150
  * Only records data when `enablePerformanceCounter` is true.
@@ -206,6 +226,105 @@ export declare class UDocViewer {
206
226
  * @param destination - Full destination object with page index and display mode
207
227
  */
208
228
  goToDestination(destination: Destination): void;
229
+ /**
230
+ * Navigate to the next page.
231
+ */
232
+ nextPage(): void;
233
+ /**
234
+ * Navigate to the previous page.
235
+ */
236
+ previousPage(): void;
237
+ /**
238
+ * Current zoom level (1 = 100%).
239
+ */
240
+ get zoom(): number;
241
+ /**
242
+ * Current zoom mode.
243
+ */
244
+ get zoomMode(): ZoomMode;
245
+ /**
246
+ * Zoom in to the next zoom step.
247
+ */
248
+ zoomIn(): void;
249
+ /**
250
+ * Zoom out to the previous zoom step.
251
+ */
252
+ zoomOut(): void;
253
+ /**
254
+ * Set zoom to a specific level (1 = 100%). Switches to custom zoom mode.
255
+ */
256
+ setZoom(zoom: number): void;
257
+ /**
258
+ * Set zoom mode.
259
+ */
260
+ setZoomMode(mode: ZoomMode): void;
261
+ /** Current scroll mode. */
262
+ get scrollMode(): ScrollMode;
263
+ /** Current layout mode. */
264
+ get layoutMode(): LayoutMode;
265
+ /** Current page rotation in degrees. */
266
+ get pageRotation(): PageRotation;
267
+ /** Current spacing mode. */
268
+ get spacingMode(): SpacingMode;
269
+ /** Whether the viewer is in fullscreen mode. */
270
+ get isFullscreen(): boolean;
271
+ /**
272
+ * Set scroll mode.
273
+ */
274
+ setScrollMode(mode: ScrollMode): void;
275
+ /**
276
+ * Set page layout mode.
277
+ */
278
+ setLayoutMode(mode: LayoutMode): void;
279
+ /**
280
+ * Set page rotation.
281
+ */
282
+ setPageRotation(rotation: PageRotation): void;
283
+ /**
284
+ * Set spacing mode.
285
+ */
286
+ setSpacingMode(mode: SpacingMode): void;
287
+ /**
288
+ * Enter or exit fullscreen mode.
289
+ */
290
+ setFullscreen(fullscreen: boolean): void;
291
+ /**
292
+ * Show or hide the top toolbar.
293
+ */
294
+ setToolbarVisible(visible: boolean): void;
295
+ /**
296
+ * Show or hide the floating toolbar (page navigation, zoom, view mode controls).
297
+ */
298
+ setFloatingToolbarVisible(visible: boolean): void;
299
+ /**
300
+ * Enable or disable the fullscreen button.
301
+ */
302
+ setFullscreenEnabled(enabled: boolean): void;
303
+ /**
304
+ * Enable or disable the entire left panel area.
305
+ * When disabled, the left panel is hidden and all left panel tabs are inaccessible.
306
+ */
307
+ setLeftPanelEnabled(enabled: boolean): void;
308
+ /**
309
+ * Enable or disable the entire right panel area.
310
+ * When disabled, the right panel is hidden and all right panel tabs are inaccessible.
311
+ */
312
+ setRightPanelEnabled(enabled: boolean): void;
313
+ /**
314
+ * Enable or disable a specific panel tab.
315
+ * Disabled panels are removed from the UI and cannot be opened.
316
+ * If the panel is currently open and being disabled, it will be closed.
317
+ */
318
+ setPanelEnabled(panel: PanelTab, enabled: boolean): void;
319
+ /**
320
+ * Open a specific panel.
321
+ * Has no effect if the panel is disabled via `setPanelEnabled()` or a `disable*` option.
322
+ */
323
+ openPanel(panel: PanelTab): void;
324
+ /**
325
+ * Close the currently open panel.
326
+ */
327
+ closePanel(): void;
209
328
  /**
210
329
  * Render a page to an image.
211
330
  *
@@ -271,5 +390,6 @@ export declare class UDocViewer {
271
390
  private createEngineAdapter;
272
391
  private ensureNotDestroyed;
273
392
  private ensureLoaded;
393
+ private ensureUiMode;
274
394
  }
275
395
  //# sourceMappingURL=UDocViewer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UDocViewer.d.ts","sourceRoot":"","sources":["../../src/UDocViewer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAc,MAAM,mBAAmB,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,YAAY,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGlE,OAAO,EAA8C,KAAK,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE9G;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,MAAM,CAAC,EAAE,YAAY,GAAG,cAAc,GAAG,MAAM,GAAG,UAAU,CAAC;IAE7D;;;OAGG;IACH,SAAS,CAAC,EAAE,WAAW,GAAG,YAAY,CAAC;IAEvC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,IAAI,GAAG,MAAM,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;I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EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI;IAQ7E;;OAEG;IACH,OAAO,IAAI,IAAI;IAoBf;;;OAGG;IACH,aAAa,IAAI,MAAM,GAAG,IAAI;IAI9B;;;;OAIG;IACG,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBvD,OAAO,CAAC,gBAAgB;YAWV,yBAAyB;YAiBzB,iBAAiB;IA+E/B,OAAO,CAAC,IAAI;IAaZ,OAAO,CAAC,mBAAmB;IAqB3B,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,YAAY;CAKvB"}
@@ -5,8 +5,9 @@
5
5
  * Created via `client.createViewer()`.
6
6
  */
7
7
  import { mountViewerShell } from "./ui/viewer/shell.js";
8
- import { getFormatDefaults } from "./ui/viewer/state.js";
8
+ import { getFormatDefaults, } from "./ui/viewer/state.js";
9
9
  import { PerformanceCounter, NoOpPerformanceCounter } from "./performance/index.js";
10
+ import { reportDocumentOpen } from "./telemetry.js";
10
11
  /**
11
12
  * Document viewer component.
12
13
  *
@@ -26,13 +27,18 @@ export class UDocViewer {
26
27
  googleFontsEnabled;
27
28
  viewOverrides;
28
29
  currentFormat = null;
30
+ storeUnsub = null;
31
+ telemetryEnabled;
32
+ sdkVersion;
29
33
  /**
30
34
  * @internal
31
35
  * Use `client.createViewer()` instead.
32
36
  */
33
- constructor(workerClient, options = {}, showAttribution = true) {
37
+ constructor(workerClient, options = {}, showAttribution = true, telemetryEnabled = true, sdkVersion = "__VERSION__") {
34
38
  this.workerClient = workerClient;
35
39
  this.googleFontsEnabled = options.googleFonts ?? true;
40
+ this.telemetryEnabled = telemetryEnabled;
41
+ this.sdkVersion = sdkVersion;
36
42
  this.viewOverrides = this.buildViewModeOverrides(options);
37
43
  // Initialize performance counter
38
44
  if (options.enablePerformanceCounter) {
@@ -53,6 +59,61 @@ export class UDocViewer {
53
59
  this.uiShell.setCallbacks({
54
60
  onPasswordSubmit: (password) => this.handlePasswordSubmit(password),
55
61
  });
62
+ // Subscribe to store state changes to emit public events
63
+ this.storeUnsub = this.uiShell.store.subscribeEffect((prev, next) => {
64
+ if (prev.page !== next.page) {
65
+ this.emit("page:change", { page: next.page, previousPage: prev.page });
66
+ }
67
+ if (prev.activePanel !== next.activePanel) {
68
+ this.emit("panel:change", { panel: next.activePanel, previousPanel: prev.activePanel });
69
+ }
70
+ if (prev.toolbarVisible !== next.toolbarVisible) {
71
+ this.emit("ui:visibilityChange", { component: "toolbar", visible: next.toolbarVisible });
72
+ }
73
+ if (prev.floatingToolbarVisible !== next.floatingToolbarVisible) {
74
+ this.emit("ui:visibilityChange", {
75
+ component: "floatingToolbar",
76
+ visible: next.floatingToolbarVisible,
77
+ });
78
+ }
79
+ if (prev.leftPanelVisible !== next.leftPanelVisible) {
80
+ this.emit("ui:visibilityChange", {
81
+ component: "leftPanel",
82
+ visible: next.leftPanelVisible,
83
+ });
84
+ }
85
+ if (prev.rightPanelVisible !== next.rightPanelVisible) {
86
+ this.emit("ui:visibilityChange", {
87
+ component: "rightPanel",
88
+ visible: next.rightPanelVisible,
89
+ });
90
+ }
91
+ if (prev.fullscreenButtonVisible !== next.fullscreenButtonVisible) {
92
+ this.emit("ui:visibilityChange", {
93
+ component: "fullscreen",
94
+ visible: next.fullscreenButtonVisible,
95
+ });
96
+ }
97
+ if (prev.disabledPanels !== next.disabledPanels) {
98
+ // Emit events for panels whose disabled state changed
99
+ const allPanels = [
100
+ "thumbnail",
101
+ "outline",
102
+ "bookmarks",
103
+ "layers",
104
+ "attachments",
105
+ "search",
106
+ "comments",
107
+ ];
108
+ for (const panel of allPanels) {
109
+ const wasDisabled = prev.disabledPanels.has(panel);
110
+ const isDisabled = next.disabledPanels.has(panel);
111
+ if (wasDisabled !== isDisabled) {
112
+ this.emit("ui:visibilityChange", { component: panel, visible: !isDisabled });
113
+ }
114
+ }
115
+ }
116
+ });
56
117
  }
57
118
  }
58
119
  /**
@@ -82,6 +143,35 @@ export class UDocViewer {
82
143
  overrides.spreadSpacing = options.spreadSpacing;
83
144
  if (options.activePanel !== undefined)
84
145
  overrides.activePanel = options.activePanel;
146
+ if (options.hideToolbar)
147
+ overrides.toolbarVisible = false;
148
+ if (options.hideFloatingToolbar)
149
+ overrides.floatingToolbarVisible = false;
150
+ if (options.disableFullscreen)
151
+ overrides.fullscreenButtonVisible = false;
152
+ if (options.disableLeftPanel)
153
+ overrides.leftPanelVisible = false;
154
+ if (options.disableRightPanel)
155
+ overrides.rightPanelVisible = false;
156
+ // Collect individually disabled panels into the internal Set
157
+ const disabled = [];
158
+ if (options.disableThumbnails)
159
+ disabled.push("thumbnail");
160
+ if (options.disableOutline)
161
+ disabled.push("outline");
162
+ if (options.disableBookmarks)
163
+ disabled.push("bookmarks");
164
+ if (options.disableLayers)
165
+ disabled.push("layers");
166
+ if (options.disableAttachments)
167
+ disabled.push("attachments");
168
+ if (options.disableSearch)
169
+ disabled.push("search");
170
+ if (options.disableComments)
171
+ disabled.push("comments");
172
+ if (disabled.length > 0) {
173
+ overrides.disabledPanels = new Set(disabled);
174
+ }
85
175
  return overrides;
86
176
  }
87
177
  buildViewModeOverrides(options) {
@@ -177,6 +267,15 @@ export class UDocViewer {
177
267
  this._performanceCounter.markEnd(initUiId);
178
268
  }
179
269
  this.emit("document:load", { pageCount: this._pageCount });
270
+ // Report telemetry (fire-and-forget, never throws)
271
+ if (this.telemetryEnabled) {
272
+ reportDocumentOpen({
273
+ domain: typeof window !== "undefined" ? window.location.hostname : "unknown",
274
+ format,
275
+ size_bucket: Math.floor(bytes.length / 100_000),
276
+ viewer_version: this.sdkVersion,
277
+ });
278
+ }
180
279
  }
181
280
  catch (error) {
182
281
  const phase = error instanceof TypeError ? "fetch" : "parse";
@@ -381,6 +480,231 @@ export class UDocViewer {
381
480
  }
382
481
  this.uiShell.dispatch({ type: "NAVIGATE_TO_DESTINATION", destination });
383
482
  }
483
+ /**
484
+ * Navigate to the next page.
485
+ */
486
+ nextPage() {
487
+ this.ensureNotDestroyed();
488
+ this.ensureUiMode();
489
+ const state = this.uiShell.getState();
490
+ if (state.page < state.pageCount) {
491
+ this.uiShell.dispatch({ type: "NAVIGATE_TO_PAGE", page: state.page + 1 });
492
+ }
493
+ }
494
+ /**
495
+ * Navigate to the previous page.
496
+ */
497
+ previousPage() {
498
+ this.ensureNotDestroyed();
499
+ this.ensureUiMode();
500
+ const state = this.uiShell.getState();
501
+ if (state.page > 1) {
502
+ this.uiShell.dispatch({ type: "NAVIGATE_TO_PAGE", page: state.page - 1 });
503
+ }
504
+ }
505
+ // ===========================================================================
506
+ // Zoom
507
+ // ===========================================================================
508
+ /**
509
+ * Current zoom level (1 = 100%).
510
+ */
511
+ get zoom() {
512
+ if (this.uiShell) {
513
+ const state = this.uiShell.getState();
514
+ return state.zoomMode === "custom" ? state.zoom : (state.effectiveZoom ?? state.zoom);
515
+ }
516
+ return 1;
517
+ }
518
+ /**
519
+ * Current zoom mode.
520
+ */
521
+ get zoomMode() {
522
+ if (this.uiShell) {
523
+ return this.uiShell.getState().zoomMode;
524
+ }
525
+ return "fit-spread-width";
526
+ }
527
+ /**
528
+ * Zoom in to the next zoom step.
529
+ */
530
+ zoomIn() {
531
+ this.ensureNotDestroyed();
532
+ this.ensureUiMode();
533
+ this.uiShell.dispatch({ type: "ZOOM_IN" });
534
+ }
535
+ /**
536
+ * Zoom out to the previous zoom step.
537
+ */
538
+ zoomOut() {
539
+ this.ensureNotDestroyed();
540
+ this.ensureUiMode();
541
+ this.uiShell.dispatch({ type: "ZOOM_OUT" });
542
+ }
543
+ /**
544
+ * Set zoom to a specific level (1 = 100%). Switches to custom zoom mode.
545
+ */
546
+ setZoom(zoom) {
547
+ this.ensureNotDestroyed();
548
+ this.ensureUiMode();
549
+ this.uiShell.dispatch({ type: "SET_ZOOM", zoom });
550
+ }
551
+ /**
552
+ * Set zoom mode.
553
+ */
554
+ setZoomMode(mode) {
555
+ this.ensureNotDestroyed();
556
+ this.ensureUiMode();
557
+ this.uiShell.dispatch({ type: "SET_ZOOM_MODE", mode });
558
+ }
559
+ // ===========================================================================
560
+ // View Modes
561
+ // ===========================================================================
562
+ /** Current scroll mode. */
563
+ get scrollMode() {
564
+ return this.uiShell?.getState().scrollMode ?? "continuous";
565
+ }
566
+ /** Current layout mode. */
567
+ get layoutMode() {
568
+ return this.uiShell?.getState().layoutMode ?? "single-page";
569
+ }
570
+ /** Current page rotation in degrees. */
571
+ get pageRotation() {
572
+ return this.uiShell?.getState().pageRotation ?? 0;
573
+ }
574
+ /** Current spacing mode. */
575
+ get spacingMode() {
576
+ return this.uiShell?.getState().spacingMode ?? "all";
577
+ }
578
+ /** Whether the viewer is in fullscreen mode. */
579
+ get isFullscreen() {
580
+ return this.uiShell?.getState().isFullscreen ?? false;
581
+ }
582
+ /**
583
+ * Set scroll mode.
584
+ */
585
+ setScrollMode(mode) {
586
+ this.ensureNotDestroyed();
587
+ this.ensureUiMode();
588
+ this.uiShell.dispatch({ type: "SET_SCROLL_MODE", mode });
589
+ }
590
+ /**
591
+ * Set page layout mode.
592
+ */
593
+ setLayoutMode(mode) {
594
+ this.ensureNotDestroyed();
595
+ this.ensureUiMode();
596
+ this.uiShell.dispatch({ type: "SET_LAYOUT_MODE", mode });
597
+ }
598
+ /**
599
+ * Set page rotation.
600
+ */
601
+ setPageRotation(rotation) {
602
+ this.ensureNotDestroyed();
603
+ this.ensureUiMode();
604
+ this.uiShell.dispatch({ type: "SET_PAGE_ROTATION", rotation });
605
+ }
606
+ /**
607
+ * Set spacing mode.
608
+ */
609
+ setSpacingMode(mode) {
610
+ this.ensureNotDestroyed();
611
+ this.ensureUiMode();
612
+ this.uiShell.dispatch({ type: "SET_SPACING_MODE", mode });
613
+ }
614
+ /**
615
+ * Enter or exit fullscreen mode.
616
+ */
617
+ setFullscreen(fullscreen) {
618
+ this.ensureNotDestroyed();
619
+ this.ensureUiMode();
620
+ this.uiShell.dispatch({ type: "SET_FULLSCREEN", isFullscreen: fullscreen });
621
+ // Also toggle the actual browser fullscreen
622
+ const root = this.container?.querySelector(".udoc-viewer-root");
623
+ if (root) {
624
+ if (fullscreen && !document.fullscreenElement) {
625
+ root.requestFullscreen().catch(() => { });
626
+ }
627
+ else if (!fullscreen && document.fullscreenElement) {
628
+ document.exitFullscreen().catch(() => { });
629
+ }
630
+ }
631
+ }
632
+ // ===========================================================================
633
+ // UI Component Visibility
634
+ // ===========================================================================
635
+ /**
636
+ * Show or hide the top toolbar.
637
+ */
638
+ setToolbarVisible(visible) {
639
+ this.ensureNotDestroyed();
640
+ this.ensureUiMode();
641
+ this.uiShell.dispatch({ type: "SET_TOOLBAR_VISIBLE", visible });
642
+ }
643
+ /**
644
+ * Show or hide the floating toolbar (page navigation, zoom, view mode controls).
645
+ */
646
+ setFloatingToolbarVisible(visible) {
647
+ this.ensureNotDestroyed();
648
+ this.ensureUiMode();
649
+ this.uiShell.dispatch({ type: "SET_FLOATING_TOOLBAR_VISIBLE", visible });
650
+ }
651
+ /**
652
+ * Enable or disable the fullscreen button.
653
+ */
654
+ setFullscreenEnabled(enabled) {
655
+ this.ensureNotDestroyed();
656
+ this.ensureUiMode();
657
+ this.uiShell.dispatch({ type: "SET_FULLSCREEN_BUTTON_VISIBLE", visible: enabled });
658
+ }
659
+ /**
660
+ * Enable or disable the entire left panel area.
661
+ * When disabled, the left panel is hidden and all left panel tabs are inaccessible.
662
+ */
663
+ setLeftPanelEnabled(enabled) {
664
+ this.ensureNotDestroyed();
665
+ this.ensureUiMode();
666
+ this.uiShell.dispatch({ type: "SET_LEFT_PANEL_VISIBLE", visible: enabled });
667
+ }
668
+ /**
669
+ * Enable or disable the entire right panel area.
670
+ * When disabled, the right panel is hidden and all right panel tabs are inaccessible.
671
+ */
672
+ setRightPanelEnabled(enabled) {
673
+ this.ensureNotDestroyed();
674
+ this.ensureUiMode();
675
+ this.uiShell.dispatch({ type: "SET_RIGHT_PANEL_VISIBLE", visible: enabled });
676
+ }
677
+ /**
678
+ * Enable or disable a specific panel tab.
679
+ * Disabled panels are removed from the UI and cannot be opened.
680
+ * If the panel is currently open and being disabled, it will be closed.
681
+ */
682
+ setPanelEnabled(panel, enabled) {
683
+ this.ensureNotDestroyed();
684
+ this.ensureUiMode();
685
+ this.uiShell.dispatch({ type: "SET_PANEL_DISABLED", panel, disabled: !enabled });
686
+ }
687
+ /**
688
+ * Open a specific panel.
689
+ * Has no effect if the panel is disabled via `setPanelEnabled()` or a `disable*` option.
690
+ */
691
+ openPanel(panel) {
692
+ this.ensureNotDestroyed();
693
+ this.ensureUiMode();
694
+ this.uiShell.dispatch({ type: "TOGGLE_PANEL", panel });
695
+ // If it was already open, TOGGLE_PANEL closed it. Re-open.
696
+ if (this.uiShell.getState().activePanel !== panel) {
697
+ this.uiShell.dispatch({ type: "TOGGLE_PANEL", panel });
698
+ }
699
+ }
700
+ /**
701
+ * Close the currently open panel.
702
+ */
703
+ closePanel() {
704
+ this.ensureNotDestroyed();
705
+ this.ensureUiMode();
706
+ this.uiShell.dispatch({ type: "CLOSE_PANEL" });
707
+ }
384
708
  // ===========================================================================
385
709
  // Page Rendering
386
710
  // ===========================================================================
@@ -526,6 +850,10 @@ export class UDocViewer {
526
850
  if (this.destroyed)
527
851
  return;
528
852
  this.destroyed = true;
853
+ if (this.storeUnsub) {
854
+ this.storeUnsub();
855
+ this.storeUnsub = null;
856
+ }
529
857
  if (this.uiShell) {
530
858
  this.uiShell.destroy();
531
859
  this.uiShell = null;
@@ -701,6 +1029,11 @@ export class UDocViewer {
701
1029
  throw new Error("No document loaded");
702
1030
  }
703
1031
  }
1032
+ ensureUiMode() {
1033
+ if (!this.uiShell) {
1034
+ throw new Error("This method requires UI mode (container must be provided)");
1035
+ }
1036
+ }
704
1037
  }
705
1038
  /**
706
1039
  * Detect document format based on magic bytes and filename.