@twintag/twintag-core 0.2.279-fix-ocr-scanner-update-6ec656becd9d1b5b7652da56c9cf57d84db8e05f → 0.2.279-fix-ocr-scanner-update-ce883df10b1d4b81e7cf691ed723691d6f7bc81c
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/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/stencil-web-components.cjs.js +1 -1
- package/dist/cjs/twintag-ocr-scanner.cjs.entry.js +27 -16
- package/dist/cjs/twintag-offline-support.cjs.entry.js +1 -1
- package/dist/collection/components/twintag-scanner/twintag-ocr-scanner.js +48 -14
- package/dist/collection/version.js +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/twintag-ocr-scanner.js +28 -17
- package/dist/components/twintag-offline-support.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/stencil-web-components.js +1 -1
- package/dist/esm/twintag-ocr-scanner.entry.js +27 -16
- package/dist/esm/twintag-offline-support.entry.js +1 -1
- package/dist/stencil-web-components/{p-77acd2a5.entry.js → p-2afe759f.entry.js} +1 -1
- package/dist/stencil-web-components/{p-ae6a808d.entry.js → p-e5966a4e.entry.js} +1 -1
- package/dist/stencil-web-components/stencil-web-components.esm.js +1 -1
- package/dist/types/components/twintag-scanner/twintag-ocr-scanner.d.ts +7 -2
- package/dist/types/components.d.ts +1 -0
- package/dist/types/drone/src/libs/stencil-web-components/.stencil/libs/twintag-sdk/src/lib/version.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/twintag-sdk/src/lib/version.js +1 -1
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["twintag-preview.cjs",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback.cjs",[[1,"twintag-auth-callback"]]],["twintag-auth-logout.cjs",[[1,"twintag-auth-logout"]]],["twintag-media.cjs",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner.cjs",[[1,"twintag-ocr-scanner",{"stream":[1040],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"zoom":[514],"devices":[32]}]]],["twintag-offline-actions.cjs",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state.cjs",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support.cjs",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner.cjs",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[2],"zoom":[514],"devices":[32]}]]],["twintag-share.cjs",[[1,"twintag-share",{"url":[1],"modalTitle":[1,"modal-title"],"modalSubtitle":[1,"modal-subtitle"],"closeBtn":[1,"close-btn"],"copyClipboardBtn":[1,"copy-clipboard-btn"],"open":[1540]},[[0,"keydown","handleKeyDown"]]]]],["twintag-spinner.cjs",[[1,"twintag-spinner",{"color":[513],"duration":[2],"name":[1]}]]],["twintag-pdf-viewer.cjs",[[0,"twintag-pdf-viewer",{"src":[1],"fileName":[1,"file-name"],"file":[32],"fileURL":[32]}]]]], options);
|
|
17
|
+
return index.bootstrapLazy([["twintag-preview.cjs",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback.cjs",[[1,"twintag-auth-callback"]]],["twintag-auth-logout.cjs",[[1,"twintag-auth-logout"]]],["twintag-media.cjs",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner.cjs",[[1,"twintag-ocr-scanner",{"stream":[1040],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"zoom":[514],"devices":[32]},[[2,"recognize","ocrHandler"]]]]],["twintag-offline-actions.cjs",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state.cjs",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support.cjs",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner.cjs",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[2],"zoom":[514],"devices":[32]}]]],["twintag-share.cjs",[[1,"twintag-share",{"url":[1],"modalTitle":[1,"modal-title"],"modalSubtitle":[1,"modal-subtitle"],"closeBtn":[1,"close-btn"],"copyClipboardBtn":[1,"copy-clipboard-btn"],"open":[1540]},[[0,"keydown","handleKeyDown"]]]]],["twintag-spinner.cjs",[[1,"twintag-spinner",{"color":[513],"duration":[2],"name":[1]}]]],["twintag-pdf-viewer.cjs",[[0,"twintag-pdf-viewer",{"src":[1],"fileName":[1,"file-name"],"file":[32],"fileURL":[32]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -15,5 +15,5 @@ const patchBrowser = () => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["twintag-preview.cjs",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback.cjs",[[1,"twintag-auth-callback"]]],["twintag-auth-logout.cjs",[[1,"twintag-auth-logout"]]],["twintag-media.cjs",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner.cjs",[[1,"twintag-ocr-scanner",{"stream":[1040],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"zoom":[514],"devices":[32]}]]],["twintag-offline-actions.cjs",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state.cjs",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support.cjs",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner.cjs",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[2],"zoom":[514],"devices":[32]}]]],["twintag-share.cjs",[[1,"twintag-share",{"url":[1],"modalTitle":[1,"modal-title"],"modalSubtitle":[1,"modal-subtitle"],"closeBtn":[1,"close-btn"],"copyClipboardBtn":[1,"copy-clipboard-btn"],"open":[1540]},[[0,"keydown","handleKeyDown"]]]]],["twintag-spinner.cjs",[[1,"twintag-spinner",{"color":[513],"duration":[2],"name":[1]}]]],["twintag-pdf-viewer.cjs",[[0,"twintag-pdf-viewer",{"src":[1],"fileName":[1,"file-name"],"file":[32],"fileURL":[32]}]]]], options);
|
|
18
|
+
return index.bootstrapLazy([["twintag-preview.cjs",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback.cjs",[[1,"twintag-auth-callback"]]],["twintag-auth-logout.cjs",[[1,"twintag-auth-logout"]]],["twintag-media.cjs",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner.cjs",[[1,"twintag-ocr-scanner",{"stream":[1040],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"zoom":[514],"devices":[32]},[[2,"recognize","ocrHandler"]]]]],["twintag-offline-actions.cjs",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state.cjs",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support.cjs",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner.cjs",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[2],"zoom":[514],"devices":[32]}]]],["twintag-share.cjs",[[1,"twintag-share",{"url":[1],"modalTitle":[1,"modal-title"],"modalSubtitle":[1,"modal-subtitle"],"closeBtn":[1,"close-btn"],"copyClipboardBtn":[1,"copy-clipboard-btn"],"open":[1540]},[[0,"keydown","handleKeyDown"]]]]],["twintag-spinner.cjs",[[1,"twintag-spinner",{"color":[513],"duration":[2],"name":[1]}]]],["twintag-pdf-viewer.cjs",[[0,"twintag-pdf-viewer",{"src":[1],"fileName":[1,"file-name"],"file":[32],"fileURL":[32]}]]]], options);
|
|
19
19
|
});
|
|
@@ -1892,11 +1892,12 @@ var src = {
|
|
|
1892
1892
|
|
|
1893
1893
|
const twintagScannerCss = ":host{--twintag-scanner-bg-select-cameras:white;--twintag-scanner-text-select-cameras:black;--twintag-scanner-radius-select-cameras:6px 0 0 0;--twintag-scanner-min-height:min-content;--twintag-scanner-corners-color:white;--twintag-scanner-corners-width:4px;--twintag-scanner-corners-length:36px;--twintag-scanner-corners-offset:24px;display:grid;place-items:center;position:relative;width:100%}:host .icon-container{display:grid;place-items:center;position:absolute;inset:0;z-index:-2222}:host .icon-container .check-icon{opacity:0;z-index:2222}:host .video-container{--crop:0;--crop-x:var(--crop);--crop-y:var(--crop);display:flex;align-items:center;justify-content:center;position:relative;width:100%;height:100%;opacity:0;overflow:hidden;z-index:1}:host .video-container::after{content:\"\";position:absolute;width:100%;height:100%;opacity:inherit;background:rgba(0, 0, 0, 0.5);-webkit-clip-path:polygon(0% 0%, 0% 100%, calc(var(--crop-x) * 1%) 100%, calc(var(--crop-x) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) 100%, 100% 100%, 100% 0%);clip-path:polygon(0% 0%, 0% 100%, calc(var(--crop-x) * 1%) 100%, calc(var(--crop-x) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) 100%, 100% 100%, 100% 0%)}:host .video-container:before{display:block;content:\"\";width:100%;padding-top:100%}:host .video-container .video-corners{position:absolute;width:calc((1 - var(--crop-x) / 50) * 100% + var(--twintag-scanner-corners-offset));height:calc((1 - var(--crop-y) / 50) * 100% + var(--twintag-scanner-corners-offset));opacity:inherit;background:linear-gradient(to right, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 0, linear-gradient(to right, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 100%, linear-gradient(to left, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 0, linear-gradient(to left, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 100%, linear-gradient(to bottom, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 0, linear-gradient(to bottom, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 0, linear-gradient(to top, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 100%, linear-gradient(to top, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 100%;background-size:var(--twintag-scanner-corners-length) var(--twintag-scanner-corners-length);background-repeat:no-repeat;z-index:2222}:host .video-container video{position:absolute;width:100% !important;object-fit:cover;object-position:center;aspect-ratio:1/1 !important;min-height:var(--twintag-scanner-min-height)}";
|
|
1894
1894
|
|
|
1895
|
-
const
|
|
1895
|
+
const TwintagOcrScanner = class {
|
|
1896
1896
|
constructor(hostRef) {
|
|
1897
1897
|
index.registerInstance(this, hostRef);
|
|
1898
1898
|
this.symbol = index.createEvent(this, "symbol", 7);
|
|
1899
1899
|
this.streamIsActive = index.createEvent(this, "streamIsActive", 7);
|
|
1900
|
+
this.canRecognize = index.createEvent(this, "canRecognize", 7);
|
|
1900
1901
|
this.frame = index.createEvent(this, "frame", 7);
|
|
1901
1902
|
this.devices = [];
|
|
1902
1903
|
this.stream = null;
|
|
@@ -1904,6 +1905,15 @@ const TwintagOCRScanner = class {
|
|
|
1904
1905
|
this.cropY = 1;
|
|
1905
1906
|
this.zoom = 0;
|
|
1906
1907
|
}
|
|
1908
|
+
async ocrHandler() {
|
|
1909
|
+
const { text, frame } = await this.readBarcodeFromCanvas();
|
|
1910
|
+
this.symbol.emit({
|
|
1911
|
+
text,
|
|
1912
|
+
format: 'OCR',
|
|
1913
|
+
});
|
|
1914
|
+
this.frame.emit(frame);
|
|
1915
|
+
this.stopStream();
|
|
1916
|
+
}
|
|
1907
1917
|
async connectedCallback() {
|
|
1908
1918
|
this.worker = await src.createWorker('eng');
|
|
1909
1919
|
}
|
|
@@ -1921,24 +1931,22 @@ const TwintagOCRScanner = class {
|
|
|
1921
1931
|
this.drawInCanvas();
|
|
1922
1932
|
const frame = this.canvas.toDataURL('image/png');
|
|
1923
1933
|
const { data: { text } } = await this.worker.recognize(frame);
|
|
1924
|
-
|
|
1934
|
+
return {
|
|
1925
1935
|
text,
|
|
1926
|
-
|
|
1927
|
-
}
|
|
1928
|
-
this.frame.emit(frame);
|
|
1929
|
-
this.stopStream();
|
|
1936
|
+
frame,
|
|
1937
|
+
};
|
|
1930
1938
|
}
|
|
1931
1939
|
drawInCanvas() {
|
|
1932
1940
|
const stage = Math.min(this.video.videoWidth, this.video.videoHeight);
|
|
1933
|
-
const
|
|
1934
|
-
const
|
|
1941
|
+
const width = stage * this.cropX;
|
|
1942
|
+
const height = stage * this.cropY;
|
|
1935
1943
|
const center = {
|
|
1936
1944
|
x: this.video.videoWidth / 2,
|
|
1937
1945
|
y: this.video.videoHeight / 2,
|
|
1938
1946
|
};
|
|
1939
|
-
const sx = center.x -
|
|
1940
|
-
const sy = center.y -
|
|
1941
|
-
this.context.drawImage(this.video, sx, sy,
|
|
1947
|
+
const sx = center.x - width / 2;
|
|
1948
|
+
const sy = center.y - height / 2;
|
|
1949
|
+
this.context.drawImage(this.video, sx, sy, width, height, 0, 0, width, height);
|
|
1942
1950
|
}
|
|
1943
1951
|
async updateStream(constraints) {
|
|
1944
1952
|
if (this.stream) {
|
|
@@ -2045,9 +2053,11 @@ const TwintagOCRScanner = class {
|
|
|
2045
2053
|
onComplete: () => {
|
|
2046
2054
|
this.streamIsActive.emit(true);
|
|
2047
2055
|
const stage = Math.min(this.video.videoWidth, this.video.videoHeight);
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
this.
|
|
2056
|
+
const width = stage * this.cropX;
|
|
2057
|
+
const height = stage * this.cropY;
|
|
2058
|
+
this.canvas.width = width;
|
|
2059
|
+
this.canvas.height = height;
|
|
2060
|
+
this.canRecognize.emit(true);
|
|
2051
2061
|
}
|
|
2052
2062
|
});
|
|
2053
2063
|
}
|
|
@@ -2063,6 +2073,7 @@ const TwintagOCRScanner = class {
|
|
|
2063
2073
|
this.video.srcObject = null;
|
|
2064
2074
|
this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height);
|
|
2065
2075
|
await this.worker.terminate();
|
|
2076
|
+
this.canRecognize.emit(false);
|
|
2066
2077
|
},
|
|
2067
2078
|
});
|
|
2068
2079
|
}
|
|
@@ -2073,6 +2084,6 @@ const TwintagOCRScanner = class {
|
|
|
2073
2084
|
return (index.h(index.Host, null, index.h("div", { class: "video-container", ref: (el) => (this.videoContainer = el) }, index.h("div", { class: "video-corners" }), index.h("video", { crossOrigin: "Anonymous", autoplay: true, playsinline: true, ref: (el) => (this.video = el) }))));
|
|
2074
2085
|
}
|
|
2075
2086
|
};
|
|
2076
|
-
|
|
2087
|
+
TwintagOcrScanner.style = twintagScannerCss;
|
|
2077
2088
|
|
|
2078
|
-
exports.twintag_ocr_scanner =
|
|
2089
|
+
exports.twintag_ocr_scanner = TwintagOcrScanner;
|
|
@@ -206,7 +206,7 @@ class IndexedDbService {
|
|
|
206
206
|
/**
|
|
207
207
|
* The SDK version.
|
|
208
208
|
*/
|
|
209
|
-
const VERSION = '0.2.279-fix-ocr-scanner-update-
|
|
209
|
+
const VERSION = '0.2.279-fix-ocr-scanner-update-ce883df10b1d4b81e7cf691ed723691d6f7bc81c';
|
|
210
210
|
|
|
211
211
|
class TwintagErrorValue {
|
|
212
212
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h, Host, } from '@stencil/core';
|
|
2
2
|
import gsap from 'gsap';
|
|
3
3
|
import { createWorker } from 'tesseract.js';
|
|
4
|
-
export class
|
|
4
|
+
export class TwintagOcrScanner {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.devices = [];
|
|
7
7
|
this.stream = null;
|
|
@@ -9,6 +9,15 @@ export class TwintagOCRScanner {
|
|
|
9
9
|
this.cropY = 1;
|
|
10
10
|
this.zoom = 0;
|
|
11
11
|
}
|
|
12
|
+
async ocrHandler() {
|
|
13
|
+
const { text, frame } = await this.readBarcodeFromCanvas();
|
|
14
|
+
this.symbol.emit({
|
|
15
|
+
text,
|
|
16
|
+
format: 'OCR',
|
|
17
|
+
});
|
|
18
|
+
this.frame.emit(frame);
|
|
19
|
+
this.stopStream();
|
|
20
|
+
}
|
|
12
21
|
async connectedCallback() {
|
|
13
22
|
this.worker = await createWorker('eng');
|
|
14
23
|
}
|
|
@@ -26,24 +35,22 @@ export class TwintagOCRScanner {
|
|
|
26
35
|
this.drawInCanvas();
|
|
27
36
|
const frame = this.canvas.toDataURL('image/png');
|
|
28
37
|
const { data: { text } } = await this.worker.recognize(frame);
|
|
29
|
-
|
|
38
|
+
return {
|
|
30
39
|
text,
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
this.frame.emit(frame);
|
|
34
|
-
this.stopStream();
|
|
40
|
+
frame,
|
|
41
|
+
};
|
|
35
42
|
}
|
|
36
43
|
drawInCanvas() {
|
|
37
44
|
const stage = Math.min(this.video.videoWidth, this.video.videoHeight);
|
|
38
|
-
const
|
|
39
|
-
const
|
|
45
|
+
const width = stage * this.cropX;
|
|
46
|
+
const height = stage * this.cropY;
|
|
40
47
|
const center = {
|
|
41
48
|
x: this.video.videoWidth / 2,
|
|
42
49
|
y: this.video.videoHeight / 2,
|
|
43
50
|
};
|
|
44
|
-
const sx = center.x -
|
|
45
|
-
const sy = center.y -
|
|
46
|
-
this.context.drawImage(this.video, sx, sy,
|
|
51
|
+
const sx = center.x - width / 2;
|
|
52
|
+
const sy = center.y - height / 2;
|
|
53
|
+
this.context.drawImage(this.video, sx, sy, width, height, 0, 0, width, height);
|
|
47
54
|
}
|
|
48
55
|
async updateStream(constraints) {
|
|
49
56
|
if (this.stream) {
|
|
@@ -150,9 +157,11 @@ export class TwintagOCRScanner {
|
|
|
150
157
|
onComplete: () => {
|
|
151
158
|
this.streamIsActive.emit(true);
|
|
152
159
|
const stage = Math.min(this.video.videoWidth, this.video.videoHeight);
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
this.
|
|
160
|
+
const width = stage * this.cropX;
|
|
161
|
+
const height = stage * this.cropY;
|
|
162
|
+
this.canvas.width = width;
|
|
163
|
+
this.canvas.height = height;
|
|
164
|
+
this.canRecognize.emit(true);
|
|
156
165
|
}
|
|
157
166
|
});
|
|
158
167
|
}
|
|
@@ -168,6 +177,7 @@ export class TwintagOCRScanner {
|
|
|
168
177
|
this.video.srcObject = null;
|
|
169
178
|
this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height);
|
|
170
179
|
await this.worker.terminate();
|
|
180
|
+
this.canRecognize.emit(false);
|
|
171
181
|
},
|
|
172
182
|
});
|
|
173
183
|
}
|
|
@@ -303,6 +313,21 @@ export class TwintagOCRScanner {
|
|
|
303
313
|
"resolved": "boolean",
|
|
304
314
|
"references": {}
|
|
305
315
|
}
|
|
316
|
+
}, {
|
|
317
|
+
"method": "canRecognize",
|
|
318
|
+
"name": "canRecognize",
|
|
319
|
+
"bubbles": true,
|
|
320
|
+
"cancelable": true,
|
|
321
|
+
"composed": true,
|
|
322
|
+
"docs": {
|
|
323
|
+
"tags": [],
|
|
324
|
+
"text": ""
|
|
325
|
+
},
|
|
326
|
+
"complexType": {
|
|
327
|
+
"original": "boolean",
|
|
328
|
+
"resolved": "boolean",
|
|
329
|
+
"references": {}
|
|
330
|
+
}
|
|
306
331
|
}, {
|
|
307
332
|
"method": "frame",
|
|
308
333
|
"name": "frame",
|
|
@@ -320,4 +345,13 @@ export class TwintagOCRScanner {
|
|
|
320
345
|
}
|
|
321
346
|
}];
|
|
322
347
|
}
|
|
348
|
+
static get listeners() {
|
|
349
|
+
return [{
|
|
350
|
+
"name": "recognize",
|
|
351
|
+
"method": "ocrHandler",
|
|
352
|
+
"target": undefined,
|
|
353
|
+
"capture": true,
|
|
354
|
+
"passive": false
|
|
355
|
+
}];
|
|
356
|
+
}
|
|
323
357
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export { TwintagAuthCallback as TwintagAuthCallback } from '../types/components/twintag-auth-callback/twintag-auth-callback';
|
|
3
3
|
export { TwintagAuthLogout as TwintagAuthLogout } from '../types/components/twintag-auth-logout/twintag-auth-logout';
|
|
4
4
|
export { TwintagMedia as TwintagMedia } from '../types/components/twintag-media/twintag-media';
|
|
5
|
-
export {
|
|
5
|
+
export { TwintagOcrScanner as TwintagOcrScanner } from '../types/components/twintag-scanner/twintag-ocr-scanner';
|
|
6
6
|
export { TwintagOfflineActions as TwintagOfflineActions } from '../types/components/twintag-offline-support/twintag-offline-actions/twintag-offline-actions';
|
|
7
7
|
export { TwintagOfflineState as TwintagOfflineState } from '../types/components/twintag-offline-support/twintag-connection-state/twintag-offline-state';
|
|
8
8
|
export { TwintagOfflineSupport as TwintagOfflineSupport } from '../types/components/twintag-offline-support/twintag-offline-support';
|
|
@@ -1888,13 +1888,14 @@ var src = {
|
|
|
1888
1888
|
|
|
1889
1889
|
const twintagScannerCss = ":host{--twintag-scanner-bg-select-cameras:white;--twintag-scanner-text-select-cameras:black;--twintag-scanner-radius-select-cameras:6px 0 0 0;--twintag-scanner-min-height:min-content;--twintag-scanner-corners-color:white;--twintag-scanner-corners-width:4px;--twintag-scanner-corners-length:36px;--twintag-scanner-corners-offset:24px;display:grid;place-items:center;position:relative;width:100%}:host .icon-container{display:grid;place-items:center;position:absolute;inset:0;z-index:-2222}:host .icon-container .check-icon{opacity:0;z-index:2222}:host .video-container{--crop:0;--crop-x:var(--crop);--crop-y:var(--crop);display:flex;align-items:center;justify-content:center;position:relative;width:100%;height:100%;opacity:0;overflow:hidden;z-index:1}:host .video-container::after{content:\"\";position:absolute;width:100%;height:100%;opacity:inherit;background:rgba(0, 0, 0, 0.5);-webkit-clip-path:polygon(0% 0%, 0% 100%, calc(var(--crop-x) * 1%) 100%, calc(var(--crop-x) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) 100%, 100% 100%, 100% 0%);clip-path:polygon(0% 0%, 0% 100%, calc(var(--crop-x) * 1%) 100%, calc(var(--crop-x) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) 100%, 100% 100%, 100% 0%)}:host .video-container:before{display:block;content:\"\";width:100%;padding-top:100%}:host .video-container .video-corners{position:absolute;width:calc((1 - var(--crop-x) / 50) * 100% + var(--twintag-scanner-corners-offset));height:calc((1 - var(--crop-y) / 50) * 100% + var(--twintag-scanner-corners-offset));opacity:inherit;background:linear-gradient(to right, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 0, linear-gradient(to right, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 100%, linear-gradient(to left, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 0, linear-gradient(to left, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 100%, linear-gradient(to bottom, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 0, linear-gradient(to bottom, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 0, linear-gradient(to top, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 100%, linear-gradient(to top, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 100%;background-size:var(--twintag-scanner-corners-length) var(--twintag-scanner-corners-length);background-repeat:no-repeat;z-index:2222}:host .video-container video{position:absolute;width:100% !important;object-fit:cover;object-position:center;aspect-ratio:1/1 !important;min-height:var(--twintag-scanner-min-height)}";
|
|
1890
1890
|
|
|
1891
|
-
const
|
|
1891
|
+
const TwintagOcrScanner$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement$1 {
|
|
1892
1892
|
constructor() {
|
|
1893
1893
|
super();
|
|
1894
1894
|
this.__registerHost();
|
|
1895
1895
|
this.__attachShadow();
|
|
1896
1896
|
this.symbol = createEvent(this, "symbol", 7);
|
|
1897
1897
|
this.streamIsActive = createEvent(this, "streamIsActive", 7);
|
|
1898
|
+
this.canRecognize = createEvent(this, "canRecognize", 7);
|
|
1898
1899
|
this.frame = createEvent(this, "frame", 7);
|
|
1899
1900
|
this.devices = [];
|
|
1900
1901
|
this.stream = null;
|
|
@@ -1902,6 +1903,15 @@ const TwintagOCRScanner = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
1902
1903
|
this.cropY = 1;
|
|
1903
1904
|
this.zoom = 0;
|
|
1904
1905
|
}
|
|
1906
|
+
async ocrHandler() {
|
|
1907
|
+
const { text, frame } = await this.readBarcodeFromCanvas();
|
|
1908
|
+
this.symbol.emit({
|
|
1909
|
+
text,
|
|
1910
|
+
format: 'OCR',
|
|
1911
|
+
});
|
|
1912
|
+
this.frame.emit(frame);
|
|
1913
|
+
this.stopStream();
|
|
1914
|
+
}
|
|
1905
1915
|
async connectedCallback() {
|
|
1906
1916
|
this.worker = await src.createWorker('eng');
|
|
1907
1917
|
}
|
|
@@ -1919,24 +1929,22 @@ const TwintagOCRScanner = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
1919
1929
|
this.drawInCanvas();
|
|
1920
1930
|
const frame = this.canvas.toDataURL('image/png');
|
|
1921
1931
|
const { data: { text } } = await this.worker.recognize(frame);
|
|
1922
|
-
|
|
1932
|
+
return {
|
|
1923
1933
|
text,
|
|
1924
|
-
|
|
1925
|
-
}
|
|
1926
|
-
this.frame.emit(frame);
|
|
1927
|
-
this.stopStream();
|
|
1934
|
+
frame,
|
|
1935
|
+
};
|
|
1928
1936
|
}
|
|
1929
1937
|
drawInCanvas() {
|
|
1930
1938
|
const stage = Math.min(this.video.videoWidth, this.video.videoHeight);
|
|
1931
|
-
const
|
|
1932
|
-
const
|
|
1939
|
+
const width = stage * this.cropX;
|
|
1940
|
+
const height = stage * this.cropY;
|
|
1933
1941
|
const center = {
|
|
1934
1942
|
x: this.video.videoWidth / 2,
|
|
1935
1943
|
y: this.video.videoHeight / 2,
|
|
1936
1944
|
};
|
|
1937
|
-
const sx = center.x -
|
|
1938
|
-
const sy = center.y -
|
|
1939
|
-
this.context.drawImage(this.video, sx, sy,
|
|
1945
|
+
const sx = center.x - width / 2;
|
|
1946
|
+
const sy = center.y - height / 2;
|
|
1947
|
+
this.context.drawImage(this.video, sx, sy, width, height, 0, 0, width, height);
|
|
1940
1948
|
}
|
|
1941
1949
|
async updateStream(constraints) {
|
|
1942
1950
|
if (this.stream) {
|
|
@@ -2043,9 +2051,11 @@ const TwintagOCRScanner = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
2043
2051
|
onComplete: () => {
|
|
2044
2052
|
this.streamIsActive.emit(true);
|
|
2045
2053
|
const stage = Math.min(this.video.videoWidth, this.video.videoHeight);
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
this.
|
|
2054
|
+
const width = stage * this.cropX;
|
|
2055
|
+
const height = stage * this.cropY;
|
|
2056
|
+
this.canvas.width = width;
|
|
2057
|
+
this.canvas.height = height;
|
|
2058
|
+
this.canRecognize.emit(true);
|
|
2049
2059
|
}
|
|
2050
2060
|
});
|
|
2051
2061
|
}
|
|
@@ -2061,6 +2071,7 @@ const TwintagOCRScanner = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
2061
2071
|
this.video.srcObject = null;
|
|
2062
2072
|
this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height);
|
|
2063
2073
|
await this.worker.terminate();
|
|
2074
|
+
this.canRecognize.emit(false);
|
|
2064
2075
|
},
|
|
2065
2076
|
});
|
|
2066
2077
|
}
|
|
@@ -2077,7 +2088,7 @@ const TwintagOCRScanner = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
2077
2088
|
"cropY": [2, "crop-y"],
|
|
2078
2089
|
"zoom": [514],
|
|
2079
2090
|
"devices": [32]
|
|
2080
|
-
}]);
|
|
2091
|
+
}, [[2, "recognize", "ocrHandler"]]]);
|
|
2081
2092
|
function defineCustomElement$1() {
|
|
2082
2093
|
if (typeof customElements === "undefined") {
|
|
2083
2094
|
return;
|
|
@@ -2086,13 +2097,13 @@ function defineCustomElement$1() {
|
|
|
2086
2097
|
components.forEach(tagName => { switch (tagName) {
|
|
2087
2098
|
case "twintag-ocr-scanner":
|
|
2088
2099
|
if (!customElements.get(tagName)) {
|
|
2089
|
-
customElements.define(tagName,
|
|
2100
|
+
customElements.define(tagName, TwintagOcrScanner$1);
|
|
2090
2101
|
}
|
|
2091
2102
|
break;
|
|
2092
2103
|
} });
|
|
2093
2104
|
}
|
|
2094
2105
|
|
|
2095
|
-
const TwintagOcrScanner =
|
|
2106
|
+
const TwintagOcrScanner = TwintagOcrScanner$1;
|
|
2096
2107
|
const defineCustomElement = defineCustomElement$1;
|
|
2097
2108
|
|
|
2098
2109
|
export { TwintagOcrScanner, defineCustomElement };
|
|
@@ -223,7 +223,7 @@ class IndexedDbService {
|
|
|
223
223
|
/**
|
|
224
224
|
* The SDK version.
|
|
225
225
|
*/
|
|
226
|
-
const VERSION = '0.2.279-fix-ocr-scanner-update-
|
|
226
|
+
const VERSION = '0.2.279-fix-ocr-scanner-update-ce883df10b1d4b81e7cf691ed723691d6f7bc81c';
|
|
227
227
|
|
|
228
228
|
class TwintagErrorValue {
|
|
229
229
|
}
|
package/dist/esm/loader.js
CHANGED
|
@@ -10,7 +10,7 @@ const patchEsm = () => {
|
|
|
10
10
|
const defineCustomElements = (win, options) => {
|
|
11
11
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
12
12
|
return patchEsm().then(() => {
|
|
13
|
-
return bootstrapLazy([["twintag-preview",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback",[[1,"twintag-auth-callback"]]],["twintag-auth-logout",[[1,"twintag-auth-logout"]]],["twintag-media",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner",[[1,"twintag-ocr-scanner",{"stream":[1040],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"zoom":[514],"devices":[32]}]]],["twintag-offline-actions",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[2],"zoom":[514],"devices":[32]}]]],["twintag-share",[[1,"twintag-share",{"url":[1],"modalTitle":[1,"modal-title"],"modalSubtitle":[1,"modal-subtitle"],"closeBtn":[1,"close-btn"],"copyClipboardBtn":[1,"copy-clipboard-btn"],"open":[1540]},[[0,"keydown","handleKeyDown"]]]]],["twintag-spinner",[[1,"twintag-spinner",{"color":[513],"duration":[2],"name":[1]}]]],["twintag-pdf-viewer",[[0,"twintag-pdf-viewer",{"src":[1],"fileName":[1,"file-name"],"file":[32],"fileURL":[32]}]]]], options);
|
|
13
|
+
return bootstrapLazy([["twintag-preview",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback",[[1,"twintag-auth-callback"]]],["twintag-auth-logout",[[1,"twintag-auth-logout"]]],["twintag-media",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner",[[1,"twintag-ocr-scanner",{"stream":[1040],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"zoom":[514],"devices":[32]},[[2,"recognize","ocrHandler"]]]]],["twintag-offline-actions",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[2],"zoom":[514],"devices":[32]}]]],["twintag-share",[[1,"twintag-share",{"url":[1],"modalTitle":[1,"modal-title"],"modalSubtitle":[1,"modal-subtitle"],"closeBtn":[1,"close-btn"],"copyClipboardBtn":[1,"copy-clipboard-btn"],"open":[1540]},[[0,"keydown","handleKeyDown"]]]]],["twintag-spinner",[[1,"twintag-spinner",{"color":[513],"duration":[2],"name":[1]}]]],["twintag-pdf-viewer",[[0,"twintag-pdf-viewer",{"src":[1],"fileName":[1,"file-name"],"file":[32],"fileURL":[32]}]]]], options);
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -13,5 +13,5 @@ const patchBrowser = () => {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
patchBrowser().then(options => {
|
|
16
|
-
return bootstrapLazy([["twintag-preview",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback",[[1,"twintag-auth-callback"]]],["twintag-auth-logout",[[1,"twintag-auth-logout"]]],["twintag-media",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner",[[1,"twintag-ocr-scanner",{"stream":[1040],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"zoom":[514],"devices":[32]}]]],["twintag-offline-actions",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[2],"zoom":[514],"devices":[32]}]]],["twintag-share",[[1,"twintag-share",{"url":[1],"modalTitle":[1,"modal-title"],"modalSubtitle":[1,"modal-subtitle"],"closeBtn":[1,"close-btn"],"copyClipboardBtn":[1,"copy-clipboard-btn"],"open":[1540]},[[0,"keydown","handleKeyDown"]]]]],["twintag-spinner",[[1,"twintag-spinner",{"color":[513],"duration":[2],"name":[1]}]]],["twintag-pdf-viewer",[[0,"twintag-pdf-viewer",{"src":[1],"fileName":[1,"file-name"],"file":[32],"fileURL":[32]}]]]], options);
|
|
16
|
+
return bootstrapLazy([["twintag-preview",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback",[[1,"twintag-auth-callback"]]],["twintag-auth-logout",[[1,"twintag-auth-logout"]]],["twintag-media",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner",[[1,"twintag-ocr-scanner",{"stream":[1040],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"zoom":[514],"devices":[32]},[[2,"recognize","ocrHandler"]]]]],["twintag-offline-actions",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[2],"zoom":[514],"devices":[32]}]]],["twintag-share",[[1,"twintag-share",{"url":[1],"modalTitle":[1,"modal-title"],"modalSubtitle":[1,"modal-subtitle"],"closeBtn":[1,"close-btn"],"copyClipboardBtn":[1,"copy-clipboard-btn"],"open":[1540]},[[0,"keydown","handleKeyDown"]]]]],["twintag-spinner",[[1,"twintag-spinner",{"color":[513],"duration":[2],"name":[1]}]]],["twintag-pdf-viewer",[[0,"twintag-pdf-viewer",{"src":[1],"fileName":[1,"file-name"],"file":[32],"fileURL":[32]}]]]], options);
|
|
17
17
|
});
|
|
@@ -1888,11 +1888,12 @@ var src = {
|
|
|
1888
1888
|
|
|
1889
1889
|
const twintagScannerCss = ":host{--twintag-scanner-bg-select-cameras:white;--twintag-scanner-text-select-cameras:black;--twintag-scanner-radius-select-cameras:6px 0 0 0;--twintag-scanner-min-height:min-content;--twintag-scanner-corners-color:white;--twintag-scanner-corners-width:4px;--twintag-scanner-corners-length:36px;--twintag-scanner-corners-offset:24px;display:grid;place-items:center;position:relative;width:100%}:host .icon-container{display:grid;place-items:center;position:absolute;inset:0;z-index:-2222}:host .icon-container .check-icon{opacity:0;z-index:2222}:host .video-container{--crop:0;--crop-x:var(--crop);--crop-y:var(--crop);display:flex;align-items:center;justify-content:center;position:relative;width:100%;height:100%;opacity:0;overflow:hidden;z-index:1}:host .video-container::after{content:\"\";position:absolute;width:100%;height:100%;opacity:inherit;background:rgba(0, 0, 0, 0.5);-webkit-clip-path:polygon(0% 0%, 0% 100%, calc(var(--crop-x) * 1%) 100%, calc(var(--crop-x) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) 100%, 100% 100%, 100% 0%);clip-path:polygon(0% 0%, 0% 100%, calc(var(--crop-x) * 1%) 100%, calc(var(--crop-x) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) 100%, 100% 100%, 100% 0%)}:host .video-container:before{display:block;content:\"\";width:100%;padding-top:100%}:host .video-container .video-corners{position:absolute;width:calc((1 - var(--crop-x) / 50) * 100% + var(--twintag-scanner-corners-offset));height:calc((1 - var(--crop-y) / 50) * 100% + var(--twintag-scanner-corners-offset));opacity:inherit;background:linear-gradient(to right, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 0, linear-gradient(to right, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 100%, linear-gradient(to left, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 0, linear-gradient(to left, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 100%, linear-gradient(to bottom, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 0, linear-gradient(to bottom, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 0, linear-gradient(to top, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 100%, linear-gradient(to top, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 100%;background-size:var(--twintag-scanner-corners-length) var(--twintag-scanner-corners-length);background-repeat:no-repeat;z-index:2222}:host .video-container video{position:absolute;width:100% !important;object-fit:cover;object-position:center;aspect-ratio:1/1 !important;min-height:var(--twintag-scanner-min-height)}";
|
|
1890
1890
|
|
|
1891
|
-
const
|
|
1891
|
+
const TwintagOcrScanner = class {
|
|
1892
1892
|
constructor(hostRef) {
|
|
1893
1893
|
registerInstance(this, hostRef);
|
|
1894
1894
|
this.symbol = createEvent(this, "symbol", 7);
|
|
1895
1895
|
this.streamIsActive = createEvent(this, "streamIsActive", 7);
|
|
1896
|
+
this.canRecognize = createEvent(this, "canRecognize", 7);
|
|
1896
1897
|
this.frame = createEvent(this, "frame", 7);
|
|
1897
1898
|
this.devices = [];
|
|
1898
1899
|
this.stream = null;
|
|
@@ -1900,6 +1901,15 @@ const TwintagOCRScanner = class {
|
|
|
1900
1901
|
this.cropY = 1;
|
|
1901
1902
|
this.zoom = 0;
|
|
1902
1903
|
}
|
|
1904
|
+
async ocrHandler() {
|
|
1905
|
+
const { text, frame } = await this.readBarcodeFromCanvas();
|
|
1906
|
+
this.symbol.emit({
|
|
1907
|
+
text,
|
|
1908
|
+
format: 'OCR',
|
|
1909
|
+
});
|
|
1910
|
+
this.frame.emit(frame);
|
|
1911
|
+
this.stopStream();
|
|
1912
|
+
}
|
|
1903
1913
|
async connectedCallback() {
|
|
1904
1914
|
this.worker = await src.createWorker('eng');
|
|
1905
1915
|
}
|
|
@@ -1917,24 +1927,22 @@ const TwintagOCRScanner = class {
|
|
|
1917
1927
|
this.drawInCanvas();
|
|
1918
1928
|
const frame = this.canvas.toDataURL('image/png');
|
|
1919
1929
|
const { data: { text } } = await this.worker.recognize(frame);
|
|
1920
|
-
|
|
1930
|
+
return {
|
|
1921
1931
|
text,
|
|
1922
|
-
|
|
1923
|
-
}
|
|
1924
|
-
this.frame.emit(frame);
|
|
1925
|
-
this.stopStream();
|
|
1932
|
+
frame,
|
|
1933
|
+
};
|
|
1926
1934
|
}
|
|
1927
1935
|
drawInCanvas() {
|
|
1928
1936
|
const stage = Math.min(this.video.videoWidth, this.video.videoHeight);
|
|
1929
|
-
const
|
|
1930
|
-
const
|
|
1937
|
+
const width = stage * this.cropX;
|
|
1938
|
+
const height = stage * this.cropY;
|
|
1931
1939
|
const center = {
|
|
1932
1940
|
x: this.video.videoWidth / 2,
|
|
1933
1941
|
y: this.video.videoHeight / 2,
|
|
1934
1942
|
};
|
|
1935
|
-
const sx = center.x -
|
|
1936
|
-
const sy = center.y -
|
|
1937
|
-
this.context.drawImage(this.video, sx, sy,
|
|
1943
|
+
const sx = center.x - width / 2;
|
|
1944
|
+
const sy = center.y - height / 2;
|
|
1945
|
+
this.context.drawImage(this.video, sx, sy, width, height, 0, 0, width, height);
|
|
1938
1946
|
}
|
|
1939
1947
|
async updateStream(constraints) {
|
|
1940
1948
|
if (this.stream) {
|
|
@@ -2041,9 +2049,11 @@ const TwintagOCRScanner = class {
|
|
|
2041
2049
|
onComplete: () => {
|
|
2042
2050
|
this.streamIsActive.emit(true);
|
|
2043
2051
|
const stage = Math.min(this.video.videoWidth, this.video.videoHeight);
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
this.
|
|
2052
|
+
const width = stage * this.cropX;
|
|
2053
|
+
const height = stage * this.cropY;
|
|
2054
|
+
this.canvas.width = width;
|
|
2055
|
+
this.canvas.height = height;
|
|
2056
|
+
this.canRecognize.emit(true);
|
|
2047
2057
|
}
|
|
2048
2058
|
});
|
|
2049
2059
|
}
|
|
@@ -2059,6 +2069,7 @@ const TwintagOCRScanner = class {
|
|
|
2059
2069
|
this.video.srcObject = null;
|
|
2060
2070
|
this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height);
|
|
2061
2071
|
await this.worker.terminate();
|
|
2072
|
+
this.canRecognize.emit(false);
|
|
2062
2073
|
},
|
|
2063
2074
|
});
|
|
2064
2075
|
}
|
|
@@ -2069,6 +2080,6 @@ const TwintagOCRScanner = class {
|
|
|
2069
2080
|
return (h(Host, null, h("div", { class: "video-container", ref: (el) => (this.videoContainer = el) }, h("div", { class: "video-corners" }), h("video", { crossOrigin: "Anonymous", autoplay: true, playsinline: true, ref: (el) => (this.video = el) }))));
|
|
2070
2081
|
}
|
|
2071
2082
|
};
|
|
2072
|
-
|
|
2083
|
+
TwintagOcrScanner.style = twintagScannerCss;
|
|
2073
2084
|
|
|
2074
|
-
export {
|
|
2085
|
+
export { TwintagOcrScanner as twintag_ocr_scanner };
|
|
@@ -202,7 +202,7 @@ class IndexedDbService {
|
|
|
202
202
|
/**
|
|
203
203
|
* The SDK version.
|
|
204
204
|
*/
|
|
205
|
-
const VERSION = '0.2.279-fix-ocr-scanner-update-
|
|
205
|
+
const VERSION = '0.2.279-fix-ocr-scanner-update-ce883df10b1d4b81e7cf691ed723691d6f7bc81c';
|
|
206
206
|
|
|
207
207
|
class TwintagErrorValue {
|
|
208
208
|
}
|