react-image-annotate-master-custom 0.0.1
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/Annotator/index.js +164 -0
- package/Annotator/reducers/combine-reducers.js +14 -0
- package/Annotator/reducers/convert-expanding-line-to-polygon.js +73 -0
- package/Annotator/reducers/fix-twisted.js +4 -0
- package/Annotator/reducers/general-reducer.js +1073 -0
- package/Annotator/reducers/get-active-image.js +27 -0
- package/Annotator/reducers/get-implied-video-regions.js +180 -0
- package/Annotator/reducers/history-handler.js +38 -0
- package/Annotator/reducers/image-reducer.js +20 -0
- package/Annotator/reducers/video-reducer.js +88 -0
- package/ClassSelectionMenu/index.js +135 -0
- package/Crosshairs/index.js +53 -0
- package/DebugSidebarBox/index.js +20 -0
- package/DemoSite/Editor.js +194 -0
- package/DemoSite/ErrorBoundaryDialog.js +64 -0
- package/DemoSite/index.js +69 -0
- package/FullImageSegmentationAnnotator/index.js +7 -0
- package/HighlightBox/index.js +105 -0
- package/HistorySidebarBox/index.js +71 -0
- package/ImageCanvas/index.js +428 -0
- package/ImageCanvas/region-tools.js +165 -0
- package/ImageCanvas/styles.js +31 -0
- package/ImageCanvas/use-mouse.js +180 -0
- package/ImageCanvas/use-project-box.js +27 -0
- package/ImageCanvas/use-wasd-mode.js +62 -0
- package/ImageMask/index.js +133 -0
- package/ImageMask/load-image.js +25 -0
- package/ImageSelectorSidebarBox/index.js +60 -0
- package/KeyframeTimeline/get-time-string.js +27 -0
- package/KeyframeTimeline/index.js +233 -0
- package/KeyframesSelectorSidebarBox/index.js +93 -0
- package/LandingPage/index.js +159 -0
- package/MainLayout/icon-dictionary.js +104 -0
- package/MainLayout/index.js +359 -0
- package/MainLayout/styles.js +25 -0
- package/MainLayout/types.js +0 -0
- package/MainLayout/use-implied-video-regions.js +13 -0
- package/PointDistances/index.js +73 -0
- package/PreventScrollToParents/index.js +51 -0
- package/README.md +101 -0
- package/RegionLabel/index.js +197 -0
- package/RegionLabel/styles.js +48 -0
- package/RegionSelectAndTransformBoxes/index.js +166 -0
- package/RegionSelectorSidebarBox/index.js +248 -0
- package/RegionSelectorSidebarBox/styles.js +53 -0
- package/RegionShapes/index.js +275 -0
- package/RegionTags/index.js +138 -0
- package/SettingsDialog/index.js +52 -0
- package/SettingsProvider/index.js +53 -0
- package/Shortcuts/ShortcutField.js +46 -0
- package/Shortcuts/index.js +133 -0
- package/ShortcutsManager/index.js +155 -0
- package/Sidebar/index.js +69 -0
- package/SidebarBoxContainer/index.js +93 -0
- package/SmallToolButton/index.js +42 -0
- package/TagsSidebarBox/index.js +105 -0
- package/TaskDescriptionSidebarBox/index.js +58 -0
- package/Theme/index.js +30 -0
- package/VideoOrImageCanvasBackground/index.js +151 -0
- package/colors.js +14 -0
- package/hooks/use-event-callback.js +10 -0
- package/hooks/use-exclude-pattern.js +24 -0
- package/hooks/use-load-image.js +26 -0
- package/hooks/use-window-size.js +46 -0
- package/hooks/xpattern.js +1 -0
- package/index.js +3 -0
- package/lib.js +3 -0
- package/package.json +91 -0
- package/stories.js +5 -0
- package/utils/get-from-local-storage.js +7 -0
- package/utils/get-hotkey-help-text.js +9 -0
- package/utils/get-landmarks-with-transform.js +40 -0
- package/utils/set-in-local-storage.js +3 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useRef, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { styled } from "@mui/material/styles";
|
|
4
|
+
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
5
|
+
import useEventCallback from "use-event-callback";
|
|
6
|
+
import { useSettings } from "../SettingsProvider";
|
|
7
|
+
var theme = createTheme();
|
|
8
|
+
var Video = styled("video")(function (_ref) {
|
|
9
|
+
var theme = _ref.theme;
|
|
10
|
+
return {
|
|
11
|
+
zIndex: 0,
|
|
12
|
+
position: "absolute"
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
var StyledImage = styled("img")(function (_ref2) {
|
|
16
|
+
var theme = _ref2.theme;
|
|
17
|
+
return {
|
|
18
|
+
zIndex: 0,
|
|
19
|
+
position: "absolute"
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
var Error = styled("div")(function (_ref3) {
|
|
23
|
+
var theme = _ref3.theme;
|
|
24
|
+
return {
|
|
25
|
+
zIndex: 0,
|
|
26
|
+
position: "absolute",
|
|
27
|
+
left: 0,
|
|
28
|
+
right: 0,
|
|
29
|
+
bottom: 0,
|
|
30
|
+
top: 0,
|
|
31
|
+
backgroundColor: "rgba(255,0,0,0.2)",
|
|
32
|
+
color: "#ff0000",
|
|
33
|
+
fontWeight: "bold",
|
|
34
|
+
whiteSpace: "pre-wrap",
|
|
35
|
+
padding: 50
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
export default (function (_ref4) {
|
|
39
|
+
var imagePosition = _ref4.imagePosition,
|
|
40
|
+
mouseEvents = _ref4.mouseEvents,
|
|
41
|
+
videoTime = _ref4.videoTime,
|
|
42
|
+
videoSrc = _ref4.videoSrc,
|
|
43
|
+
imageSrc = _ref4.imageSrc,
|
|
44
|
+
onLoad = _ref4.onLoad,
|
|
45
|
+
_ref4$useCrossOrigin = _ref4.useCrossOrigin,
|
|
46
|
+
useCrossOrigin = _ref4$useCrossOrigin === void 0 ? false : _ref4$useCrossOrigin,
|
|
47
|
+
videoPlaying = _ref4.videoPlaying,
|
|
48
|
+
onChangeVideoTime = _ref4.onChangeVideoTime,
|
|
49
|
+
onChangeVideoPlaying = _ref4.onChangeVideoPlaying;
|
|
50
|
+
var settings = useSettings();
|
|
51
|
+
var videoRef = useRef();
|
|
52
|
+
var imageRef = useRef();
|
|
53
|
+
|
|
54
|
+
var _useState = useState(),
|
|
55
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
56
|
+
error = _useState2[0],
|
|
57
|
+
setError = _useState2[1];
|
|
58
|
+
|
|
59
|
+
useEffect(function () {
|
|
60
|
+
if (!videoPlaying && videoRef.current) {
|
|
61
|
+
videoRef.current.currentTime = (videoTime || 0) / 1000;
|
|
62
|
+
}
|
|
63
|
+
}, [videoTime]);
|
|
64
|
+
useEffect(function () {
|
|
65
|
+
var renderLoopRunning = false;
|
|
66
|
+
|
|
67
|
+
if (videoRef.current) {
|
|
68
|
+
if (videoPlaying) {
|
|
69
|
+
videoRef.current.play();
|
|
70
|
+
renderLoopRunning = true;
|
|
71
|
+
|
|
72
|
+
if (settings.videoPlaybackSpeed) {
|
|
73
|
+
videoRef.current.playbackRate = parseFloat(settings.videoPlaybackSpeed);
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
videoRef.current.pause();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function checkForNewFrame() {
|
|
81
|
+
if (!renderLoopRunning) return;
|
|
82
|
+
if (!videoRef.current) return;
|
|
83
|
+
var newVideoTime = Math.floor(videoRef.current.currentTime * 1000);
|
|
84
|
+
|
|
85
|
+
if (videoTime !== newVideoTime) {
|
|
86
|
+
onChangeVideoTime(newVideoTime);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (videoRef.current.paused) {
|
|
90
|
+
renderLoopRunning = false;
|
|
91
|
+
onChangeVideoPlaying(false);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
requestAnimationFrame(checkForNewFrame);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
checkForNewFrame();
|
|
98
|
+
return function () {
|
|
99
|
+
renderLoopRunning = false;
|
|
100
|
+
};
|
|
101
|
+
}, [videoPlaying]);
|
|
102
|
+
var onLoadedVideoMetadata = useEventCallback(function (event) {
|
|
103
|
+
var videoElm = event.currentTarget;
|
|
104
|
+
videoElm.currentTime = (videoTime || 0) / 1000;
|
|
105
|
+
if (onLoad) onLoad({
|
|
106
|
+
naturalWidth: videoElm.videoWidth,
|
|
107
|
+
naturalHeight: videoElm.videoHeight,
|
|
108
|
+
videoElm: videoElm,
|
|
109
|
+
duration: videoElm.duration
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
var onImageLoaded = useEventCallback(function (event) {
|
|
113
|
+
var imageElm = event.currentTarget;
|
|
114
|
+
if (onLoad) onLoad({
|
|
115
|
+
naturalWidth: imageElm.naturalWidth,
|
|
116
|
+
naturalHeight: imageElm.naturalHeight,
|
|
117
|
+
imageElm: imageElm
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
var onImageError = useEventCallback(function (event) {
|
|
121
|
+
setError("Could not load image\n\nMake sure your image works by visiting ".concat(imageSrc || videoSrc, " in a web browser. If that URL works, the server hosting the URL may be not allowing you to access the image from your current domain. Adjust server settings to enable the image to be viewed.").concat(!useCrossOrigin ? "" : "\n\nYour image may be blocked because it's not being sent with CORs headers. To do pixel segmentation, browser web security requires CORs headers in order for the algorithm to read the pixel data from the image. CORs headers are easy to add if you're using an S3 bucket or own the server hosting your images.", "\n\n If you need a hand, reach out to the community at universaldatatool.slack.com"));
|
|
122
|
+
});
|
|
123
|
+
var stylePosition = useMemo(function () {
|
|
124
|
+
var width = imagePosition.bottomRight.x - imagePosition.topLeft.x;
|
|
125
|
+
var height = imagePosition.bottomRight.y - imagePosition.topLeft.y;
|
|
126
|
+
return {
|
|
127
|
+
imageRendering: "pixelated",
|
|
128
|
+
left: imagePosition.topLeft.x,
|
|
129
|
+
top: imagePosition.topLeft.y,
|
|
130
|
+
width: isNaN(width) ? 0 : width,
|
|
131
|
+
height: isNaN(height) ? 0 : height
|
|
132
|
+
};
|
|
133
|
+
}, [imagePosition.topLeft.x, imagePosition.topLeft.y, imagePosition.bottomRight.x, imagePosition.bottomRight.y]);
|
|
134
|
+
if (!videoSrc && !imageSrc) return React.createElement(Error, null, "No imageSrc or videoSrc provided");
|
|
135
|
+
if (error) return React.createElement(Error, null, error);
|
|
136
|
+
return React.createElement(ThemeProvider, {
|
|
137
|
+
theme: theme
|
|
138
|
+
}, imageSrc && videoTime === undefined ? React.createElement(StyledImage, Object.assign({}, mouseEvents, {
|
|
139
|
+
src: imageSrc,
|
|
140
|
+
ref: imageRef,
|
|
141
|
+
style: stylePosition,
|
|
142
|
+
onLoad: onImageLoaded,
|
|
143
|
+
onError: onImageError,
|
|
144
|
+
crossOrigin: useCrossOrigin ? "anonymous" : undefined
|
|
145
|
+
})) : React.createElement(Video, Object.assign({}, mouseEvents, {
|
|
146
|
+
ref: videoRef,
|
|
147
|
+
style: stylePosition,
|
|
148
|
+
onLoadedMetadata: onLoadedVideoMetadata,
|
|
149
|
+
src: videoSrc || imageSrc
|
|
150
|
+
})));
|
|
151
|
+
});
|
package/colors.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as muiColors from "@mui/material/colors";
|
|
2
|
+
export var colors = [muiColors.red[500], muiColors.blue[500], muiColors.green[500], muiColors.orange[800], muiColors.brown[500], muiColors.lightGreen[700], muiColors.pink[500], muiColors.purple[500], muiColors.indigo[500], muiColors.teal[500], muiColors.lime[500], muiColors.blueGrey[500]];
|
|
3
|
+
var transparency = 0x88000000;
|
|
4
|
+
|
|
5
|
+
function reverseParseColor(rrggbb) {
|
|
6
|
+
rrggbb = rrggbb.replace("#", "");
|
|
7
|
+
var bbggrr = rrggbb.substr(4, 2) + rrggbb.substr(2, 2) + rrggbb.substr(0, 2);
|
|
8
|
+
return parseInt(bbggrr, 16);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export var colorInts = colors.map(function (c) {
|
|
12
|
+
return (reverseParseColor(c) | transparency) >>> 0;
|
|
13
|
+
});
|
|
14
|
+
export default colors;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useRef, useCallback, useLayoutEffect, useEffect } from "react";
|
|
2
|
+
export default (function (fn) {
|
|
3
|
+
var ref = useRef();
|
|
4
|
+
useLayoutEffect(function () {
|
|
5
|
+
ref.current = fn;
|
|
6
|
+
});
|
|
7
|
+
return useCallback(function () {
|
|
8
|
+
return (0, ref.current).apply(void 0, arguments);
|
|
9
|
+
}, []);
|
|
10
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useRef } from "react";
|
|
2
|
+
import excludePatternSrc from "./xpattern.js";
|
|
3
|
+
export default (function () {
|
|
4
|
+
var excludePattern = useRef(null);
|
|
5
|
+
|
|
6
|
+
if (excludePattern.current === null) {
|
|
7
|
+
excludePattern.current = {
|
|
8
|
+
image: new Image(),
|
|
9
|
+
pattern: null
|
|
10
|
+
};
|
|
11
|
+
var canvas = document.createElement("canvas");
|
|
12
|
+
canvas.width = 100;
|
|
13
|
+
canvas.height = 100;
|
|
14
|
+
var context = canvas.getContext("2d");
|
|
15
|
+
|
|
16
|
+
excludePattern.current.image.onload = function () {
|
|
17
|
+
excludePattern.current.pattern = context.createPattern(excludePattern.current.image, "repeat");
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
excludePattern.current.image.src = excludePatternSrc;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return excludePattern.current.pattern;
|
|
24
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { useRef, useState } from "react";
|
|
3
|
+
export default (function (imageSrc, onImageLoaded) {
|
|
4
|
+
var _useState = useState(false),
|
|
5
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
6
|
+
imageLoaded = _useState2[0],
|
|
7
|
+
changeImageLoaded = _useState2[1];
|
|
8
|
+
|
|
9
|
+
var image = useRef(null);
|
|
10
|
+
|
|
11
|
+
if (image.current === null) {
|
|
12
|
+
image.current = new Image();
|
|
13
|
+
|
|
14
|
+
image.current.onload = function () {
|
|
15
|
+
changeImageLoaded(true);
|
|
16
|
+
if (onImageLoaded) onImageLoaded({
|
|
17
|
+
width: image.current.naturalWidth,
|
|
18
|
+
height: image.current.naturalHeight
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
image.current.src = imageSrc;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return [image.current, imageLoaded];
|
|
26
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { useRafState, useInterval } from "react-use";
|
|
4
|
+
|
|
5
|
+
var useWindowSize = function useWindowSize() {
|
|
6
|
+
var initialWidth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Infinity;
|
|
7
|
+
var initialHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
|
8
|
+
var isClient = typeof window !== "undefined";
|
|
9
|
+
|
|
10
|
+
var _useRafState = useRafState({
|
|
11
|
+
width: isClient ? window.innerWidth : initialWidth,
|
|
12
|
+
height: isClient ? window.innerHeight : initialHeight
|
|
13
|
+
}),
|
|
14
|
+
_useRafState2 = _slicedToArray(_useRafState, 2),
|
|
15
|
+
state = _useRafState2[0],
|
|
16
|
+
setState = _useRafState2[1];
|
|
17
|
+
|
|
18
|
+
useEffect(function () {
|
|
19
|
+
if (!isClient) return;
|
|
20
|
+
|
|
21
|
+
var handler = function handler() {
|
|
22
|
+
setState({
|
|
23
|
+
width: window.innerWidth,
|
|
24
|
+
height: window.innerHeight
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
window.addEventListener("resize", handler);
|
|
29
|
+
return function () {
|
|
30
|
+
window.removeEventListener("resize", handler);
|
|
31
|
+
};
|
|
32
|
+
}, []);
|
|
33
|
+
useInterval(function () {
|
|
34
|
+
if (!isClient) return;
|
|
35
|
+
|
|
36
|
+
if (window.innerWidth !== state.width || window.innerHeight !== state.height) {
|
|
37
|
+
setState({
|
|
38
|
+
width: window.innerWidth,
|
|
39
|
+
height: window.innerHeight
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}, 100);
|
|
43
|
+
return state;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default useWindowSize;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4wMSAxY5oG+lzgAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAAcSURBVAjXY/jPwPCfAQnA+TAGugLcAhhakRUAAK3lEe8m9qZhAAAAAElFTkSuQmCC";
|
package/index.js
ADDED
package/lib.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-image-annotate-master-custom",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@fortawesome/fontawesome-svg-core": "^1.2.12",
|
|
6
|
+
"@fortawesome/free-solid-svg-icons": "^5.6.3",
|
|
7
|
+
"@fortawesome/react-fontawesome": "^0.1.3",
|
|
8
|
+
"@mui/icons-material": "^5.2.1",
|
|
9
|
+
"@mui/material": "^5.2.3",
|
|
10
|
+
"@mui/styles": "^5.2.3",
|
|
11
|
+
"@semantic-release/git": "^9.0.0",
|
|
12
|
+
"autoseg": "^0.0.12",
|
|
13
|
+
"clamp": "^1.0.1",
|
|
14
|
+
"color-alpha": "^1.0.4",
|
|
15
|
+
"get-image-data": "^3.0.1",
|
|
16
|
+
"material-survey": "^2.1.0",
|
|
17
|
+
"mmgc1-cpp": "^1.0.50",
|
|
18
|
+
"moment": "^2.23.0",
|
|
19
|
+
"react": "^17.0.2",
|
|
20
|
+
"react-dom": "^17.0.2",
|
|
21
|
+
"react-full-screen": "^0.3.1",
|
|
22
|
+
"react-hotkeys": "^2.0.0",
|
|
23
|
+
"react-json-view": "^1.19.1",
|
|
24
|
+
"react-markdown": "^4.0.6",
|
|
25
|
+
"react-material-workspace-layout": "^1.0.10",
|
|
26
|
+
"react-monaco-editor": "^0.25.1",
|
|
27
|
+
"react-remove-scroll": "^2.0.4",
|
|
28
|
+
"react-select": "^3.0.8",
|
|
29
|
+
"react-syntax-highlighter": "^12.2.1",
|
|
30
|
+
"react-use": "^13.27.0",
|
|
31
|
+
"react-use-measure": "^2.0.0",
|
|
32
|
+
"seamless-immutable": "^7.1.4",
|
|
33
|
+
"shallow-equal": "^1.2.1",
|
|
34
|
+
"storybook": "^5.3.14",
|
|
35
|
+
"styled-components": "^5.2.1",
|
|
36
|
+
"transformation-matrix-js": "^2.7.6",
|
|
37
|
+
"use-event-callback": "^0.1.0",
|
|
38
|
+
"use-key-hook": "^1.3.0"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"react": "^17.0.0",
|
|
42
|
+
"react-dom": "^17.0.0"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/Novus-Solutions/react-image-annotate-master-custom.git",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/Novus-Solutions/react-image-annotate-master-custom.git"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"start": "react-scripts start",
|
|
51
|
+
"test": "react-scripts test",
|
|
52
|
+
"eject": "react-scripts eject",
|
|
53
|
+
"storybook": "start-storybook -p 9090 -s public",
|
|
54
|
+
"build": "npm run build:babel && cp ./package.json ./dist/package.json && cp ./README.md ./dist/README.md",
|
|
55
|
+
"dist": "npm run build && cd dist && npm publish",
|
|
56
|
+
"build:babel": "NODE_ENV=production babel ./src --ignore \"src/**/*.story.js\" --out-dir=./dist && rm dist/index.js && cp dist/lib.js dist/index.js",
|
|
57
|
+
"build-storybook": "build-storybook",
|
|
58
|
+
"build:gh-pages": "CI=false react-scripts build && mkdir build/demo && cp build/index.html build/demo/index.html",
|
|
59
|
+
"gh-pages": "npm run build:gh-pages && gh-pages -d build",
|
|
60
|
+
"prettier": "prettier --write \"src/**/*.js\"",
|
|
61
|
+
"prettier:test": "prettier --check \"src/**/*.js\""
|
|
62
|
+
},
|
|
63
|
+
"eslintConfig": {
|
|
64
|
+
"extends": "react-app"
|
|
65
|
+
},
|
|
66
|
+
"browserslist": [
|
|
67
|
+
">0.2%",
|
|
68
|
+
"not dead",
|
|
69
|
+
"not ie <= 11",
|
|
70
|
+
"not op_mini all"
|
|
71
|
+
],
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@babel/cli": "^7.2.3",
|
|
74
|
+
"@babel/core": "^7.2.2",
|
|
75
|
+
"@babel/plugin-proposal-optional-chaining": "^7.11.0",
|
|
76
|
+
"@storybook/addon-actions": "^5.3.14",
|
|
77
|
+
"@storybook/addon-links": "^5.3.14",
|
|
78
|
+
"@storybook/addons": "^5.3.14",
|
|
79
|
+
"@storybook/react": "^5.3.14",
|
|
80
|
+
"babel-loader": "^8.0.5",
|
|
81
|
+
"babel-preset-react-app": "^7.0.0",
|
|
82
|
+
"gh-pages": "^2.0.1",
|
|
83
|
+
"prettier": "^2.5.1",
|
|
84
|
+
"raw.macro": "^0.3.0",
|
|
85
|
+
"react-github-btn": "^1.1.1",
|
|
86
|
+
"react-scripts": "^3.4.1"
|
|
87
|
+
},
|
|
88
|
+
"prettier": {
|
|
89
|
+
"semi": false
|
|
90
|
+
}
|
|
91
|
+
}
|
package/stories.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { getApplicationKeyMap } from "react-hotkeys";
|
|
2
|
+
export var getHotkeyHelpText = function getHotkeyHelpText(commandName) {
|
|
3
|
+
var _getApplicationKeyMap, _getApplicationKeyMap2, _getApplicationKeyMap3;
|
|
4
|
+
|
|
5
|
+
var firstSequence = (_getApplicationKeyMap = getApplicationKeyMap()[commandName]) === null || _getApplicationKeyMap === void 0 ? void 0 : (_getApplicationKeyMap2 = _getApplicationKeyMap.sequences) === null || _getApplicationKeyMap2 === void 0 ? void 0 : (_getApplicationKeyMap3 = _getApplicationKeyMap2[0]) === null || _getApplicationKeyMap3 === void 0 ? void 0 : _getApplicationKeyMap3.sequence;
|
|
6
|
+
if (!firstSequence) return "";
|
|
7
|
+
return " (".concat(firstSequence, ")");
|
|
8
|
+
};
|
|
9
|
+
export default getHotkeyHelpText;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
export default (function (_ref) {
|
|
3
|
+
var center = _ref.center,
|
|
4
|
+
scale = _ref.scale,
|
|
5
|
+
landmarks = _ref.landmarks;
|
|
6
|
+
var points = {};
|
|
7
|
+
var _iteratorNormalCompletion = true;
|
|
8
|
+
var _didIteratorError = false;
|
|
9
|
+
var _iteratorError = undefined;
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
for (var _iterator = Object.entries(landmarks)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
13
|
+
var _ref4 = _step.value;
|
|
14
|
+
|
|
15
|
+
var _ref3 = _slicedToArray(_ref4, 2);
|
|
16
|
+
|
|
17
|
+
var keypointId = _ref3[0];
|
|
18
|
+
var defaultPosition = _ref3[1].defaultPosition;
|
|
19
|
+
points[keypointId] = {
|
|
20
|
+
x: defaultPosition[0] * scale + center.x,
|
|
21
|
+
y: defaultPosition[1] * scale + center.y
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
} catch (err) {
|
|
25
|
+
_didIteratorError = true;
|
|
26
|
+
_iteratorError = err;
|
|
27
|
+
} finally {
|
|
28
|
+
try {
|
|
29
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
30
|
+
_iterator.return();
|
|
31
|
+
}
|
|
32
|
+
} finally {
|
|
33
|
+
if (_didIteratorError) {
|
|
34
|
+
throw _iteratorError;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return points;
|
|
40
|
+
});
|