@operato/ocr 0.2.19 → 0.2.23

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/src/type.ts ADDED
@@ -0,0 +1,13 @@
1
+ export type ScanResult = {
2
+ key_values: {
3
+ [key: string]: Array<string>
4
+ }
5
+ boundaries: Array<Array<{ x: number; y: number }>>
6
+ texts: Array<string>
7
+ }
8
+
9
+ export const NOTHING_RESULT = {
10
+ boundaries: [],
11
+ key_values: {},
12
+ texts: []
13
+ }
@@ -1,14 +0,0 @@
1
- import '@material/mwc-icon';
2
- import { LitElement } from 'lit';
3
- export declare class CameraCapturer extends LitElement {
4
- static styles: import("lit").CSSResult[];
5
- multiple?: boolean;
6
- accept?: string;
7
- label?: string;
8
- _files?: File[];
9
- render(): import("lit-html").TemplateResult<1>;
10
- firstUpdated(): void;
11
- fileInput: HTMLInputElement;
12
- get files(): File[] | undefined;
13
- reset(): void;
14
- }
@@ -1,170 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import '@material/mwc-icon';
3
- import { css, html, LitElement } from 'lit';
4
- import { customElement, property, query } from 'lit/decorators.js';
5
- import { FileDropHelper } from './file-drop-helper';
6
- let CameraCapturer = class CameraCapturer extends LitElement {
7
- render() {
8
- var files = this._files || [];
9
- return html `
10
- <mwc-icon>camera</mwc-icon>
11
- <span>Capture image<br />or drop files here!</span>
12
- <input
13
- id="input-file"
14
- type="file"
15
- accept=${this.accept}
16
- ?multiple=${this.multiple}
17
- hidden
18
- capture="environment"
19
- @change=${(e) => {
20
- const fileInput = e.currentTarget;
21
- this._files = [...files, ...Array.from(fileInput.files)];
22
- this.dispatchEvent(new CustomEvent('files-change', {
23
- bubbles: true,
24
- composed: true,
25
- detail: {
26
- files: files
27
- }
28
- }));
29
- // fileInput.value = null
30
- fileInput.files = null;
31
- }}
32
- />
33
- <label for="input-file">${this.label || 'capture image'}</label>
34
-
35
- ${(files === null || files === void 0 ? void 0 : files.length)
36
- ? html ` <ul>
37
- ${files.map(file => html `
38
- <li>
39
- - ${file.name}
40
- <mwc-icon
41
- @click=${(e) => {
42
- this._files = [...files.splice(files.indexOf(file), 1)];
43
- this.dispatchEvent(new CustomEvent('files-change', {
44
- bubbles: true,
45
- composed: true,
46
- detail: {
47
- files: this._files
48
- }
49
- }));
50
- }}
51
- >delete_outline</mwc-icon
52
- >
53
- </li>
54
- `)}
55
- </ul>`
56
- : ''}
57
- `;
58
- }
59
- firstUpdated() {
60
- FileDropHelper.set(this);
61
- this.addEventListener('file-drop', (e) => {
62
- const detail = e.detail;
63
- this._files = this.multiple ? detail : detail[0] ? [detail[0]] : [];
64
- this.dispatchEvent(new CustomEvent('files-change', {
65
- bubbles: true,
66
- composed: true,
67
- detail: {
68
- files: this._files
69
- }
70
- }));
71
- });
72
- }
73
- get files() {
74
- return this._files;
75
- }
76
- reset() {
77
- this.fileInput.value = '';
78
- this._files = [];
79
- this.dispatchEvent(new CustomEvent('files-change', {
80
- bubbles: true,
81
- composed: true,
82
- detail: {
83
- files: this._files
84
- }
85
- }));
86
- }
87
- };
88
- CameraCapturer.styles = [
89
- css `
90
- :host {
91
- display: flex;
92
- flex-direction: column;
93
- border-radius: var(--border-radius);
94
- text-align: center;
95
- padding-bottom: 5px !important;
96
- text-transform: capitalize;
97
-
98
- border: var(--file-uploader-border);
99
- background-color: var(--main-section-background-color);
100
- font: var(--file-uploader-font) !important;
101
- color: var(--file-uploader-color);
102
- }
103
- :host > mwc-icon {
104
- color: var(--file-uploader-icon-color);
105
- }
106
-
107
- :host(.candrop) {
108
- background-color: var(--file-uploader-candrop-background-color);
109
- }
110
-
111
- #input-file {
112
- display: none;
113
- }
114
-
115
- label {
116
- position: relative;
117
- width: auto;
118
- border: none;
119
- text-transform: capitalize;
120
-
121
- padding: var(--file-uploader-label-padding);
122
- border-radius: var(--file-uploader-label-border-radius);
123
- background-color: var(--file-uploader-label-background-color);
124
- color: var(--file-uploader-label-color);
125
- font: var(--file-uploader-label-font) !important;
126
- }
127
-
128
- ul {
129
- max-width: 500px;
130
- list-style: none;
131
- padding: 0;
132
- }
133
- li {
134
- text-align: left;
135
-
136
- padding: var(--file-uploader-li-padding);
137
- border-bottom: var(--file-uploader-li-border-bottom);
138
- }
139
- li mwc-icon {
140
- float: right;
141
- cursor: pointer;
142
- font: var(--file-uploader-li-icon-font);
143
- margin: var(--file-uploader-li-icon-margin);
144
- }
145
- li mwc-icon:hover,
146
- li mwc-icon:active {
147
- color: var(--file-uploader-li-icon-focus-color);
148
- }
149
- `
150
- ];
151
- __decorate([
152
- property({ type: Boolean })
153
- ], CameraCapturer.prototype, "multiple", void 0);
154
- __decorate([
155
- property({ type: String })
156
- ], CameraCapturer.prototype, "accept", void 0);
157
- __decorate([
158
- property({ type: String })
159
- ], CameraCapturer.prototype, "label", void 0);
160
- __decorate([
161
- property({ type: Array })
162
- ], CameraCapturer.prototype, "_files", void 0);
163
- __decorate([
164
- query('#input-file')
165
- ], CameraCapturer.prototype, "fileInput", void 0);
166
- CameraCapturer = __decorate([
167
- customElement('ox-camera-capturer')
168
- ], CameraCapturer);
169
- export { CameraCapturer };
170
- //# sourceMappingURL=camera-capturer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"camera-capturer.js","sourceRoot":"","sources":["../../src/camera-capturer.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAE3B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGnD,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,UAAU;IAsE5C,MAAM;QACJ,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAA;QAE7B,OAAO,IAAI,CAAA;;;;;;iBAME,IAAI,CAAC,MAAM;oBACR,IAAI,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A1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;8CAAgB;AAoFpB;IAArB,KAAK,CAAC,aAAa,CAAC;iDAA6B;AAxJvC,cAAc;IAD1B,aAAa,CAAC,oBAAoB,CAAC;GACvB,cAAc,CA4K1B;SA5KY,cAAc","sourcesContent":["import '@material/mwc-icon'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { FileDropHelper } from './file-drop-helper'\n\n@customElement('ox-camera-capturer')\nexport class CameraCapturer extends LitElement {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n border-radius: var(--border-radius);\n text-align: center;\n padding-bottom: 5px !important;\n text-transform: capitalize;\n\n border: var(--file-uploader-border);\n background-color: var(--main-section-background-color);\n font: var(--file-uploader-font) !important;\n color: var(--file-uploader-color);\n }\n :host > mwc-icon {\n color: var(--file-uploader-icon-color);\n }\n\n :host(.candrop) {\n background-color: var(--file-uploader-candrop-background-color);\n }\n\n #input-file {\n display: none;\n }\n\n label {\n position: relative;\n width: auto;\n border: none;\n text-transform: capitalize;\n\n padding: var(--file-uploader-label-padding);\n border-radius: var(--file-uploader-label-border-radius);\n background-color: var(--file-uploader-label-background-color);\n color: var(--file-uploader-label-color);\n font: var(--file-uploader-label-font) !important;\n }\n\n ul {\n max-width: 500px;\n list-style: none;\n padding: 0;\n }\n li {\n text-align: left;\n\n padding: var(--file-uploader-li-padding);\n border-bottom: var(--file-uploader-li-border-bottom);\n }\n li mwc-icon {\n float: right;\n cursor: pointer;\n font: var(--file-uploader-li-icon-font);\n margin: var(--file-uploader-li-icon-margin);\n }\n li mwc-icon:hover,\n li mwc-icon:active {\n color: var(--file-uploader-li-icon-focus-color);\n }\n `\n ]\n\n @property({ type: Boolean }) multiple?: boolean\n @property({ type: String }) accept?: string\n @property({ type: String }) label?: string\n @property({ type: Array }) _files?: File[]\n\n render() {\n var files = this._files || []\n\n return html`\n <mwc-icon>camera</mwc-icon>\n <span>Capture image<br />or drop files here!</span>\n <input\n id=\"input-file\"\n type=\"file\"\n accept=${this.accept}\n ?multiple=${this.multiple}\n hidden\n capture=\"environment\"\n @change=${(e: Event) => {\n const fileInput = e.currentTarget as HTMLInputElement\n\n this._files = [...files, ...Array.from(fileInput.files as FileList)]\n\n this.dispatchEvent(\n new CustomEvent('files-change', {\n bubbles: true,\n composed: true,\n detail: {\n files: files\n }\n })\n )\n\n // fileInput.value = null\n fileInput.files = null\n }}\n />\n <label for=\"input-file\">${this.label || 'capture image'}</label>\n\n ${files?.length\n ? html` <ul>\n ${files.map(\n file => html`\n <li>\n - ${file.name}\n <mwc-icon\n @click=${(e: Event) => {\n this._files = [...files.splice(files.indexOf(file), 1)]\n this.dispatchEvent(\n new CustomEvent('files-change', {\n bubbles: true,\n composed: true,\n detail: {\n files: this._files\n }\n })\n )\n }}\n >delete_outline</mwc-icon\n >\n </li>\n `\n )}\n </ul>`\n : ''}\n `\n }\n\n firstUpdated() {\n FileDropHelper.set(this)\n\n this.addEventListener('file-drop', (e: Event) => {\n const detail = (e as CustomEvent).detail\n this._files = this.multiple ? detail : detail[0] ? [detail[0]] : []\n\n this.dispatchEvent(\n new CustomEvent('files-change', {\n bubbles: true,\n composed: true,\n detail: {\n files: this._files\n }\n })\n )\n })\n }\n\n @query('#input-file') fileInput!: HTMLInputElement\n\n get files() {\n return this._files\n }\n\n reset() {\n this.fileInput.value = ''\n this._files = []\n\n this.dispatchEvent(\n new CustomEvent('files-change', {\n bubbles: true,\n composed: true,\n detail: {\n files: this._files\n }\n })\n )\n }\n}\n"]}
@@ -1,16 +0,0 @@
1
- /**
2
- * judge callback function for FileDropHelper.set
3
- */
4
- declare type JudgeCallback = () => boolean;
5
- /**
6
- * file drop assist class
7
- */
8
- export declare class FileDropHelper {
9
- /**
10
- * 파일 드롭 영역에서의 file drag&drop과 관련된 이벤트에 대한 처리를 설정한다.
11
- * @param dropArea file drag&drop target area
12
- * @param [judge] file drag&drop과 관련된 이벤트에 대한 judge callback function
13
- */
14
- static set(dropArea: HTMLElement, judge?: JudgeCallback): void;
15
- }
16
- export {};
@@ -1,47 +0,0 @@
1
- /**
2
- * file drop assist class
3
- */
4
- export class FileDropHelper {
5
- /**
6
- * 파일 드롭 영역에서의 file drag&drop과 관련된 이벤트에 대한 처리를 설정한다.
7
- * @param dropArea file drag&drop target area
8
- * @param [judge] file drag&drop과 관련된 이벤트에 대한 judge callback function
9
- */
10
- static set(dropArea, judge) {
11
- var preventDefaults = (e) => {
12
- if (!judge || judge()) {
13
- e.preventDefault();
14
- e.stopPropagation();
15
- }
16
- };
17
- var highlight = (e) => {
18
- if (!judge || judge()) {
19
- dropArea.classList.add('candrop');
20
- }
21
- };
22
- var unhighlight = (e) => {
23
- if (!judge || judge()) {
24
- dropArea.classList.remove('candrop');
25
- }
26
- };
27
- ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(event => {
28
- dropArea.addEventListener(event, preventDefaults, false);
29
- });
30
- ['dragenter', 'dragover'].forEach(event => {
31
- dropArea.addEventListener(event, highlight, false);
32
- });
33
- ['dragleave', 'drop'].forEach(event => {
34
- dropArea.addEventListener(event, unhighlight, false);
35
- });
36
- dropArea.addEventListener('drop', e => {
37
- if (!judge || judge()) {
38
- let dt = e.dataTransfer;
39
- let files = dt.files;
40
- dropArea.dispatchEvent(new CustomEvent('file-drop', {
41
- detail: [...Array.from(files)]
42
- }));
43
- }
44
- }, false);
45
- }
46
- }
47
- //# sourceMappingURL=file-drop-helper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-drop-helper.js","sourceRoot":"","sources":["../../src/file-drop-helper.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,OAAO,cAAc;IACzB;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,QAAqB,EAAE,KAAqB;QACrD,IAAI,eAAe,GAAG,CAAC,CAAQ,EAAE,EAAE;YACjC,IAAI,CAAC,KAAK,IAAI,KAAK,EAAE,EAAE;gBACrB,CAAC,CAAC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,WAAW,CAAC,WAAW,EAAE;oBAC3B,MAAM,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;iBAC/B,CAAC,CACH,CAAA;aACF;QACH,CAAC,EACD,KAAK,CACN,CAAA;IACH,CAAC;CACF","sourcesContent":["/**\n * judge callback function for FileDropHelper.set\n */\ntype JudgeCallback = () => boolean\n\n/**\n * file drop assist class\n */\nexport class FileDropHelper {\n /**\n * 파일 드롭 영역에서의 file drag&drop과 관련된 이벤트에 대한 처리를 설정한다.\n * @param dropArea file drag&drop target area\n * @param [judge] file drag&drop과 관련된 이벤트에 대한 judge callback function\n */\n static set(dropArea: HTMLElement, judge?: JudgeCallback) {\n var preventDefaults = (e: Event) => {\n if (!judge || judge()) {\n e.preventDefault()\n e.stopPropagation()\n }\n }\n\n var highlight = (e: Event) => {\n if (!judge || judge()) {\n dropArea.classList.add('candrop')\n }\n }\n\n var unhighlight = (e: Event) => {\n if (!judge || judge()) {\n dropArea.classList.remove('candrop')\n }\n }\n\n ;['dragenter', 'dragover', 'dragleave', 'drop'].forEach(event => {\n dropArea.addEventListener(event, preventDefaults, false)\n })\n ;['dragenter', 'dragover'].forEach(event => {\n dropArea.addEventListener(event, highlight, false)\n })\n ;['dragleave', 'drop'].forEach(event => {\n dropArea.addEventListener(event, unhighlight, false)\n })\n\n dropArea.addEventListener(\n 'drop',\n e => {\n if (!judge || judge()) {\n let dt = e.dataTransfer!\n let files = dt.files\n\n dropArea.dispatchEvent(\n new CustomEvent('file-drop', {\n detail: [...Array.from(files)]\n })\n )\n }\n },\n false\n )\n }\n}\n"]}
File without changes
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=touch-mouse-event.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"touch-mouse-event.js","sourceRoot":"","sources":["../../../src/utils/touch-mouse-event.ts"],"names":[],"mappings":"","sourcesContent":[""]}