@nyris/nyris-webapp 0.3.4 → 0.3.5
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/build/asset-manifest.json +8 -8
- package/build/index.html +1 -1
- package/build/{precache-manifest.9800bdc87f5a2c5d6d8a5d1a5287598f.js → precache-manifest.bbb31f2ce7710d7eb3175b1b48241d24.js} +8 -8
- package/build/service-worker.js +1 -1
- package/build/static/js/2.4a55bc61.chunk.js +3 -0
- package/build/static/js/{2.29ddd567.chunk.js.LICENSE.txt → 2.4a55bc61.chunk.js.LICENSE.txt} +0 -0
- package/build/static/js/2.4a55bc61.chunk.js.map +1 -0
- package/build/static/js/main.2660f94a.chunk.js +2 -0
- package/build/static/js/main.2660f94a.chunk.js.map +1 -0
- package/package.json +3 -3
- package/src/App.tsx +1 -2
- package/src/Store/Search.ts +39 -66
- package/src/components/DragDropFile.tsx +22 -18
- package/src/modules/LandingPage/index.tsx +59 -83
- package/src/modules/LandingPage/indexNewVersion.tsx +8 -8
- package/src/page/result/index.tsx +47 -97
- package/src/services/Feedback.ts +46 -47
- package/src/services/image.ts +28 -95
- package/src/services/session.ts +9 -12
- package/src/services/types.ts +1 -33
- package/src/types.ts +12 -7
- package/build/static/js/2.29ddd567.chunk.js +0 -3
- package/build/static/js/2.29ddd567.chunk.js.map +0 -1
- package/build/static/js/main.c35ded37.chunk.js +0 -2
- package/build/static/js/main.c35ded37.chunk.js.map +0 -1
- package/src/Store/common.d.ts +0 -10
- package/src/services/findByImage.ts +0 -24
- package/src/services/findRegionsCustom.ts +0 -15
- package/src/services/nyris.ts +0 -123
package/src/Store/common.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type NyrisAppPart = 'start' | 'camera' | 'results';
|
|
2
|
-
export type NyrisFeedbackState = 'hidden' | 'question' | 'positive' | 'negative';
|
|
3
|
-
export type NyrisAction =
|
|
4
|
-
| { type: 'SHOW_START' }
|
|
5
|
-
| { type: 'SHOW_CAMERA' }
|
|
6
|
-
| { type: 'SHOW_RESULTS' }
|
|
7
|
-
| { type: 'SHOW_FEEDBACK' }
|
|
8
|
-
| { type: 'HIDE_FEEDBACK' }
|
|
9
|
-
| { type: 'RESULT_LINK_CLICKED', position: number, url: string}
|
|
10
|
-
| { type: 'RESULT_IMAGE_CLICKED', position: number, url: string}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import NyrisAPI from "@nyris/nyris-api";
|
|
2
|
-
|
|
3
|
-
export const findByImage = async (image: any, options: any, settings: any) => {
|
|
4
|
-
|
|
5
|
-
try {
|
|
6
|
-
const api = new NyrisAPI(settings);
|
|
7
|
-
const {
|
|
8
|
-
results,
|
|
9
|
-
duration,
|
|
10
|
-
requestId,
|
|
11
|
-
categoryPredictions,
|
|
12
|
-
codes,
|
|
13
|
-
} = await api.findByImage(image, options);
|
|
14
|
-
return {
|
|
15
|
-
results,
|
|
16
|
-
duration,
|
|
17
|
-
requestId,
|
|
18
|
-
categoryPredictions,
|
|
19
|
-
codes,
|
|
20
|
-
};
|
|
21
|
-
} catch (error) {
|
|
22
|
-
console.log("error findByImage", error);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ImageSearchOptions,
|
|
3
|
-
Region,
|
|
4
|
-
Result,
|
|
5
|
-
SearchServiceSettings,
|
|
6
|
-
} from "./types";
|
|
7
|
-
// import {canvasToJpgBlob, getElementSize, getThumbSizeArea, toCanvas} from "./nyris";
|
|
8
|
-
import axios, { AxiosInstance } from "axios";
|
|
9
|
-
import {
|
|
10
|
-
canvasToJpgBlob,
|
|
11
|
-
getElementSize,
|
|
12
|
-
getThumbSizeArea,
|
|
13
|
-
toCanvas,
|
|
14
|
-
} from "./nyris";
|
|
15
|
-
|
package/src/services/nyris.ts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import loadImage from "blueimp-load-image";
|
|
2
|
-
import { Crop, WH } from "./types";
|
|
3
|
-
|
|
4
|
-
export function getElementSize(
|
|
5
|
-
elem: HTMLImageElement | HTMLVideoElement | HTMLCanvasElement
|
|
6
|
-
) {
|
|
7
|
-
const img = elem as HTMLImageElement;
|
|
8
|
-
const video = elem as HTMLVideoElement;
|
|
9
|
-
return [
|
|
10
|
-
img.naturalWidth || video.videoWidth || elem.width,
|
|
11
|
-
img.naturalHeight || video.videoHeight || elem.height,
|
|
12
|
-
];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function getThumbSizeArea(
|
|
16
|
-
maxWidth: number,
|
|
17
|
-
maxHeight: number,
|
|
18
|
-
originalWidth: number,
|
|
19
|
-
originalHeight: number
|
|
20
|
-
): WH {
|
|
21
|
-
const targetArea = maxWidth * maxHeight;
|
|
22
|
-
|
|
23
|
-
const aspectRatio = originalWidth / originalHeight;
|
|
24
|
-
const width = Math.sqrt(targetArea * aspectRatio);
|
|
25
|
-
return {
|
|
26
|
-
w: width,
|
|
27
|
-
h: width / aspectRatio,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// TODO get rid of crop type
|
|
32
|
-
export function toCanvas(
|
|
33
|
-
elem: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement,
|
|
34
|
-
newSize?: WH,
|
|
35
|
-
canvas?: HTMLCanvasElement,
|
|
36
|
-
crop?: Crop
|
|
37
|
-
): HTMLCanvasElement {
|
|
38
|
-
let [ow, oh] = getElementSize(elem);
|
|
39
|
-
if (!crop) {
|
|
40
|
-
crop = {
|
|
41
|
-
x: 0,
|
|
42
|
-
y: 0,
|
|
43
|
-
w: ow,
|
|
44
|
-
h: oh,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
const sx = crop.x;
|
|
48
|
-
const sy = crop.y;
|
|
49
|
-
const sw = crop.w;
|
|
50
|
-
const sh = crop.h;
|
|
51
|
-
|
|
52
|
-
const dw = (newSize && newSize.w) || ow;
|
|
53
|
-
const dh = (newSize && newSize.h) || oh;
|
|
54
|
-
|
|
55
|
-
if (!canvas) canvas = document.createElement("canvas");
|
|
56
|
-
|
|
57
|
-
canvas.width = dw;
|
|
58
|
-
canvas.height = dh;
|
|
59
|
-
// @ts-ignore
|
|
60
|
-
canvas.getContext("2d").drawImage(
|
|
61
|
-
elem,
|
|
62
|
-
sx,
|
|
63
|
-
sy,
|
|
64
|
-
sw,
|
|
65
|
-
sh,
|
|
66
|
-
0,
|
|
67
|
-
0, // dx dy
|
|
68
|
-
dw,
|
|
69
|
-
dh
|
|
70
|
-
);
|
|
71
|
-
return canvas;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function canvasToJpgBlob(
|
|
75
|
-
canvas: HTMLCanvasElement,
|
|
76
|
-
quality: number
|
|
77
|
-
): Promise<Blob> {
|
|
78
|
-
return new Promise((resolve, reject) => {
|
|
79
|
-
canvas.toBlob(
|
|
80
|
-
(blob) => {
|
|
81
|
-
if (blob) {
|
|
82
|
-
resolve(blob);
|
|
83
|
-
} else {
|
|
84
|
-
reject();
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
"image/jpeg",
|
|
88
|
-
quality
|
|
89
|
-
);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export const rectToCrop = ({ x1, x2, y1, y2 }: any): Crop => ({
|
|
94
|
-
x: x1,
|
|
95
|
-
y: y1,
|
|
96
|
-
w: x2 - x1,
|
|
97
|
-
h: y2 - y1,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
export function fileOrBlobToCanvas(
|
|
101
|
-
file: File | string
|
|
102
|
-
): Promise<HTMLCanvasElement> {
|
|
103
|
-
return new Promise((resolve, reject) => {
|
|
104
|
-
// File can also be an image element
|
|
105
|
-
loadImage(
|
|
106
|
-
file,
|
|
107
|
-
(data) => {
|
|
108
|
-
const c = data as HTMLCanvasElement;
|
|
109
|
-
if (c) {
|
|
110
|
-
resolve(c);
|
|
111
|
-
} else {
|
|
112
|
-
reject();
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
canvas: true,
|
|
117
|
-
orientation: true,
|
|
118
|
-
crossOrigin: "anonymous",
|
|
119
|
-
}
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
});
|
|
123
|
-
}
|