@operato/ocr 8.0.0 → 9.0.0-beta.10
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/CHANGELOG.md +177 -13
- package/dist/src/ox-ocr-helper.d.ts +2 -2
- package/dist/src/ox-ocr-helper.js +40 -8
- package/dist/src/ox-ocr-helper.js.map +1 -1
- package/dist/src/ox-ocr-result-image.d.ts +1 -1
- package/dist/src/ox-ocr-result-image.js +76 -11
- package/dist/src/ox-ocr-result-image.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,92 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [
|
|
6
|
+
## [9.0.0-beta.10](https://github.com/hatiolab/operato/compare/v9.0.0-beta.9...v9.0.0-beta.10) (2025-01-25)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :bug: Bug Fix
|
|
10
|
+
|
|
11
|
+
* tweak tsconfig.json ([3c424b1](https://github.com/hatiolab/operato/commit/3c424b18d046f95d5619076d113d49a4b4dc9bbb))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [9.0.0-beta.7](https://github.com/hatiolab/operato/compare/v9.0.0-beta.6...v9.0.0-beta.7) (2025-01-20)
|
|
16
|
+
|
|
17
|
+
**Note:** Version bump only for package @operato/ocr
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## [9.0.0-beta.6](https://github.com/hatiolab/operato/compare/v9.0.0-beta.5...v9.0.0-beta.6) (2025-01-20)
|
|
24
|
+
|
|
25
|
+
**Note:** Version bump only for package @operato/ocr
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## [9.0.0-beta.5](https://github.com/hatiolab/operato/compare/v9.0.0-beta.4...v9.0.0-beta.5) (2025-01-20)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### :bug: Bug Fix
|
|
35
|
+
|
|
36
|
+
* esm module ([1319b00](https://github.com/hatiolab/operato/commit/1319b00d6955a514f63b3469fb514a28f84168a2))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## [9.0.0-beta.4](https://github.com/hatiolab/operato/compare/v9.0.0-beta.3...v9.0.0-beta.4) (2025-01-20)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### :bug: Bug Fix
|
|
44
|
+
|
|
45
|
+
* esm module ([0402232](https://github.com/hatiolab/operato/commit/04022327fa47eac64eaf3c56eeec55b9ace13e0e))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## [9.0.0-beta.0](https://github.com/hatiolab/operato/compare/v8.0.0-beta.11...v9.0.0-beta.0) (2025-01-13)
|
|
50
|
+
|
|
51
|
+
**Note:** Version bump only for package @operato/ocr
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## [8.0.0-beta.5](https://github.com/hatiolab/operato/compare/v8.0.0-beta.4...v8.0.0-beta.5) (2025-01-10)
|
|
58
|
+
|
|
59
|
+
**Note:** Version bump only for package @operato/ocr
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
## [8.0.0-beta.2](https://github.com/hatiolab/operato/compare/v8.0.0-beta.1...v8.0.0-beta.2) (2025-01-08)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
### :bug: Bug Fix
|
|
69
|
+
|
|
70
|
+
* typo .npmignore ([d9c0c8c](https://github.com/hatiolab/operato/commit/d9c0c8c79abc688c3c2cfb6c37fcb689483a5977))
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## [8.0.0-beta.1](https://github.com/hatiolab/operato/compare/v8.0.0-beta.0...v8.0.0-beta.1) (2025-01-08)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
### :bug: Bug Fix
|
|
78
|
+
|
|
79
|
+
* missing .npmignore ([be05985](https://github.com/hatiolab/operato/commit/be05985abfae4af53501f718dd52932099f7fbcb))
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
## [8.0.0-beta.0](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.56...v8.0.0-beta.0) (2025-01-07)
|
|
84
|
+
|
|
85
|
+
**Note:** Version bump only for package @operato/ocr
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
## [8.0.0-alpha.51](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.50...v8.0.0-alpha.51) (2024-11-29)
|
|
7
92
|
|
|
8
93
|
**Note:** Version bump only for package @operato/ocr
|
|
9
94
|
|
|
@@ -11,17 +96,96 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
11
96
|
|
|
12
97
|
|
|
13
98
|
|
|
14
|
-
|
|
99
|
+
## [8.0.0-alpha.50](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.49...v8.0.0-alpha.50) (2024-11-16)
|
|
100
|
+
|
|
101
|
+
**Note:** Version bump only for package @operato/ocr
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
## [8.0.0-alpha.46](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.45...v8.0.0-alpha.46) (2024-10-23)
|
|
108
|
+
|
|
109
|
+
**Note:** Version bump only for package @operato/ocr
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
## [8.0.0-alpha.45](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.44...v8.0.0-alpha.45) (2024-10-23)
|
|
116
|
+
|
|
117
|
+
**Note:** Version bump only for package @operato/ocr
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
## [8.0.0-alpha.41](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.40...v8.0.0-alpha.41) (2024-10-21)
|
|
124
|
+
|
|
125
|
+
**Note:** Version bump only for package @operato/ocr
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
## [8.0.0-alpha.37](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.36...v8.0.0-alpha.37) (2024-10-20)
|
|
15
132
|
|
|
16
133
|
|
|
17
134
|
### :bug: Bug Fix
|
|
18
135
|
|
|
19
|
-
*
|
|
20
|
-
|
|
136
|
+
* update dev-dependencies version ([d6fe342](https://github.com/hatiolab/operato/commit/d6fe342de738c6bad3528550a862b5a1d2573161))
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
## [8.0.0-alpha.34](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.33...v8.0.0-alpha.34) (2024-10-15)
|
|
141
|
+
|
|
142
|
+
**Note:** Version bump only for package @operato/ocr
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
## [8.0.0-alpha.33](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.32...v8.0.0-alpha.33) (2024-10-14)
|
|
149
|
+
|
|
150
|
+
**Note:** Version bump only for package @operato/ocr
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
## [8.0.0-alpha.30](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.29...v8.0.0-alpha.30) (2024-10-11)
|
|
157
|
+
|
|
158
|
+
**Note:** Version bump only for package @operato/ocr
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
## [8.0.0-alpha.29](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.28...v8.0.0-alpha.29) (2024-10-10)
|
|
165
|
+
|
|
166
|
+
**Note:** Version bump only for package @operato/ocr
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
## [8.0.0-alpha.27](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.26...v8.0.0-alpha.27) (2024-10-06)
|
|
173
|
+
|
|
174
|
+
**Note:** Version bump only for package @operato/ocr
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
## [8.0.0-alpha.26](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.25...v8.0.0-alpha.26) (2024-10-06)
|
|
181
|
+
|
|
182
|
+
**Note:** Version bump only for package @operato/ocr
|
|
183
|
+
|
|
184
|
+
|
|
21
185
|
|
|
22
186
|
|
|
23
187
|
|
|
24
|
-
|
|
188
|
+
## [8.0.0-alpha.21](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.20...v8.0.0-alpha.21) (2024-10-05)
|
|
25
189
|
|
|
26
190
|
**Note:** Version bump only for package @operato/ocr
|
|
27
191
|
|
|
@@ -29,7 +193,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
29
193
|
|
|
30
194
|
|
|
31
195
|
|
|
32
|
-
|
|
196
|
+
## [8.0.0-alpha.20](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.19...v8.0.0-alpha.20) (2024-10-04)
|
|
33
197
|
|
|
34
198
|
**Note:** Version bump only for package @operato/ocr
|
|
35
199
|
|
|
@@ -37,7 +201,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
37
201
|
|
|
38
202
|
|
|
39
203
|
|
|
40
|
-
|
|
204
|
+
## [8.0.0-alpha.19](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.18...v8.0.0-alpha.19) (2024-10-04)
|
|
41
205
|
|
|
42
206
|
**Note:** Version bump only for package @operato/ocr
|
|
43
207
|
|
|
@@ -45,7 +209,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
45
209
|
|
|
46
210
|
|
|
47
211
|
|
|
48
|
-
|
|
212
|
+
## [8.0.0-alpha.10](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.9...v8.0.0-alpha.10) (2024-09-18)
|
|
49
213
|
|
|
50
214
|
**Note:** Version bump only for package @operato/ocr
|
|
51
215
|
|
|
@@ -53,7 +217,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
53
217
|
|
|
54
218
|
|
|
55
219
|
|
|
56
|
-
|
|
220
|
+
## [8.0.0-alpha.4](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.3...v8.0.0-alpha.4) (2024-09-07)
|
|
57
221
|
|
|
58
222
|
**Note:** Version bump only for package @operato/ocr
|
|
59
223
|
|
|
@@ -61,7 +225,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
61
225
|
|
|
62
226
|
|
|
63
227
|
|
|
64
|
-
|
|
228
|
+
## [8.0.0-alpha.3](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.2...v8.0.0-alpha.3) (2024-09-06)
|
|
65
229
|
|
|
66
230
|
**Note:** Version bump only for package @operato/ocr
|
|
67
231
|
|
|
@@ -69,7 +233,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
69
233
|
|
|
70
234
|
|
|
71
235
|
|
|
72
|
-
|
|
236
|
+
## [8.0.0-alpha.2](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.1...v8.0.0-alpha.2) (2024-09-05)
|
|
73
237
|
|
|
74
238
|
**Note:** Version bump only for package @operato/ocr
|
|
75
239
|
|
|
@@ -77,7 +241,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
77
241
|
|
|
78
242
|
|
|
79
243
|
|
|
80
|
-
|
|
244
|
+
## [8.0.0-alpha.1](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.0...v8.0.0-alpha.1) (2024-09-04)
|
|
81
245
|
|
|
82
246
|
**Note:** Version bump only for package @operato/ocr
|
|
83
247
|
|
|
@@ -85,7 +249,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
85
249
|
|
|
86
250
|
|
|
87
251
|
|
|
88
|
-
|
|
252
|
+
## [8.0.0-alpha.0](https://github.com/hatiolab/operato/compare/v7.1.1...v8.0.0-alpha.0) (2024-09-01)
|
|
89
253
|
|
|
90
254
|
**Note:** Version bump only for package @operato/ocr
|
|
91
255
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import '@material/web/progress/linear-progress.js';
|
|
2
2
|
import '@operato/input';
|
|
3
|
-
import './ox-ocr-result-image';
|
|
3
|
+
import './ox-ocr-result-image.js';
|
|
4
4
|
import { LitElement } from 'lit';
|
|
5
|
-
import { ScanResult } from './type';
|
|
5
|
+
import { ScanResult } from './type.js';
|
|
6
6
|
export declare class OcrHelper extends LitElement {
|
|
7
7
|
static styles: import("lit").CSSResult[];
|
|
8
8
|
result: ScanResult[];
|
|
@@ -1,17 +1,44 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import '@material/web/progress/linear-progress.js';
|
|
3
3
|
import '@operato/input';
|
|
4
|
-
import './ox-ocr-result-image';
|
|
4
|
+
import './ox-ocr-result-image.js';
|
|
5
5
|
import { css, html, LitElement } from 'lit';
|
|
6
6
|
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
7
7
|
import { copyToClipboard } from '@operato/utils';
|
|
8
|
-
import { NOTHING_RESULT } from './type';
|
|
8
|
+
import { NOTHING_RESULT } from './type.js';
|
|
9
9
|
let OcrHelper = class OcrHelper extends LitElement {
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments);
|
|
12
|
-
this
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
Object.defineProperty(this, "result", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: []
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(this, "files", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: []
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(this, "_index", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: 0
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(this, "fileUploader", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: void 0
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(this, "copied", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
configurable: true,
|
|
39
|
+
writable: true,
|
|
40
|
+
value: void 0
|
|
41
|
+
});
|
|
15
42
|
}
|
|
16
43
|
render() {
|
|
17
44
|
var _a;
|
|
@@ -75,8 +102,12 @@ let OcrHelper = class OcrHelper extends LitElement {
|
|
|
75
102
|
await copyToClipboard(e.detail);
|
|
76
103
|
}
|
|
77
104
|
};
|
|
78
|
-
OcrHelper
|
|
79
|
-
|
|
105
|
+
Object.defineProperty(OcrHelper, "styles", {
|
|
106
|
+
enumerable: true,
|
|
107
|
+
configurable: true,
|
|
108
|
+
writable: true,
|
|
109
|
+
value: [
|
|
110
|
+
css `
|
|
80
111
|
:host {
|
|
81
112
|
display: flex;
|
|
82
113
|
flex-direction: column;
|
|
@@ -120,7 +151,8 @@ OcrHelper.styles = [
|
|
|
120
151
|
flex: 1;
|
|
121
152
|
}
|
|
122
153
|
`
|
|
123
|
-
]
|
|
154
|
+
]
|
|
155
|
+
});
|
|
124
156
|
__decorate([
|
|
125
157
|
property({ type: Array })
|
|
126
158
|
], OcrHelper.prototype, "result", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-ocr-helper.js","sourceRoot":"","sources":["../../src/ox-ocr-helper.ts"],"names":[],"mappings":";AAA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,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2CF;KACF;EA7CY,CA6CZ;AAE0B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;yCAA0B;AACzB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;wCAAuB;AAExC;IAAR,KAAK,EAAE;yCAAmB;AAEP;IAAnB,KAAK,CAAC,WAAW,CAAC;+CAAmB;AACpB;IAAjB,KAAK,CAAC,SAAS,CAAC;yCAAqB;AAtD3B,SAAS;IADrB,aAAa,CAAC,eAAe,CAAC;GAClB,SAAS,CAyHrB","sourcesContent":["import '@material/web/progress/linear-progress.js'\nimport '@operato/input'\nimport './ox-ocr-result-image.js'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { copyToClipboard } from '@operato/utils'\n\nimport { NOTHING_RESULT, ScanResult } from './type.js'\n\n@customElement('ox-ocr-helper')\nexport class OcrHelper extends LitElement {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n min-width: 240px;\n }\n\n [buttons] {\n display: flex;\n flex-direction: row-reverse;\n }\n\n #images {\n flex: 1;\n background-color: var(--md-sys-color-background, #f4f7fb);\n color: white;\n\n display: flex;\n flex-direction: column;\n }\n\n [tab] {\n display: flex;\n flex-direction: row;\n }\n\n [i] {\n min-width: 50px;\n background-color: var(--md-sys-color-on-secondary-container, #394e64);\n border-right: 1px solid rgba(0, 0, 0, 0.2);\n padding: var(--spacing-small, 4px);\n text-align: center;\n height: 1.4em;\n }\n\n [i][active] {\n background-color: var(--md-sys-color-on-primary-container, #22a6a7);\n font-weight: bold;\n }\n\n ox-ocr-result-image {\n flex: 1;\n }\n `\n ]\n\n @property({ type: Array }) result: ScanResult[] = []\n @property({ type: Array }) files: Array<any> = []\n\n @state() _index: number = 0\n\n @query('#capturer') fileUploader!: any\n @query('#copied') copied!: HTMLElement\n\n render() {\n const files = this.files || []\n const index = this._index || 0\n const file = files[index]\n const result = this.result?.[index] || NOTHING_RESULT\n\n return html`\n <div attachment-wrap>\n <ox-input-file\n id=\"capturer\"\n label=\"Capture Images\"\n accept=\"image/*\"\n multiple=\"true\"\n ?hidden=${false}\n @change=${(e: Event) => this.onFilesChange(e)}\n hide-filelist\n ></ox-input-file>\n </div>\n ${this.files.length > 0 && !(this.result.length > 0)\n ? html`<md-linear-progress indeterminate></md-linear-progress> `\n : html``}\n\n <div id=\"images\">\n <div\n tab\n @click=${(e: MouseEvent) => {\n const item = (e.target as HTMLElement)?.closest('[i]')\n const children = (e.currentTarget as HTMLElement)?.querySelectorAll('[i]')\n if (item) {\n this._index = Array.from(children).indexOf(item)\n }\n }}\n >\n ${files.map((file: any, idx: number) => html`<div i ?active=${idx === index}>${idx}</div>`)}\n </div>\n <ox-ocr-result-image\n .file=${file}\n @selected=${(e: CustomEvent) => this.onSelected(e)}\n .result=${result}\n ></ox-ocr-result-image>\n </div>\n\n <div id=\"copied\"></div>\n `\n }\n\n reset() {\n this.fileUploader.reset()\n this.copied.textContent = ''\n }\n\n onFilesChange(e: Event) {\n this.files = this.fileUploader.files\n this.result = []\n\n this.dispatchEvent(\n new CustomEvent('attached', {\n detail: this.fileUploader?.files\n })\n )\n }\n\n async onSelected(e: CustomEvent) {\n await copyToClipboard(e.detail)\n }\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { css, html, LitElement } from 'lit';
|
|
3
3
|
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
4
|
-
import { NOTHING_RESULT } from './type';
|
|
5
|
-
import { touch2mouse } from './utils/touch-to-mouse-event';
|
|
4
|
+
import { NOTHING_RESULT } from './type.js';
|
|
5
|
+
import { touch2mouse } from './utils/touch-to-mouse-event.js';
|
|
6
6
|
function convert2To4(p1, p2) {
|
|
7
7
|
const x = p2.x - p1.x;
|
|
8
8
|
const y = p2.y - p1.y;
|
|
@@ -29,12 +29,72 @@ function convert2To4(p1, p2) {
|
|
|
29
29
|
let OcrResultImage = class OcrResultImage extends LitElement {
|
|
30
30
|
constructor() {
|
|
31
31
|
super(...arguments);
|
|
32
|
-
this
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
Object.defineProperty(this, "file", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: void 0
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(this, "result", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true,
|
|
42
|
+
value: NOTHING_RESULT
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(this, "_ratio", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true,
|
|
48
|
+
value: { x: 1, y: 1 }
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(this, "_image", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
configurable: true,
|
|
53
|
+
writable: true,
|
|
54
|
+
value: void 0
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(this, "_resizeObserver", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
configurable: true,
|
|
59
|
+
writable: true,
|
|
60
|
+
value: void 0
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(this, "_trails", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
configurable: true,
|
|
65
|
+
writable: true,
|
|
66
|
+
value: []
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(this, "_tracking", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
configurable: true,
|
|
71
|
+
writable: true,
|
|
72
|
+
value: false
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(this, "_selections", {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
configurable: true,
|
|
77
|
+
writable: true,
|
|
78
|
+
value: []
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(this, "_text", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
configurable: true,
|
|
83
|
+
writable: true,
|
|
84
|
+
value: ''
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(this, "_img", {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
configurable: true,
|
|
89
|
+
writable: true,
|
|
90
|
+
value: void 0
|
|
91
|
+
});
|
|
92
|
+
Object.defineProperty(this, "_overlay", {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
configurable: true,
|
|
95
|
+
writable: true,
|
|
96
|
+
value: void 0
|
|
97
|
+
});
|
|
38
98
|
}
|
|
39
99
|
render() {
|
|
40
100
|
return html `
|
|
@@ -223,8 +283,12 @@ let OcrResultImage = class OcrResultImage extends LitElement {
|
|
|
223
283
|
this.updateTrails({ x: x / this._ratio.x, y: y / this._ratio.y }, false);
|
|
224
284
|
}
|
|
225
285
|
};
|
|
226
|
-
OcrResultImage
|
|
227
|
-
|
|
286
|
+
Object.defineProperty(OcrResultImage, "styles", {
|
|
287
|
+
enumerable: true,
|
|
288
|
+
configurable: true,
|
|
289
|
+
writable: true,
|
|
290
|
+
value: [
|
|
291
|
+
css `
|
|
228
292
|
:host {
|
|
229
293
|
display: block;
|
|
230
294
|
position: relative;
|
|
@@ -270,7 +334,8 @@ OcrResultImage.styles = [
|
|
|
270
334
|
font-size: 1.5em;
|
|
271
335
|
}
|
|
272
336
|
`
|
|
273
|
-
]
|
|
337
|
+
]
|
|
338
|
+
});
|
|
274
339
|
__decorate([
|
|
275
340
|
property({ type: Array })
|
|
276
341
|
], OcrResultImage.prototype, "file", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-ocr-result-image.js","sourceRoot":"","sources":["../../src/ox-ocr-result-image.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AAC3D,O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AC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,CAAA;IAC1E,CAAC;;AAhTM,qBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6CF;CACF,AA/CY,CA+CZ;AAE0B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;4CAAU;AACT;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;8CAAoC;AAErD;IAAR,KAAK,EAAE;8CAAkD;AACjD;IAAR,KAAK,EAAE;8CAAgB;AACf;IAAR,KAAK,EAAE;uDAAiC;AAChC;IAAR,KAAK,EAAE;+CAAqD;AACpD;IAAR,KAAK,EAAE;iDAA2B;AAC1B;IAAR,KAAK,EAAE;mDAAgC;AAC/B;IAAR,KAAK,EAAE;6CAAmB;AAEb;IAAb,KAAK,CAAC,KAAK,CAAC;4CAAwB;AACjB;IAAnB,KAAK,CAAC,WAAW,CAAC;gDAA6B;AA9DrC,cAAc;IAD1B,aAAa,CAAC,qBAAqB,CAAC;GACxB,cAAc,CAkT1B","sourcesContent":["import { css, html, LitElement, PropertyValues } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { NOTHING_RESULT, ScanResult } from './type'\nimport { touch2mouse } from './utils/touch-to-mouse-event'\n\nfunction convert2To4(p1: { x: number; y: number }, p2: { x: number; y: number }): { x: number; y: number }[] {\n const x = p2.x - p1.x\n const y = p2.y - p1.y\n const length = Math.sqrt(x * x + y * y)\n const center = { x: p1.x + x / 2, y: p1.y + y / 2 }\n const theta = Math.atan2(y, x)\n\n const newp1 = { x: center.x - length / 2, y: center.y }\n const newp2 = { x: center.x + length / 2, y: center.y }\n\n const rectpoints = [\n { x: newp1.x, y: newp1.y - 10 },\n { x: newp1.x, y: newp1.y + 10 },\n { x: newp2.x, y: newp2.y + 10 },\n { x: newp2.x, y: newp2.y - 10 }\n ]\n\n const cos = Math.cos(theta)\n const sin = Math.sin(theta)\n\n return rectpoints.map(({ x, y }: { x: number; y: number }) => {\n return {\n x: cos * (x - center.x) + sin * (y - center.y) + center.x,\n y: cos * (y - center.y) - sin * (x - center.x) + center.y\n }\n })\n}\n\n@customElement('ox-ocr-result-image')\nexport class OcrResultImage extends LitElement {\n static styles = [\n css`\n :host {\n display: block;\n position: relative;\n }\n\n img {\n display: block;\n flex: 1;\n border: 0;\n padding: 0;\n margin: 0;\n max-width: 100%;\n max-height: 100%;\n }\n\n img[noimage] {\n display: none;\n }\n\n [overlay] {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n\n border: 0;\n padding: 0;\n margin: 0;\n opacity: 50%;\n }\n\n [notice] {\n position: absolute;\n bottom: 0;\n background-color: var(--md-sys-color-on-primary-container, #38a25b);\n padding: var(--padding-default, 9px) var(--spacing-large, 15px);\n opacity: 0.95;\n\n overflow-wrap: anywhere;\n\n color: #fff;\n font-size: 1.5em;\n }\n `\n ]\n\n @property({ type: Array }) file: any\n @property({ type: Array }) result: ScanResult = NOTHING_RESULT\n\n @state() _ratio: { x: number; y: number } = { x: 1, y: 1 }\n @state() _image!: string\n @state() _resizeObserver!: ResizeObserver\n @state() _trails: Array<Array<{ x: number; y: number }>> = []\n @state() _tracking: boolean = false\n @state() _selections: Array<number> = []\n @state() _text: string = ''\n\n @query('img') _img!: HTMLImageElement\n @query('[overlay]') _overlay!: HTMLCanvasElement\n\n render() {\n return html`\n <img src=${this._image} @load=${() => this.calculateRatio()} ?noimage=${!this._image} />\n <canvas overlay></canvas>\n\n ${this._text ? html` <div notice>${this._text} copied!</div> ` : html``}\n `\n }\n\n renderOverlay() {\n const { boundaries } = this.result\n\n const context = this._overlay.getContext('2d')\n if (!context) {\n return\n }\n\n context.save()\n\n context.clearRect(0, 0, this._overlay.width, this._overlay.height)\n\n context.lineWidth = 5\n context.strokeStyle = 'red'\n context.fillStyle = 'red'\n context.lineJoin = 'round'\n context.lineCap = 'round'\n\n this._image &&\n boundaries\n .map((bounds): Array<{ x: number; y: number }> => {\n return bounds.map(bound => {\n return {\n x: bound.x, //* this._ratio.x,\n y: bound.y // * this._ratio.y\n }\n })\n })\n .forEach((bounds, idx) => {\n context.beginPath()\n\n context.moveTo(bounds[0].x, bounds[0].y)\n context.lineTo(bounds[1].x, bounds[1].y)\n context.lineTo(bounds[2].x, bounds[2].y)\n context.lineTo(bounds[3].x, bounds[3].y)\n context.closePath()\n\n if (this._selections.includes(idx)) {\n context.fill()\n }\n context.stroke()\n })\n\n /* draw trails */\n if (this._trails && this._trails.length > 0) {\n context.lineWidth = 10\n context.strokeStyle = 'blue'\n\n context.beginPath()\n\n this._trails.forEach(trail => {\n if (trail && trail.length > 0) {\n const { x, y } = trail[0]\n context.moveTo(x, y)\n\n trail.slice(1).forEach(point => {\n const { x, y } = point\n context.lineTo(x, y)\n })\n }\n })\n\n context.stroke()\n }\n\n context.restore()\n }\n\n async calculateRatio() {\n const { naturalWidth, naturalHeight, offsetWidth, offsetHeight } = this._img\n const { offsetWidth: overlayWidth, offsetHeight: overlayHeight } = this._overlay\n\n if (!naturalWidth || !naturalHeight) {\n return\n }\n\n this._ratio = {\n x: offsetWidth / naturalWidth,\n y: offsetHeight / naturalHeight\n }\n\n this._overlay.setAttribute('width', String(overlayWidth / this._ratio.x))\n this._overlay.setAttribute('height', String(overlayHeight / this._ratio.y))\n }\n\n async connectedCallback() {\n await super.connectedCallback()\n\n this._resizeObserver = new ResizeObserver(entries => {\n this.calculateRatio()\n this.renderOverlay()\n })\n\n await this.updateComplete\n this._resizeObserver.observe(this._overlay)\n\n this.calculateRatio()\n\n this.addEventListener('mousedown', this.onTrailStart.bind(this) as EventListener)\n this.addEventListener('mouseup', this.onTrailEnd.bind(this) as EventListener)\n this.addEventListener('mousemove', this.onTrail.bind(this) as EventListener)\n this.addEventListener('touchstart', touch2mouse as EventListener)\n this.addEventListener('touchend', touch2mouse as EventListener)\n this.addEventListener('touchmove', touch2mouse as EventListener)\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n\n this._resizeObserver.disconnect()\n }\n\n reset() {\n this._selections = []\n this._trails = []\n this._text = ''\n }\n\n async updated(changes: PropertyValues<this>) {\n if (changes.has('file') || changes.has('result')) {\n this.reset()\n }\n\n if (changes.has('result')) {\n this.result.boundaries = this.result.boundaries.map((bound: { x: number; y: number }[]) => {\n return bound.length > 2 ? bound : convert2To4(bound[0], bound[1])\n })\n }\n\n if (changes.has('file')) {\n this._image = this.file && URL.createObjectURL(this.file)\n if (this._image) {\n requestAnimationFrame(() => {\n URL.revokeObjectURL(this._image)\n })\n\n await this.updateComplete\n this.calculateRatio()\n }\n }\n\n this.renderOverlay()\n }\n\n findIndex(x: number, y: number): number {\n const { boundaries } = this.result\n\n return boundaries.findIndex(path => {\n var result = false\n\n path.forEach((p, idx) => {\n let j = (idx + path.length + 1) % path.length\n\n let x1 = p.x\n let y1 = p.y\n let x2 = path[j].x\n let y2 = path[j].y\n\n if (y1 > y != y2 > y && x < ((x2 - x1) * (y - y1)) / (y2 - y1) + x1) {\n result = !result\n }\n })\n\n return result\n })\n }\n\n updateTrails(point: { x: number; y: number }, started: boolean, attached?: boolean) {\n if (started && !attached) {\n this.reset()\n }\n\n if (started) {\n this._trails.push([])\n }\n\n var trail = this._trails[this._trails.length - 1]\n if (!trail) {\n return\n }\n\n trail.push(point)\n\n this._trails.flat().forEach(({ x, y }) => {\n const idx = this.findIndex(x, y)\n if (idx === -1) {\n return\n }\n\n if (!this._selections.includes(idx)) {\n this._selections.push(idx)\n }\n })\n\n this.requestUpdate()\n }\n\n onTrailStart(e: MouseEvent) {\n const { offsetX: x, offsetY: y, button, shiftKey } = e\n\n if (button !== 0) {\n return\n }\n\n this._tracking = true\n this.updateTrails({ x: x / this._ratio.x, y: y / this._ratio.y }, true, shiftKey)\n }\n\n onTrailEnd(e: MouseEvent) {\n if (!this._tracking) {\n return\n }\n\n this._text = this._selections.map(idx => this.result.texts[idx]).join('')\n\n this.dispatchEvent(\n new CustomEvent('select', {\n detail: this._text\n })\n )\n\n this._tracking = false\n }\n\n onTrail(e: MouseEvent) {\n const { offsetX: x, offsetY: y } = e\n\n if (!this._tracking) {\n return\n }\n\n this.updateTrails({ x: x / this._ratio.x, y: y / this._ratio.y }, false)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ox-ocr-result-image.js","sourceRoot":"","sources":["../../src/ox-ocr-result-image.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzE,OAAO,EAAE,cAAc,EAAc,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAE7D,SAAS,WAAW,CAAC,EAA4B,EAAE,EAA4B;IAC7E,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;IACrB,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;IACrB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;IACvC,MAAM,MAAM,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAA;IACnD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAE9B,MAAM,KAAK,GAAG,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,C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ement, PropertyValues } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { NOTHING_RESULT, ScanResult } from './type.js'\nimport { touch2mouse } from './utils/touch-to-mouse-event.js'\n\nfunction convert2To4(p1: { x: number; y: number }, p2: { x: number; y: number }): { x: number; y: number }[] {\n const x = p2.x - p1.x\n const y = p2.y - p1.y\n const length = Math.sqrt(x * x + y * y)\n const center = { x: p1.x + x / 2, y: p1.y + y / 2 }\n const theta = Math.atan2(y, x)\n\n const newp1 = { x: center.x - length / 2, y: center.y }\n const newp2 = { x: center.x + length / 2, y: center.y }\n\n const rectpoints = [\n { x: newp1.x, y: newp1.y - 10 },\n { x: newp1.x, y: newp1.y + 10 },\n { x: newp2.x, y: newp2.y + 10 },\n { x: newp2.x, y: newp2.y - 10 }\n ]\n\n const cos = Math.cos(theta)\n const sin = Math.sin(theta)\n\n return rectpoints.map(({ x, y }: { x: number; y: number }) => {\n return {\n x: cos * (x - center.x) + sin * (y - center.y) + center.x,\n y: cos * (y - center.y) - sin * (x - center.x) + center.y\n }\n })\n}\n\n@customElement('ox-ocr-result-image')\nexport class OcrResultImage extends LitElement {\n static styles = [\n css`\n :host {\n display: block;\n position: relative;\n }\n\n img {\n display: block;\n flex: 1;\n border: 0;\n padding: 0;\n margin: 0;\n max-width: 100%;\n max-height: 100%;\n }\n\n img[noimage] {\n display: none;\n }\n\n [overlay] {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n\n border: 0;\n padding: 0;\n margin: 0;\n opacity: 50%;\n }\n\n [notice] {\n position: absolute;\n bottom: 0;\n background-color: var(--md-sys-color-on-primary-container, #38a25b);\n padding: var(--padding-default, 9px) var(--spacing-large, 15px);\n opacity: 0.95;\n\n overflow-wrap: anywhere;\n\n color: #fff;\n font-size: 1.5em;\n }\n `\n ]\n\n @property({ type: Array }) file: any\n @property({ type: Array }) result: ScanResult = NOTHING_RESULT\n\n @state() _ratio: { x: number; y: number } = { x: 1, y: 1 }\n @state() _image!: string\n @state() _resizeObserver!: ResizeObserver\n @state() _trails: Array<Array<{ x: number; y: number }>> = []\n @state() _tracking: boolean = false\n @state() _selections: Array<number> = []\n @state() _text: string = ''\n\n @query('img') _img!: HTMLImageElement\n @query('[overlay]') _overlay!: HTMLCanvasElement\n\n render() {\n return html`\n <img src=${this._image} @load=${() => this.calculateRatio()} ?noimage=${!this._image} />\n <canvas overlay></canvas>\n\n ${this._text ? html` <div notice>${this._text} copied!</div> ` : html``}\n `\n }\n\n renderOverlay() {\n const { boundaries } = this.result\n\n const context = this._overlay.getContext('2d')\n if (!context) {\n return\n }\n\n context.save()\n\n context.clearRect(0, 0, this._overlay.width, this._overlay.height)\n\n context.lineWidth = 5\n context.strokeStyle = 'red'\n context.fillStyle = 'red'\n context.lineJoin = 'round'\n context.lineCap = 'round'\n\n this._image &&\n boundaries\n .map((bounds): Array<{ x: number; y: number }> => {\n return bounds.map(bound => {\n return {\n x: bound.x, //* this._ratio.x,\n y: bound.y // * this._ratio.y\n }\n })\n })\n .forEach((bounds, idx) => {\n context.beginPath()\n\n context.moveTo(bounds[0].x, bounds[0].y)\n context.lineTo(bounds[1].x, bounds[1].y)\n context.lineTo(bounds[2].x, bounds[2].y)\n context.lineTo(bounds[3].x, bounds[3].y)\n context.closePath()\n\n if (this._selections.includes(idx)) {\n context.fill()\n }\n context.stroke()\n })\n\n /* draw trails */\n if (this._trails && this._trails.length > 0) {\n context.lineWidth = 10\n context.strokeStyle = 'blue'\n\n context.beginPath()\n\n this._trails.forEach(trail => {\n if (trail && trail.length > 0) {\n const { x, y } = trail[0]\n context.moveTo(x, y)\n\n trail.slice(1).forEach(point => {\n const { x, y } = point\n context.lineTo(x, y)\n })\n }\n })\n\n context.stroke()\n }\n\n context.restore()\n }\n\n async calculateRatio() {\n const { naturalWidth, naturalHeight, offsetWidth, offsetHeight } = this._img\n const { offsetWidth: overlayWidth, offsetHeight: overlayHeight } = this._overlay\n\n if (!naturalWidth || !naturalHeight) {\n return\n }\n\n this._ratio = {\n x: offsetWidth / naturalWidth,\n y: offsetHeight / naturalHeight\n }\n\n this._overlay.setAttribute('width', String(overlayWidth / this._ratio.x))\n this._overlay.setAttribute('height', String(overlayHeight / this._ratio.y))\n }\n\n async connectedCallback() {\n await super.connectedCallback()\n\n this._resizeObserver = new ResizeObserver(entries => {\n this.calculateRatio()\n this.renderOverlay()\n })\n\n await this.updateComplete\n this._resizeObserver.observe(this._overlay)\n\n this.calculateRatio()\n\n this.addEventListener('mousedown', this.onTrailStart.bind(this) as EventListener)\n this.addEventListener('mouseup', this.onTrailEnd.bind(this) as EventListener)\n this.addEventListener('mousemove', this.onTrail.bind(this) as EventListener)\n this.addEventListener('touchstart', touch2mouse as EventListener)\n this.addEventListener('touchend', touch2mouse as EventListener)\n this.addEventListener('touchmove', touch2mouse as EventListener)\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n\n this._resizeObserver.disconnect()\n }\n\n reset() {\n this._selections = []\n this._trails = []\n this._text = ''\n }\n\n async updated(changes: PropertyValues<this>) {\n if (changes.has('file') || changes.has('result')) {\n this.reset()\n }\n\n if (changes.has('result')) {\n this.result.boundaries = this.result.boundaries.map((bound: { x: number; y: number }[]) => {\n return bound.length > 2 ? bound : convert2To4(bound[0], bound[1])\n })\n }\n\n if (changes.has('file')) {\n this._image = this.file && URL.createObjectURL(this.file)\n if (this._image) {\n requestAnimationFrame(() => {\n URL.revokeObjectURL(this._image)\n })\n\n await this.updateComplete\n this.calculateRatio()\n }\n }\n\n this.renderOverlay()\n }\n\n findIndex(x: number, y: number): number {\n const { boundaries } = this.result\n\n return boundaries.findIndex(path => {\n var result = false\n\n path.forEach((p, idx) => {\n let j = (idx + path.length + 1) % path.length\n\n let x1 = p.x\n let y1 = p.y\n let x2 = path[j].x\n let y2 = path[j].y\n\n if (y1 > y != y2 > y && x < ((x2 - x1) * (y - y1)) / (y2 - y1) + x1) {\n result = !result\n }\n })\n\n return result\n })\n }\n\n updateTrails(point: { x: number; y: number }, started: boolean, attached?: boolean) {\n if (started && !attached) {\n this.reset()\n }\n\n if (started) {\n this._trails.push([])\n }\n\n var trail = this._trails[this._trails.length - 1]\n if (!trail) {\n return\n }\n\n trail.push(point)\n\n this._trails.flat().forEach(({ x, y }) => {\n const idx = this.findIndex(x, y)\n if (idx === -1) {\n return\n }\n\n if (!this._selections.includes(idx)) {\n this._selections.push(idx)\n }\n })\n\n this.requestUpdate()\n }\n\n onTrailStart(e: MouseEvent) {\n const { offsetX: x, offsetY: y, button, shiftKey } = e\n\n if (button !== 0) {\n return\n }\n\n this._tracking = true\n this.updateTrails({ x: x / this._ratio.x, y: y / this._ratio.y }, true, shiftKey)\n }\n\n onTrailEnd(e: MouseEvent) {\n if (!this._tracking) {\n return\n }\n\n this._text = this._selections.map(idx => this.result.texts[idx]).join('')\n\n this.dispatchEvent(\n new CustomEvent('select', {\n detail: this._text\n })\n )\n\n this._tracking = false\n }\n\n onTrail(e: MouseEvent) {\n const { offsetX: x, offsetY: y } = e\n\n if (!this._tracking) {\n return\n }\n\n this.updateTrails({ x: x / this._ratio.x, y: y / this._ratio.y }, false)\n }\n}\n"]}
|