@digipair/skill-web-ocr 0.91.0-0 → 0.92.0
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/index.cjs.d.ts +1 -0
- package/index.cjs.js +5335 -0
- package/index.esm.js +5330 -0
- package/libs/skill-web-ocr/src/lib/input-ocr-image.element.d.ts +12 -0
- package/libs/skill-web-ocr/src/lib/input-ocr.element.d.ts +16 -0
- package/package.json +5 -21
- package/.swcrc +0 -28
- package/README.md +0 -7
- package/eslint.config.mjs +0 -22
- package/rollup.config.cjs +0 -28
- package/src/lib/input-ocr-image.element.ts +0 -47
- package/src/lib/input-ocr.element.ts +0 -112
- package/src/lib/skill-web-ocr.spec.ts +0 -7
- package/src/lib/tesseract.js.d.ts +0 -1
- package/tsconfig.json +0 -13
- package/tsconfig.lib.json +0 -19
- /package/{src/index.d.ts → index.d.ts} +0 -0
- /package/{src/index.ts → libs/skill-web-ocr/src/index.d.ts} +0 -0
- /package/{src/lib/skill-web-ocr.ts → libs/skill-web-ocr/src/lib/skill-web-ocr.d.ts} +0 -0
- /package/{src/schema.fr.json → schema.fr.json} +0 -0
- /package/{src/schema.json → schema.json} +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
export declare class HiddenElement extends LitElement {
|
|
3
|
+
selector: string;
|
|
4
|
+
language: string;
|
|
5
|
+
required: boolean;
|
|
6
|
+
private _value;
|
|
7
|
+
get value(): string | ArrayBuffer;
|
|
8
|
+
connectedCallback(): void;
|
|
9
|
+
private initialize;
|
|
10
|
+
private analyzeFile;
|
|
11
|
+
render(): TemplateResult;
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
export declare class InputOcrElement extends LitElement {
|
|
3
|
+
label: string;
|
|
4
|
+
language: string;
|
|
5
|
+
accept: string;
|
|
6
|
+
required: boolean;
|
|
7
|
+
private state;
|
|
8
|
+
private _content;
|
|
9
|
+
get content(): string;
|
|
10
|
+
private _value;
|
|
11
|
+
get value(): string | ArrayBuffer;
|
|
12
|
+
static styles: import("lit").CSSResult;
|
|
13
|
+
private loadFile;
|
|
14
|
+
private analyzeFile;
|
|
15
|
+
render(): TemplateResult;
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,28 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digipair/skill-web-ocr",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "dist/libs/skill-web-ocr/index.cjs.js",
|
|
6
|
-
"module": "dist/libs/skill-web-ocr/index.esm.js",
|
|
7
|
-
"types": "dist/libs/skill-web-ocr/index.esm.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
"./package.json": "./libs/skill-web-ocr/package.json",
|
|
10
|
-
".": {
|
|
11
|
-
"development": "./dist/libs/skill-web-ocr/src/index.ts",
|
|
12
|
-
"types": "./dist/libs/skill-web-ocr/index.esm.d.ts",
|
|
13
|
-
"import": "./dist/libs/skill-web-ocr/index.esm.js",
|
|
14
|
-
"default": "./dist/libs/skill-web-ocr/index.cjs.js"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
3
|
+
"version": "0.92.0",
|
|
17
4
|
"keywords": [
|
|
18
5
|
"digipair",
|
|
19
6
|
"web",
|
|
20
7
|
"util"
|
|
21
8
|
],
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"@digipair/engine": "0.91.0-0"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
9
|
+
"dependencies": {},
|
|
10
|
+
"main": "./index.cjs.js",
|
|
11
|
+
"module": "./index.esm.js"
|
|
12
|
+
}
|
package/.swcrc
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"jsc": {
|
|
3
|
-
"target": "es2017",
|
|
4
|
-
"parser": {
|
|
5
|
-
"syntax": "typescript",
|
|
6
|
-
"decorators": true,
|
|
7
|
-
"dynamicImport": true
|
|
8
|
-
},
|
|
9
|
-
"transform": {
|
|
10
|
-
"decoratorMetadata": true,
|
|
11
|
-
"legacyDecorator": true
|
|
12
|
-
},
|
|
13
|
-
"keepClassNames": true,
|
|
14
|
-
"externalHelpers": true,
|
|
15
|
-
"loose": true
|
|
16
|
-
},
|
|
17
|
-
"module": {
|
|
18
|
-
"type": "es6"
|
|
19
|
-
},
|
|
20
|
-
"sourceMaps": true,
|
|
21
|
-
"exclude": [
|
|
22
|
-
"jest.config.ts",
|
|
23
|
-
".*\\.spec.tsx?$",
|
|
24
|
-
".*\\.test.tsx?$",
|
|
25
|
-
"./src/jest-setup.ts$",
|
|
26
|
-
"./**/jest-setup.ts$"
|
|
27
|
-
]
|
|
28
|
-
}
|
package/README.md
DELETED
package/eslint.config.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import baseConfig from '../../eslint.config.mjs';
|
|
2
|
-
|
|
3
|
-
export default [
|
|
4
|
-
...baseConfig,
|
|
5
|
-
{
|
|
6
|
-
files: ['**/*.json'],
|
|
7
|
-
rules: {
|
|
8
|
-
'@nx/dependency-checks': [
|
|
9
|
-
'error',
|
|
10
|
-
{
|
|
11
|
-
ignoredFiles: [
|
|
12
|
-
'{projectRoot}/eslint.config.{js,cjs,mjs}',
|
|
13
|
-
'{projectRoot}/rollup.config.{js,ts,mjs,mts,cjs,cts}',
|
|
14
|
-
],
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
},
|
|
18
|
-
languageOptions: {
|
|
19
|
-
parser: await import('jsonc-eslint-parser'),
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
];
|
package/rollup.config.cjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const { withNx } = require('@nx/rollup/with-nx');
|
|
2
|
-
|
|
3
|
-
module.exports = withNx(
|
|
4
|
-
{
|
|
5
|
-
main: 'libs/skill-web-ocr/src/index.ts',
|
|
6
|
-
outputPath: 'dist/libs/skill-web-ocr',
|
|
7
|
-
tsConfig: 'libs/skill-web-ocr/tsconfig.lib.json',
|
|
8
|
-
compiler: 'swc',
|
|
9
|
-
format: ['esm', "cjs"],
|
|
10
|
-
assets: [
|
|
11
|
-
{
|
|
12
|
-
input: 'libs/skill-web-ocr/',
|
|
13
|
-
glob: 'package.json',
|
|
14
|
-
output: '.'
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
input: 'libs/skill-web-ocr/src/',
|
|
18
|
-
glob: '*.json',
|
|
19
|
-
output: '.'
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
// Provide additional rollup configuration here. See: https://rollupjs.org/configuration-options
|
|
25
|
-
// e.g.
|
|
26
|
-
// output: { sourcemap: true },
|
|
27
|
-
}
|
|
28
|
-
);
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { LitElement, TemplateResult, html } from 'lit';
|
|
2
|
-
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
-
import tesseract from 'tesseract.js/dist/tesseract.esm.min.js';
|
|
4
|
-
|
|
5
|
-
@customElement('digipair-input-ocr-selector')
|
|
6
|
-
export class HiddenElement extends LitElement {
|
|
7
|
-
@property()
|
|
8
|
-
selector!: string;
|
|
9
|
-
|
|
10
|
-
@property()
|
|
11
|
-
language = 'eng';
|
|
12
|
-
|
|
13
|
-
@property()
|
|
14
|
-
required = true;
|
|
15
|
-
|
|
16
|
-
private _value: string | ArrayBuffer = '';
|
|
17
|
-
get value(): string | ArrayBuffer {
|
|
18
|
-
return this._value;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
override connectedCallback(): void {
|
|
22
|
-
super.connectedCallback();
|
|
23
|
-
this.initialize();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
private async initialize(): Promise<void> {
|
|
27
|
-
const img = document.querySelector(this.selector) as HTMLImageElement;
|
|
28
|
-
if (img) {
|
|
29
|
-
this._value = await this.analyzeFile(img);
|
|
30
|
-
this.dispatchEvent(new CustomEvent('change', { detail: { value: this.value } }));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
private async analyzeFile(file: any): Promise<string> {
|
|
35
|
-
const worker = await tesseract.createWorker(this.language);
|
|
36
|
-
const {
|
|
37
|
-
data: { text },
|
|
38
|
-
} = await worker.recognize(file);
|
|
39
|
-
await worker.terminate();
|
|
40
|
-
|
|
41
|
-
return text;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
override render(): TemplateResult {
|
|
45
|
-
return html``;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { LitElement, TemplateResult, css, html } from 'lit';
|
|
2
|
-
import { customElement, property, state } from 'lit/decorators.js';
|
|
3
|
-
import tesseract from 'tesseract.js/dist/tesseract.esm.min.js';
|
|
4
|
-
|
|
5
|
-
@customElement('digipair-input-ocr')
|
|
6
|
-
export class InputOcrElement extends LitElement {
|
|
7
|
-
@property()
|
|
8
|
-
label = 'Upload';
|
|
9
|
-
|
|
10
|
-
@property()
|
|
11
|
-
language = 'eng';
|
|
12
|
-
|
|
13
|
-
@property()
|
|
14
|
-
accept = 'image/*';
|
|
15
|
-
|
|
16
|
-
@property()
|
|
17
|
-
required = true;
|
|
18
|
-
|
|
19
|
-
@state()
|
|
20
|
-
private state = 'unloaded';
|
|
21
|
-
|
|
22
|
-
@state()
|
|
23
|
-
private _content = 'aucun fichier selectionne';
|
|
24
|
-
get content() {
|
|
25
|
-
return this._content;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
private _value: string | ArrayBuffer = '';
|
|
29
|
-
get value(): string | ArrayBuffer {
|
|
30
|
-
return this._value;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static override styles = css`
|
|
34
|
-
.download {
|
|
35
|
-
padding: 10px 15px;
|
|
36
|
-
margin-bottom: 10px;
|
|
37
|
-
line-height: 1.4;
|
|
38
|
-
border: 1px solid var(--digipair-color-primary, #52dfdb);
|
|
39
|
-
color: var(--digipair-color-primary, #52dfdb);
|
|
40
|
-
align-self: flex-start;
|
|
41
|
-
margin-right: auto;
|
|
42
|
-
text-align: center;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.download ui5-icon {
|
|
46
|
-
color: var(--digipair-color-secondary, #52dfdb);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.download.unloaded ui5-icon {
|
|
50
|
-
color: var(--digipair-color-primary, #52dfdb);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.download p {
|
|
54
|
-
text-align: center;
|
|
55
|
-
font-size: 12px;
|
|
56
|
-
margin: 0;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.download.unloaded {
|
|
60
|
-
cursor: pointer;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.download.loaded ui5-icon {
|
|
64
|
-
float: left;
|
|
65
|
-
}
|
|
66
|
-
`;
|
|
67
|
-
|
|
68
|
-
private loadFile() {
|
|
69
|
-
const input = document.createElement('input');
|
|
70
|
-
input.type = 'file';
|
|
71
|
-
input.multiple = false;
|
|
72
|
-
input.accept = this.accept;
|
|
73
|
-
input.onchange = async (event: any) => {
|
|
74
|
-
const files = event.target.files;
|
|
75
|
-
const file = files[0];
|
|
76
|
-
|
|
77
|
-
this.state = 'loading';
|
|
78
|
-
this._value = await this.analyzeFile(file);
|
|
79
|
-
this._content = `> ${file.name}`;
|
|
80
|
-
this.state = 'loaded';
|
|
81
|
-
this.dispatchEvent(new CustomEvent('change', { detail: { value: this.value } }));
|
|
82
|
-
};
|
|
83
|
-
input.click();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
private async analyzeFile(file: any): Promise<string> {
|
|
87
|
-
const worker = await tesseract.createWorker(this.language);
|
|
88
|
-
const {
|
|
89
|
-
data: { text },
|
|
90
|
-
} = await worker.recognize(file);
|
|
91
|
-
await worker.terminate();
|
|
92
|
-
|
|
93
|
-
return text;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
override render(): TemplateResult {
|
|
97
|
-
return html`
|
|
98
|
-
<section
|
|
99
|
-
class="download ${this.state}"
|
|
100
|
-
@click=${() => (['unloaded', 'loaded'].indexOf(this.state) >= 0 ? this.loadFile() : void 0)}
|
|
101
|
-
>
|
|
102
|
-
${this.state === 'loaded'
|
|
103
|
-
? html` <ui5-icon name="attachment"></ui5-icon>
|
|
104
|
-
<p>${this.label}<br />${this._content}</p>`
|
|
105
|
-
: this.state === 'loading'
|
|
106
|
-
? html`<ui5-busy-indicator size="Small" active></ui5-busy-indicator>`
|
|
107
|
-
: html` <ui5-icon name="add-document"></ui5-icon>
|
|
108
|
-
<p>${this.label}</p>`}
|
|
109
|
-
</section>
|
|
110
|
-
`;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare module 'tesseract.js/dist/tesseract.esm.min.js';
|
package/tsconfig.json
DELETED
package/tsconfig.lib.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"rootDir": "src",
|
|
5
|
-
"outDir": "dist",
|
|
6
|
-
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
|
|
7
|
-
"emitDeclarationOnly": true,
|
|
8
|
-
"module": "esnext",
|
|
9
|
-
"moduleResolution": "node",
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"types": ["node"]
|
|
12
|
-
},
|
|
13
|
-
"include": ["src/**/*.ts"],
|
|
14
|
-
"references": [
|
|
15
|
-
{
|
|
16
|
-
"path": "../engine/tsconfig.lib.json"
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|