Skip to content

Commit 54ea316

Browse files
committed
feat: release v1.2.0
1 parent eff6909 commit 54ea316

23 files changed

+1499
-798
lines changed

README.md

+121-25
Large diffs are not rendered by default.

dev-server/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ app.get("/hello-world", (req, res) => {
5050
res.sendFile(path.join(__dirname, "../samples/hello-world.html"));
5151
});
5252

53+
app.get("/scenarios/use-file-input", (req, res) => {
54+
res.sendFile(path.join(__dirname, "../samples/scenarios/use-file-input.html"));
55+
});
56+
5357
// Allow upload feature
5458
app.post("/upload", function (req, res) {
5559
try {

dist/dds.bundle.esm.d.ts

+88-87
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DSImageData, OriginalImageResultItem, Quadrilateral, EngineResourcePaths } from 'dynamsoft-core';
1+
import { DSImageData, Quadrilateral, OriginalImageResultItem, EngineResourcePaths } from 'dynamsoft-core';
22
export * from 'dynamsoft-core';
33
export * from 'dynamsoft-license';
44
import { CapturedResult, CaptureVisionRouter } from 'dynamsoft-capture-vision-router';
@@ -28,7 +28,8 @@ declare enum EnumFlowType {
2828
MANUAL = "manual",
2929
SMART_CAPTURE = "smartCapture",
3030
AUTO_CROP = "autoCrop",
31-
UPLOADED_IMAGE = "uploadedImage"
31+
UPLOADED_IMAGE = "uploadedImage",
32+
STATIC_FILE = "staticFile"
3233
}
3334
type ResultStatus = {
3435
code: EnumResultStatus;
@@ -37,7 +38,7 @@ type ResultStatus = {
3738
interface DocumentResult {
3839
status: ResultStatus;
3940
correctedImageResult?: NormalizedImageResultItem | DSImageData;
40-
originalImageResult?: OriginalImageResultItem["imageData"];
41+
originalImageResult?: DSImageData;
4142
detectedQuadrilateral?: Quadrilateral;
4243
_flowType?: EnumFlowType;
4344
}
@@ -52,61 +53,37 @@ interface ToolbarButton {
5253
isHidden?: boolean;
5354
}
5455

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;
56+
interface ScanRegion {
57+
ratio: {
58+
width: number;
59+
height: number;
60+
};
61+
regionBottomMargin: number;
62+
style: {
63+
strokeWidth: number;
64+
strokeColor: string;
65+
};
9566
}
96-
9767
interface DocumentScannerViewConfig {
9868
_showCorrectionView?: boolean;
9969
templateFilePath?: string;
10070
cameraEnhancerUIPath?: string;
10171
container?: HTMLElement | string;
10272
utilizedTemplateNames?: UtilizedTemplateNames;
73+
enableAutoCropMode?: boolean;
74+
enableSmartCaptureMode?: boolean;
75+
scanRegion: ScanRegion;
76+
minVerifiedFramesForAutoCapture: number;
77+
showSubfooter?: boolean;
78+
showPoweredByDynamsoft?: boolean;
10379
}
10480
declare class DocumentScannerView {
10581
private resources;
10682
private config;
10783
private boundsDetectionEnabled;
10884
private smartCaptureEnabled;
10985
private autoCropEnabled;
86+
private resizeTimer;
11087
private crossVerificationCount;
11188
private capturedResultItems;
11289
private originalImageData;
@@ -117,6 +94,7 @@ declare class DocumentScannerView {
11794
private loadingScreen;
11895
private showScannerLoadingOverlay;
11996
private hideScannerLoadingOverlay;
97+
private getMinVerifiedFramesForAutoCapture;
12098
constructor(resources: SharedResources, config: DocumentScannerViewConfig);
12199
initialize(): Promise<void>;
122100
private initializeElements;
@@ -131,6 +109,9 @@ declare class DocumentScannerView {
131109
toggleBoundsDetection(enabled?: boolean): Promise<void>;
132110
toggleSmartCapture(mode?: boolean): Promise<void>;
133111
toggleAutoCrop(mode?: boolean): Promise<void>;
112+
private handleResize;
113+
private toggleScanGuide;
114+
private calculateScanRegion;
134115
openCamera(): Promise<void>;
135116
closeCamera(hideContainer?: boolean): void;
136117
pauseCamera(): void;
@@ -148,6 +129,51 @@ declare class DocumentScannerView {
148129
normalizeImage(points: Quadrilateral["points"], originalImageData: OriginalImageResultItem["imageData"]): Promise<NormalizedImageResultItem>;
149130
}
150131

132+
interface DocumentCorrectionViewToolbarButtonsConfig {
133+
retake?: ToolbarButtonConfig;
134+
fullImage?: ToolbarButtonConfig;
135+
detectBorders?: ToolbarButtonConfig;
136+
apply?: ToolbarButtonConfig;
137+
}
138+
interface DocumentCorrectionViewConfig {
139+
container?: HTMLElement | string;
140+
toolbarButtonsConfig?: DocumentCorrectionViewToolbarButtonsConfig;
141+
templateFilePath?: string;
142+
utilizedTemplateNames?: UtilizedTemplateNames;
143+
onFinish?: (result: DocumentResult) => void;
144+
_showResultView?: boolean;
145+
}
146+
declare class DocumentCorrectionView {
147+
private resources;
148+
private config;
149+
private scannerView;
150+
private imageEditorView;
151+
private layer;
152+
private currentCorrectionResolver?;
153+
constructor(resources: SharedResources, config: DocumentCorrectionViewConfig, scannerView: DocumentScannerView);
154+
initialize(): Promise<void>;
155+
private setupDrawingLayerStyle;
156+
private setupQuadConstraints;
157+
private getCanvasBounds;
158+
private addQuadToLayer;
159+
private setupInitialDetectedQuad;
160+
private createControls;
161+
private setupCorrectionControls;
162+
private handleRetake;
163+
setFullImageBoundary(): void;
164+
setBoundaryAutomatically(): Promise<void>;
165+
confirmCorrection(): Promise<void>;
166+
launch(): Promise<DocumentResult>;
167+
hideView(): void;
168+
/**
169+
* Normalize an image with DDN given a set of points
170+
* @param points - points provided by either users or DDN's detect quad
171+
* @returns normalized image by DDN
172+
*/
173+
correctImage(points: Quadrilateral["points"]): Promise<NormalizedImageResultItem>;
174+
dispose(preserveResolver?: boolean): void;
175+
}
176+
151177
interface DocumentResultViewToolbarButtonsConfig {
152178
retake?: ToolbarButtonConfig;
153179
correct?: ToolbarButtonConfig;
@@ -207,6 +233,9 @@ declare class DocumentScanner {
207233
private resources;
208234
private isInitialized;
209235
private isCapturing;
236+
private loadingScreen;
237+
private showScannerLoadingOverlay;
238+
private hideScannerLoadingOverlay;
210239
constructor(config: DocumentScannerConfig);
211240
initialize(): Promise<{
212241
resources: SharedResources;
@@ -226,53 +255,25 @@ declare class DocumentScanner {
226255
private initializeDDSConfig;
227256
private createViewContainers;
228257
dispose(): void;
258+
/**
259+
* Process a File object to extract image information
260+
* @param file The File object to process
261+
* @returns Promise with the processed image blob and dimensions
262+
*/
263+
private processFileToBlob;
264+
/**
265+
* Processes an uploaded image file
266+
* @param file The file to process
267+
* @returns Promise with the document result
268+
*/
269+
private processUploadedFile;
229270
/**
230271
* Launches the document scanning process.
231272
*
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
273+
* @param file Optional File object to process instead of using the camera
274+
* @returns Promise<DocumentResult> containing scan results
274275
*/
275-
launch(): Promise<DocumentResult>;
276+
launch(file?: File): Promise<DocumentResult>;
276277
}
277278

278279
declare const DDS: {

dist/dds.bundle.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/dds.bundle.mjs

+2-2
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)