@dtducas/wh-forge-viewer 1.0.5 → 1.0.6

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.
package/README.md CHANGED
@@ -6,9 +6,12 @@ A customized Autodesk Forge Viewer component for React with enhanced PDF support
6
6
 
7
7
  - ✅ **Custom Toolbar** - Pre-configured toolbar with Pan, Document Browser, Download, and Pagination controls
8
8
  - ✅ **PDF Support** - Optimized for viewing PDF documents with page navigation
9
+ - ✅ **Auto Document Browser** - Automatically opens on startup, positioned on left side
10
+ - ✅ **Smooth Pagination** - Page navigation without toolbar flickering
9
11
  - ✅ **Self-Healing** - Automatic toolbar recovery mechanism ensures UI persistence
10
12
  - ✅ **3D/2D Models** - Full support for Autodesk Forge 3D and 2D models
11
13
  - ✅ **React Integration** - Easy-to-use React component with hooks support
14
+ - ✅ **SOLID Architecture** - Follows SOLID principles with Manager pattern for maintainability
12
15
 
13
16
  ## Installation
14
17
 
@@ -62,7 +65,28 @@ The viewer includes a custom toolbar with:
62
65
 
63
66
  - React ^17.0.0 || ^18.0.0
64
67
  - Ant Design ^5.0.0
65
- - Autodesk Forge Viewer v7
68
+ - Autodesk Forge Viewer v7.108.0 (pinned for stability)
69
+
70
+ ## Important Notes
71
+
72
+ ### Viewer Versioning
73
+
74
+ This package uses a **specific version** of Autodesk Forge Viewer (v7.108.0) instead of wildcards (7.*) to ensure production stability and avoid unexpected breaking changes.
75
+
76
+ **Why?** Using wildcards can introduce unexpected behavior changes when Autodesk releases updates. For production applications, always use a specific tested version.
77
+
78
+ 📖 See [docs/VERSIONING.md](docs/VERSIONING.md) for version update guide.
79
+
80
+ ## Architecture
81
+
82
+ This package follows **SOLID principles** and uses a modular architecture:
83
+
84
+ - **Managers Pattern** - Separate managers for Pagination, Toolbar, and Document Browser
85
+ - **Service Layer** - EventBus, FileLoader, DownloadService
86
+ - **Type Safety** - Full TypeScript type definitions
87
+ - **Dependency Injection** - Clean separation of concerns
88
+
89
+ 📖 See [ARCHITECTURE.md](ARCHITECTURE.md) for detailed architecture documentation.
66
90
 
67
91
  ## Development
68
92
 
package/dist/index.d.ts CHANGED
@@ -1,89 +1,79 @@
1
1
  // Type definitions for @dtducas/wh-forge-viewer
2
2
  // Project: https://github.com/DTDucas/wh-forge-viewer
3
3
  // Definitions by: Duong Tran Quang <https://github.com/DTDucas>
4
-
5
4
  /// <reference types="react" />
6
-
7
5
  declare module '@dtducas/wh-forge-viewer' {
8
- import { FC } from 'react';
9
-
6
+ import { FC } from 'react';
7
+ /**
8
+ * Supported file extensions for the Forge Viewer
9
+ */
10
+ export type TSupportedFileExtension = 'pdf' | 'dwf' | 'dwfx';
11
+ /**
12
+ * Autodesk Forge Viewer namespace
13
+ * For full type definitions, see Autodesk Forge Viewer documentation
14
+ */
15
+ export namespace Autodesk {
16
+ export namespace Viewing {
17
+ export class GuiViewer3D {
18
+ // Add minimal type stubs for commonly used methods
19
+ start(): void;
20
+ loadExtension(extensionId: string, options?: any): Promise<any>;
21
+ loadModel(url: string, options?: any, onSuccess?: Function): void;
22
+ loadDocumentNode(document: any, node: any): Promise<any>;
23
+ addEventListener(event: string, callback: Function): void;
24
+ removeEventListener(event: string, callback: Function): void;
25
+ setReverseZoomDirection(value: boolean): void;
26
+ getExtension(extensionId: string): any;
27
+ setTool(toolName: string): void;
28
+ toolbar: any;
29
+ model: any;
30
+ }
31
+ export interface Extension {
32
+ load(): boolean;
33
+ unload(): boolean;
34
+ }
35
+ // Common event constants
36
+ export const GEOMETRY_LOADED_EVENT: string;
37
+ export const MODEL_ADDED_EVENT: string;
38
+ export const TOOLBAR_CREATED_EVENT: string;
39
+ }
40
+ }
41
+ /**
42
+ * Props for ViewerForgePDF component
43
+ */
44
+ export interface IViewerForgePDFProps {
10
45
  /**
11
- * Supported file extensions for the Forge Viewer
46
+ * URL/path to the document to load
12
47
  */
13
- export type TSupportedFileExtension = 'pdf' | 'dwf' | 'dwfx';
14
-
48
+ filePath: string;
15
49
  /**
16
- * Autodesk Forge Viewer namespace
17
- * For full type definitions, see Autodesk Forge Viewer documentation
50
+ * File extension (pdf, dwf, dwfx)
18
51
  */
19
- export namespace Autodesk {
20
- export namespace Viewing {
21
- export class GuiViewer3D {
22
- // Add minimal type stubs for commonly used methods
23
- start(): void;
24
- loadExtension(extensionId: string, options?: any): Promise<any>;
25
- loadModel(url: string, options?: any, onSuccess?: Function): void;
26
- loadDocumentNode(document: any, node: any): Promise<any>;
27
- addEventListener(event: string, callback: Function): void;
28
- removeEventListener(event: string, callback: Function): void;
29
- setReverseZoomDirection(value: boolean): void;
30
- getExtension(extensionId: string): any;
31
- setTool(toolName: string): void;
32
- toolbar: any;
33
- model: any;
34
- }
35
-
36
- export interface Extension {
37
- load(): boolean;
38
- unload(): boolean;
39
- }
40
-
41
- // Common event constants
42
- export const GEOMETRY_LOADED_EVENT: string;
43
- export const MODEL_ADDED_EVENT: string;
44
- export const TOOLBAR_CREATED_EVENT: string;
45
- }
46
- }
47
-
48
- /**
49
- * Props for ViewerForgePDF component
50
- */
51
- export interface IViewerForgePDFProps {
52
- /**
53
- * URL/path to the document to load
54
- */
55
- filePath: string;
56
-
57
- /**
58
- * File extension (pdf, dwf, dwfx)
59
- */
60
- fileExt: TSupportedFileExtension;
61
-
62
- /**
63
- * Callback to receive viewer instance when initialized
64
- */
65
- setViewer?: (viewer: Autodesk.Viewing.GuiViewer3D | null) => void;
66
- }
67
-
52
+ fileExt: TSupportedFileExtension;
68
53
  /**
69
- * ViewerForgePDF - React component for displaying PDF and CAD files using Autodesk Forge Viewer
70
- *
71
- * @example
72
- * ```tsx
73
- * import { ViewerForgePDF } from '@dtducas/wh-forge-viewer';
74
- *
75
- * function MyApp() {
76
- * const [viewer, setViewer] = useState<Autodesk.Viewing.GuiViewer3D | null>(null);
77
- *
78
- * return (
79
- * <ViewerForgePDF
80
- * filePath="https://example.com/document.pdf"
81
- * fileExt="pdf"
82
- * setViewer={setViewer}
83
- * />
84
- * );
85
- * }
86
- * ```
54
+ * Callback to receive viewer instance when initialized
87
55
  */
88
- export const ViewerForgePDF: FC<IViewerForgePDFProps>;
56
+ setViewer?: (viewer: Autodesk.Viewing.GuiViewer3D | null) => void;
57
+ }
58
+ /**
59
+ * ViewerForgePDF - React component for displaying PDF and CAD files using Autodesk Forge Viewer
60
+ *
61
+ * @example
62
+ * ```tsx
63
+ * import { ViewerForgePDF } from '@dtducas/wh-forge-viewer';
64
+ *
65
+ * function MyApp() {
66
+ * const [viewer, setViewer] = useState<Autodesk.Viewing.GuiViewer3D | null>(null);
67
+ *
68
+ * return (
69
+ * <ViewerForgePDF
70
+ * filePath="https://example.com/document.pdf"
71
+ * fileExt="pdf"
72
+ * setViewer={setViewer}
73
+ * />
74
+ * );
75
+ * }
76
+ * ```
77
+ */
78
+ export const ViewerForgePDF: FC<IViewerForgePDFProps>;
89
79
  }