Skip to content

Commit 439bce2

Browse files
committed
feat: add dist folder to allow ootb samples to run
1 parent 9a9508c commit 439bce2

File tree

9 files changed

+1751
-1
lines changed

9 files changed

+1751
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
dist
1+
# dist
22
node_modules

dist/dds.bundle.esm.d.ts

Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
import { DSImageData, OriginalImageResultItem, Quadrilateral, EngineResourcePaths } from 'dynamsoft-core';
2+
export * from 'dynamsoft-core';
3+
export * from 'dynamsoft-license';
4+
import { CapturedResult, CaptureVisionRouter } from 'dynamsoft-capture-vision-router';
5+
export * from 'dynamsoft-capture-vision-router';
6+
import { CameraEnhancer, CameraView } from 'dynamsoft-camera-enhancer';
7+
export * from 'dynamsoft-camera-enhancer';
8+
import { NormalizedImageResultItem } from 'dynamsoft-document-normalizer';
9+
export * from 'dynamsoft-document-normalizer';
10+
export * from 'dynamsoft-utility';
11+
export { NormalizedImageResultItem, PlayCallbackInfo, Point, Rect, VideoDeviceInfo } from 'dynamsoft-capture-vision-bundle';
12+
13+
declare enum EnumDDSViews {
14+
Scanner = "scanner",
15+
Result = "scan-result",
16+
Correction = "correction"
17+
}
18+
interface UtilizedTemplateNames {
19+
detect: string;
20+
normalize: string;
21+
}
22+
declare enum EnumResultStatus {
23+
RS_SUCCESS = 0,
24+
RS_CANCELLED = 1,
25+
RS_FAILED = 2
26+
}
27+
declare enum EnumFlowType {
28+
MANUAL = "manual",
29+
SMART_CAPTURE = "smartCapture",
30+
AUTO_CROP = "autoCrop",
31+
UPLOADED_IMAGE = "uploadedImage"
32+
}
33+
type ResultStatus = {
34+
code: EnumResultStatus;
35+
message?: string;
36+
};
37+
interface DocumentResult {
38+
status: ResultStatus;
39+
correctedImageResult?: NormalizedImageResultItem | DSImageData;
40+
originalImageResult?: OriginalImageResultItem["imageData"];
41+
detectedQuadrilateral?: Quadrilateral;
42+
_flowType?: EnumFlowType;
43+
}
44+
type ToolbarButtonConfig = Pick<ToolbarButton, "icon" | "label" | "className" | "isHidden">;
45+
interface ToolbarButton {
46+
id: string;
47+
icon: string;
48+
label: string;
49+
onClick?: () => void | Promise<void>;
50+
className?: string;
51+
isDisabled?: boolean;
52+
isHidden?: boolean;
53+
}
54+
55+
interface DocumentCorrectionViewToolbarButtonsConfig {
56+
fullImage?: ToolbarButtonConfig;
57+
detectBorders?: ToolbarButtonConfig;
58+
apply?: ToolbarButtonConfig;
59+
}
60+
interface DocumentCorrectionViewConfig {
61+
container?: HTMLElement | string;
62+
toolbarButtonsConfig?: DocumentCorrectionViewToolbarButtonsConfig;
63+
templateFilePath?: string;
64+
utilizedTemplateNames?: UtilizedTemplateNames;
65+
onFinish?: (result: DocumentResult) => void;
66+
_showResultView?: boolean;
67+
}
68+
declare class DocumentCorrectionView {
69+
private resources;
70+
private config;
71+
private imageEditorView;
72+
private layer;
73+
private currentCorrectionResolver?;
74+
constructor(resources: SharedResources, config: DocumentCorrectionViewConfig);
75+
initialize(): Promise<void>;
76+
private setupDrawingLayerStyle;
77+
private setupQuadConstraints;
78+
private getCanvasBounds;
79+
private addQuadToLayer;
80+
private setupInitialDetectedQuad;
81+
private createControls;
82+
private setupCorrectionControls;
83+
setFullImageBoundary(): void;
84+
setBoundaryAutomatically(): Promise<void>;
85+
confirmCorrection(): Promise<void>;
86+
launch(): Promise<DocumentResult>;
87+
hideView(): void;
88+
/**
89+
* Normalize an image with DDN given a set of points
90+
* @param points - points provided by either users or DDN's detect quad
91+
* @returns normalized image by DDN
92+
*/
93+
correctImage(points: Quadrilateral["points"]): Promise<NormalizedImageResultItem>;
94+
dispose(): void;
95+
}
96+
97+
interface DocumentScannerViewConfig {
98+
_showCorrectionView?: boolean;
99+
templateFilePath?: string;
100+
cameraEnhancerUIPath?: string;
101+
container?: HTMLElement | string;
102+
utilizedTemplateNames?: UtilizedTemplateNames;
103+
}
104+
declare class DocumentScannerView {
105+
private resources;
106+
private config;
107+
private boundsDetectionEnabled;
108+
private smartCaptureEnabled;
109+
private autoCropEnabled;
110+
private crossVerificationCount;
111+
private capturedResultItems;
112+
private originalImageData;
113+
private initialized;
114+
private initializedDCE;
115+
private DCE_ELEMENTS;
116+
private currentScanResolver?;
117+
private loadingScreen;
118+
private showScannerLoadingOverlay;
119+
private hideScannerLoadingOverlay;
120+
constructor(resources: SharedResources, config: DocumentScannerViewConfig);
121+
initialize(): Promise<void>;
122+
private initializeElements;
123+
private assignDCEClickEvents;
124+
handleCloseBtn(): Promise<void>;
125+
private attachOptionClickListeners;
126+
private highlightCameraAndResolutionOption;
127+
private toggleSelectCameraBox;
128+
private uploadImage;
129+
private fileToBlob;
130+
toggleAutoCaptureAnimation(enabled?: boolean): Promise<void>;
131+
toggleBoundsDetection(enabled?: boolean): Promise<void>;
132+
toggleSmartCapture(mode?: boolean): Promise<void>;
133+
toggleAutoCrop(mode?: boolean): Promise<void>;
134+
openCamera(): Promise<void>;
135+
closeCamera(hideContainer?: boolean): void;
136+
pauseCamera(): void;
137+
stopCapturing(): void;
138+
private getFlowType;
139+
takePhoto(): Promise<void>;
140+
handleBoundsDetection(result: CapturedResult): Promise<void>;
141+
/**
142+
* Normalize an image with DDN given a set of points
143+
* @param points - points provided by either users or DDN's detect quad
144+
* @returns normalized image by DDN
145+
*/
146+
private handleAutoCaptureMode;
147+
launch(): Promise<DocumentResult>;
148+
normalizeImage(points: Quadrilateral["points"], originalImageData: OriginalImageResultItem["imageData"]): Promise<NormalizedImageResultItem>;
149+
}
150+
151+
interface DocumentResultViewToolbarButtonsConfig {
152+
retake?: ToolbarButtonConfig;
153+
correct?: ToolbarButtonConfig;
154+
share?: ToolbarButtonConfig;
155+
upload?: ToolbarButtonConfig;
156+
done?: ToolbarButtonConfig;
157+
}
158+
interface DocumentResultViewConfig {
159+
container?: HTMLElement | string;
160+
toolbarButtonsConfig?: DocumentResultViewToolbarButtonsConfig;
161+
onDone?: (result: DocumentResult) => Promise<void>;
162+
onUpload?: (result: DocumentResult) => Promise<void>;
163+
}
164+
declare class DocumentResultView {
165+
private resources;
166+
private config;
167+
private scannerView;
168+
private correctionView;
169+
private currentScanResultViewResolver?;
170+
constructor(resources: SharedResources, config: DocumentResultViewConfig, scannerView: DocumentScannerView, correctionView: DocumentCorrectionView);
171+
launch(): Promise<DocumentResult>;
172+
private handleUploadAndShareBtn;
173+
private handleShare;
174+
private handleCorrectImage;
175+
private handleRetake;
176+
private handleDone;
177+
private createControls;
178+
initialize(): Promise<void>;
179+
hideView(): void;
180+
dispose(preserveResolver?: boolean): void;
181+
}
182+
183+
interface DocumentScannerConfig {
184+
license?: string;
185+
container?: HTMLElement | string;
186+
templateFilePath?: string;
187+
utilizedTemplateNames?: UtilizedTemplateNames;
188+
engineResourcePaths?: EngineResourcePaths;
189+
scannerViewConfig?: Omit<DocumentScannerViewConfig, "templateFilePath" | "utilizedTemplateNames" | "_showCorrectionView">;
190+
resultViewConfig?: DocumentResultViewConfig;
191+
correctionViewConfig?: Omit<DocumentCorrectionViewConfig, "templateFilePath" | "utilizedTemplateNames" | "_showCorrectionView">;
192+
showResultView?: boolean;
193+
showCorrectionView?: boolean;
194+
}
195+
interface SharedResources {
196+
cvRouter?: CaptureVisionRouter;
197+
cameraEnhancer?: CameraEnhancer;
198+
cameraView?: CameraView;
199+
result?: DocumentResult;
200+
onResultUpdated?: (result: DocumentResult) => void;
201+
}
202+
declare class DocumentScanner {
203+
private config;
204+
private scannerView?;
205+
private scanResultView?;
206+
private correctionView?;
207+
private resources;
208+
private isInitialized;
209+
private isCapturing;
210+
constructor(config: DocumentScannerConfig);
211+
initialize(): Promise<{
212+
resources: SharedResources;
213+
components: {
214+
scannerView?: DocumentScannerView;
215+
correctionView?: DocumentCorrectionView;
216+
scanResultView?: DocumentResultView;
217+
};
218+
}>;
219+
private initializeDCVResources;
220+
private shouldCreateDefaultContainer;
221+
private createDefaultDDSContainer;
222+
private checkForTemporaryLicense;
223+
private validateViewConfigs;
224+
private showCorrectionView;
225+
private showResultView;
226+
private initializeDDSConfig;
227+
private createViewContainers;
228+
dispose(): void;
229+
/**
230+
* Launches the document scanning process.
231+
*
232+
* Configuration Requirements:
233+
* 1. A container must be provided either through:
234+
* - A main container in config.container, OR
235+
* - Individual view containers in viewConfig.container when corresponding show flags are true
236+
* 2. If no main container is provided:
237+
* - showCorrectionView: true requires correctionViewConfig.container
238+
* - showResultView: true requires resultViewConfig.container
239+
*
240+
* Flow paths based on view configurations and capture method:
241+
*
242+
* 1. All views enabled (Scanner, Correction, Result):
243+
* A. Auto-capture paths:
244+
* - Smart Capture: Scanner -> Correction -> Result
245+
* - Auto Crop: Scanner -> Result
246+
* B. Manual paths:
247+
* - Upload Image: Scanner -> Correction -> Result
248+
* - Manual Capture: Scanner -> Result
249+
*
250+
* 2. Scanner + Result only:
251+
* - Flow: Scanner -> Result
252+
* - Requires: showCorrectionView: false or undefined
253+
*
254+
* 3. Scanner + Correction only:
255+
* - Flow: Scanner -> Correction
256+
* - Requires: showResultView: false or undefined
257+
*
258+
* 4. Special cases:
259+
* - Scanner only: Returns scan result directly
260+
* - Correction only + existing result: Goes to Correction
261+
* - Result only + existing result: Goes to Result
262+
*
263+
* @returns Promise<DocumentResult> containing:
264+
* - status: Success/Failed/Cancelled with message
265+
* - originalImageResult: Raw captured image
266+
* - correctedImageResult: Normalized image (if correction applied)
267+
* - detectedQuadrilateral: Document boundaries
268+
* - _flowType: Internal routing flag for different capture methods
269+
*
270+
* @throws Error if:
271+
* - Capture session is already running
272+
* - Scanner view is required but not configured
273+
* - No container is provided when showCorrectionView or showResultView is true
274+
*/
275+
launch(): Promise<DocumentResult>;
276+
}
277+
278+
declare const DDS: {
279+
DocumentScanner: typeof DocumentScanner;
280+
DocumentNormalizerView: typeof DocumentCorrectionView;
281+
DocumentScannerView: typeof DocumentScannerView;
282+
DocumentResultView: typeof DocumentResultView;
283+
EnumResultStatus: typeof EnumResultStatus;
284+
EnumFlowType: typeof EnumFlowType;
285+
EnumDDSViews: typeof EnumDDSViews;
286+
};
287+
288+
export { DDS, DocumentCorrectionViewConfig, DocumentCorrectionViewToolbarButtonsConfig, DocumentCorrectionView as DocumentNormalizerView, DocumentResult, DocumentResultView, DocumentResultViewConfig, DocumentResultViewToolbarButtonsConfig, DocumentScanner, DocumentScannerConfig, DocumentScannerView, DocumentScannerViewConfig, EnumResultStatus, ResultStatus, SharedResources, ToolbarButtonConfig, UtilizedTemplateNames };

dist/dds.bundle.js

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/dds.bundle.mjs

Lines changed: 11 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)