diff --git a/.github/workflows/labelbee-lint.yml b/.github/workflows/labelbee-lint.yml new file mode 100644 index 000000000..6bc295ff8 --- /dev/null +++ b/.github/workflows/labelbee-lint.yml @@ -0,0 +1,15 @@ +name: lint +on: push +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install modules + run: npm install + - name: Run Bootstrap + run: npm run bootstrap + - name: Build Type + run: npm run build:type + - name: Run ESLint + run: npm run lint \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 26e1392d2..91ad733b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,49 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [1.7.0](https://github.com/open-mmlab/labelbee/compare/v1.6.0...v1.7.0) (2022-06-23) + + +### Features + +* [lb-component] Add TagToolInstanceAdaptor to implement toolInstance ([85cd646](https://github.com/open-mmlab/labelbee/commit/85cd64694638e17efee32fdd841b9be7dd281dbf)) +* [lb-component] Implement keydown event for tagging ([5f441fe](https://github.com/open-mmlab/labelbee/commit/5f441feb0029cbcf704110c183d81dd8c1f67480)) +* [lb-components] Support and export 'VideoPlayer' ([0aea748](https://github.com/open-mmlab/labelbee/commit/0aea748991389933d4d7965af3e21345fffbffa4)) +* [lb-components] VideoTagTool Support i18n on hotkeys ([8216f5d](https://github.com/open-mmlab/labelbee/commit/8216f5dfb8ed0d723ed9aa5c2e15bdbbc4edf682)) +* [lb-demo] Support the use of VideoPlayer ([7ab27c2](https://github.com/open-mmlab/labelbee/commit/7ab27c2df4a794f0a5695768888da1a4a3b574be)) +* Add FileInvalid and FileException components, show operation on videoTagTool ([442318c](https://github.com/open-mmlab/labelbee/commit/442318cf1e38259b8314f538d0e91ada2329168d)) +* Add pageChange add stepChange callback ([ea20140](https://github.com/open-mmlab/labelbee/commit/ea201407655675ae48c7e9bcd21e7e530c3d7b7c)) +* add renderEnhance function ([009a734](https://github.com/open-mmlab/labelbee/commit/009a73498873ff489f0a2f44ad9bf6ca33a4a771)) +* AnntoationView-Polygon adds keypoint showing ([f414dab](https://github.com/open-mmlab/labelbee/commit/f414dab0cec2ce09f14cf7af22272632d9717c17)) +* Implement pushHistory on TagToolInstanceAdaptor ([cadd8c7](https://github.com/open-mmlab/labelbee/commit/cadd8c717e22f598325f5589ad9208862d3a1773)) +* Init result on state while TagToolInstanceAdaptor mounted ([954ba29](https://github.com/open-mmlab/labelbee/commit/954ba293b21c9bf5110ec7d8c6c5bec0ad0dd5bd)) +* PointTool emits messageSuccess when it adsorb edge ([e643dca](https://github.com/open-mmlab/labelbee/commit/e643dca72a7e3bcff45549d63ac3c2af67bb7dc2)) +* PolygonTool add combining operation ([56bb126](https://github.com/open-mmlab/labelbee/commit/56bb126da98965afeb1cad414094fea905b774c4)) +* PolygonTool add cutting operation ([cbc33ac](https://github.com/open-mmlab/labelbee/commit/cbc33ac68b2b66ca5a6b8d091098a77d0daedc6b)) +* Rename Image Error to FileError and replace life cycle fn 'componentWillUnmount' ([3063f7c](https://github.com/open-mmlab/labelbee/commit/3063f7cad8cff6366a209f13ab2b3daca4ba5a06)) +* Support batch data acquisition ([2d26c2d](https://github.com/open-mmlab/labelbee/commit/2d26c2d252bdb4c6b73b016f6833fb2b8d24dfe1)) +* TagToolInstanceAdaptor export fn: 'setValid' and getter 'valid' ([e73ca3c](https://github.com/open-mmlab/labelbee/commit/e73ca3c64cdf46cafbd235494c9e7c84aaeaa8ba)) +* VideoPlayer playPause while video clicked ([c003449](https://github.com/open-mmlab/labelbee/commit/c003449ae7c55428b27abbc7773c98a33da55933)) +* VideoTagToolInstance support exporting videoMetaData on exportData ([1b2166c](https://github.com/open-mmlab/labelbee/commit/1b2166c7b5cf7b756396ca7a681f463d099e29b3)) + + +### Bug Fixes + +* `GetCloestPoint` function needs to be added `hasClosed` ([1581ed1](https://github.com/open-mmlab/labelbee/commit/1581ed1614cd5c43e432afe18dbbfb78748f6748)) +* Click next step jump to the first page ([83a0335](https://github.com/open-mmlab/labelbee/commit/83a033520547dae0d9e57a0a8a338a3c4f2dcfca)) +* fix eslint errors ([f20b3a3](https://github.com/open-mmlab/labelbee/commit/f20b3a32572950665e20e670b1531ea8a3697d31)) +* Fix problems from comment ([145d20a](https://github.com/open-mmlab/labelbee/commit/145d20a7b1afd45521d41eeb88f8122e83e26e4b)) +* Fix the pr error ([4a2fa2b](https://github.com/open-mmlab/labelbee/commit/4a2fa2be649605a0378943e641863b14307d120c)) +* Fix the wrong internationalization issue ([3a78658](https://github.com/open-mmlab/labelbee/commit/3a7865844d4560f4f36bb454adf9a2655e2fa784)) +* PointTool for reference only to display polygons and lines ([b177dd2](https://github.com/open-mmlab/labelbee/commit/b177dd2143ca62754512bb6e0e2607102c44abc0)) +* PointTool is not allowed drawing outside the target when 'drawOutsideTarget' config is false ([2668cd7](https://github.com/open-mmlab/labelbee/commit/2668cd7c5f421b9ae9f8ae9d5c169cdeeb59df43)) +* remove ts-ignore ([9065c34](https://github.com/open-mmlab/labelbee/commit/9065c34421d8cbd152eba760233cf452c31e360f)) +* TagTool doesn't need to rotate ([c20576c](https://github.com/open-mmlab/labelbee/commit/c20576ce64b97f8610ca1810bac94289ce87a61b)) +* Temporarily supports the use of the react AnnotationTool ([004e851](https://github.com/open-mmlab/labelbee/commit/004e851b632f339ee7fe7dd73a2bcde9cfda84d2)) +* Update eslint error ([6941977](https://github.com/open-mmlab/labelbee/commit/6941977ab01476aa764d91fa9b60589fc51853d6)) +* VideoPlayer have error status while src changed ([0bbf25c](https://github.com/open-mmlab/labelbee/commit/0bbf25c4492e59b3d634849290fe65ae729fa438)) +* VideoTag emitEvent after clear result ([865575d](https://github.com/open-mmlab/labelbee/commit/865575da1a0928736f1e61cad588e5bca0d613fa)) + ## [1.6.0](https://github.com/open-mmlab/labelbee/compare/v1.5.0...v1.6.0) (2022-05-16) diff --git a/package.json b/package.json index 3a95a2f00..55ba31051 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,13 @@ "workspaces": [ "packages/*" ], - "version": "1.6.1", + "version": "1.7.0", "scripts": { "start": "lerna run build:type && lerna run --parallel --stream start", "dev": "npm run start", "bootstrap": "lerna bootstrap --no-ci", "build": "lerna run build", + "build:type": "lerna run build:type", "lint": "lerna run --parallel --stream lint", "clean": "lerna clean && rm -rf ./node_modules/ && rm -rf ./packages/**/node_modules && rm -rf ./packages/**/package-lock.json", "version": "lerna version --conventional-graduate --yes", diff --git a/packages/lb-annotation/package.json b/packages/lb-annotation/package.json index 5a3c5e331..e3006c295 100644 --- a/packages/lb-annotation/package.json +++ b/packages/lb-annotation/package.json @@ -1,6 +1,6 @@ { "name": "@labelbee/lb-annotation", - "version": "1.8.0-alpha.0", + "version": "1.8.0", "description": "Annotation tool collection", "keywords": [ "annotation", @@ -90,7 +90,7 @@ "typescript": "^4.2.3" }, "dependencies": { - "@labelbee/lb-utils": "^1.2.0-alpha.0", + "@labelbee/lb-utils": "^1.2.0", "@turf/turf": "5.1.6", "@types/three": "^0.141.0", "color-rgba": "^2.3.0", diff --git a/packages/lb-annotation/src/core/toolOperation/polygonOperation.ts b/packages/lb-annotation/src/core/toolOperation/polygonOperation.ts index d24d1a61f..72b76106e 100644 --- a/packages/lb-annotation/src/core/toolOperation/polygonOperation.ts +++ b/packages/lb-annotation/src/core/toolOperation/polygonOperation.ts @@ -748,7 +748,9 @@ class PolygonOperation extends BasicToolOperation { } case EKeyCode.X: - e.altKey && this.segment(); + if (e.altKey) { + this.segment(); + } break; default: { @@ -1275,6 +1277,8 @@ class PolygonOperation extends BasicToolOperation { case 2: this.isCombined = false; break; + default: + return; } return; diff --git a/packages/lb-annotation/src/utils/tool/PolygonUtils.ts b/packages/lb-annotation/src/utils/tool/PolygonUtils.ts index 9df2dd058..d636be806 100644 --- a/packages/lb-annotation/src/utils/tool/PolygonUtils.ts +++ b/packages/lb-annotation/src/utils/tool/PolygonUtils.ts @@ -1,5 +1,5 @@ -import { ERotateDirection } from '@/constant/annotation'; import { difference, polygon, union } from '@turf/turf'; +import { ERotateDirection } from '@/constant/annotation'; import CommonToolUtils from './CommonToolUtils'; import { IPolygonData, IPolygonPoint } from '../../types/tool/polygon'; import { ELineTypes, SEGMENT_NUMBER } from '../../constant/tool'; @@ -19,12 +19,12 @@ export default class PolygonUtils { // 支持范围hoverPolygonID const axisList = AxisUtils.axisArea(checkPoint, scope); - polygonPoints.forEach((polygon) => { - if (polygon.pointList) { + polygonPoints.forEach((p) => { + if (p.pointList) { axisList.forEach((v) => { - const size = this.calcPolygonSize(polygon.pointList); - if (this.isInPolygon(v, polygon.pointList, lineType) && size < minSize) { - hoverPolygonID = polygon.id; + const size = this.calcPolygonSize(p.pointList); + if (this.isInPolygon(v, p.pointList, lineType) && size < minSize) { + hoverPolygonID = p.id; minSize = size; } }); @@ -237,7 +237,7 @@ export default class PolygonUtils { * @returns */ public static getPolygonByID(polygonList: IPolygonData[], id?: string) { - return polygonList.find((polygon) => polygon.id === id); + return polygonList.find((p) => p.id === id); } public static getHoverEdgeIndex( @@ -502,7 +502,7 @@ export default class PolygonUtils { // 批量对多边形进行减操作 (需要对包裹内部的多边形进行判断) polygonList.forEach((v) => { - const backgroundPolygon = polygon([[...PolygonUtils.concatBeginAndEnd(v.pointList.map((v) => [v.x, v.y]))]]); + const backgroundPolygon = polygon([[...PolygonUtils.concatBeginAndEnd(v.pointList.map((p) => [p.x, p.y]))]]); const diff = difference(selectedPolygon, backgroundPolygon); if (diff) { @@ -511,20 +511,20 @@ export default class PolygonUtils { } }); const resultList = - selectedPolygon?.geometry?.coordinates.map((polygon) => { + selectedPolygon?.geometry?.coordinates.map((p) => { // 多边形需要另外判断 //@ts-ignore if (selectedPolygon?.geometry?.type === 'MultiPolygon') { //@ts-ignore - return polygon[0].reduce(PolygonUtils.deletePolygonLastPoint, []); + return p[0].reduce(PolygonUtils.deletePolygonLastPoint, []); } - return polygon.reduce(PolygonUtils.deletePolygonLastPoint, []); + return p.reduce(PolygonUtils.deletePolygonLastPoint, []); }) ?? []; - return resultList.reduce((acc, pointList) => { - const len = pointList.length; - const newPointList = pointList.filter((point: IPolygonPoint, i: number) => { + return resultList.reduce((acc, pointLists) => { + const len = pointLists.length; + const newPointList = pointLists.filter((point: IPolygonPoint, i: number) => { const nextIndex = (i + 1) % len; - if (AxisUtils.getIsInScope(point, pointList[nextIndex], 1)) { + if (AxisUtils.getIsInScope(point, pointLists[nextIndex], 1)) { // 前后 1 像素之差的点清除 return false; } @@ -538,7 +538,7 @@ export default class PolygonUtils { return [...acc, newPointList]; }, []); } catch (error) { - console.log(error); + console.error(error); } } @@ -551,9 +551,9 @@ export default class PolygonUtils { * @returns */ public static getPolygonPointList(selectedPolygonID: string, polygonList: IPolygonData[]) { - const polygon = polygonList.filter((v) => v.id === selectedPolygonID); - if (polygon[0] && polygon[0].pointList && polygon[0].pointList.length > 0) { - return polygon[0].pointList; + const p = polygonList.find((v) => v.id === selectedPolygonID); + if (p && p.pointList && p.pointList.length > 0) { + return p.pointList; } return []; } @@ -565,7 +565,7 @@ export default class PolygonUtils { * @returns */ public static getWrapPolygonIndex(pointList: IPolygonPoint[], polygonList: IPolygonData[]) { - return polygonList.findIndex((polygon) => PolygonUtils.isPointListInPolygon(pointList, polygon.pointList)); + return polygonList.findIndex((p) => PolygonUtils.isPointListInPolygon(pointList, p.pointList)); } /** @@ -686,14 +686,14 @@ export default class PolygonUtils { const newPolygon = selectedPolygon; if (unionPolygon?.geometry?.coordinates?.length === 1) { unionList.push(combinedPolygon.id); - const pointList = unionPolygon?.geometry.coordinates.map((polygon) => { + const pointList = unionPolygon?.geometry.coordinates.map((p) => { // 多边形需要另外判断 if (unionPolygon?.geometry?.type === 'MultiPolygon') { //@ts-ignore - return polygon[0].reduce(PolygonUtils.deletePolygonLastPoint, []); + return p[0].reduce(PolygonUtils.deletePolygonLastPoint, []); } //@ts-ignore - return polygon.reduce(PolygonUtils.deletePolygonLastPoint, []); + return p.reduce(PolygonUtils.deletePolygonLastPoint, []); })[0]; newPolygon.pointList = pointList; } diff --git a/packages/lb-components/package.json b/packages/lb-components/package.json index 69c27a45c..b6fa77e50 100644 --- a/packages/lb-components/package.json +++ b/packages/lb-components/package.json @@ -1,6 +1,6 @@ { "name": "@labelbee/lb-components", - "version": "1.5.0-alpha.0", + "version": "1.5.0", "description": "Provide a complete library of annotation components", "main": "./dist/index.js", "es": "./es/index.js", @@ -43,8 +43,8 @@ }, "dependencies": { "@ant-design/icons": "^4.6.2", - "@labelbee/lb-annotation": "^1.8.0-alpha.0", - "@labelbee/lb-utils": "^1.2.0-alpha.0", + "@labelbee/lb-annotation": "^1.8.0", + "@labelbee/lb-utils": "^1.2.0", "ahooks": "^3.4.0", "classnames": "^2.3.0", "lodash": "^4.17.21", diff --git a/packages/lb-components/src/components/videoPlayer/TagToolInstanceAdaptor.tsx b/packages/lb-components/src/components/videoPlayer/TagToolInstanceAdaptor.tsx index e2cfd9ade..9f36fd8fb 100644 --- a/packages/lb-components/src/components/videoPlayer/TagToolInstanceAdaptor.tsx +++ b/packages/lb-components/src/components/videoPlayer/TagToolInstanceAdaptor.tsx @@ -44,7 +44,7 @@ export class TagToolInstanceAdaptor extends React.Component< public videoRef?: HTMLVideoElement; public labelSelectedList: number[] = []; - constructor(props: IVideoTagInstanceAdaptorProps) { + public constructor(props: IVideoTagInstanceAdaptorProps) { super(props); this.state = { tagResult: [], diff --git a/packages/lb-components/src/components/videoPlayer/components/controller/index.tsx b/packages/lb-components/src/components/videoPlayer/components/controller/index.tsx index 0b3f52c0a..87d30b5e3 100644 --- a/packages/lb-components/src/components/videoPlayer/components/controller/index.tsx +++ b/packages/lb-components/src/components/videoPlayer/components/controller/index.tsx @@ -62,7 +62,7 @@ const VideoProgress = () => {
-
+
); }; diff --git a/packages/lb-components/src/components/videoPlayer/index.tsx b/packages/lb-components/src/components/videoPlayer/index.tsx index e0b666022..412f5caba 100644 --- a/packages/lb-components/src/components/videoPlayer/index.tsx +++ b/packages/lb-components/src/components/videoPlayer/index.tsx @@ -72,7 +72,7 @@ export class VideoPlayer extends React.Component; public timeInterval?: number; - constructor(props: IVideoPlayerProps) { + public constructor(props: IVideoPlayerProps) { super(props); this.state = { playbackRate: 1, @@ -85,11 +85,11 @@ export class VideoPlayer extends React.Component -1 ? imgList[imgIndex]?.url ?? '' : ''; } @@ -111,7 +111,7 @@ export class VideoPlayer extends React.Component { + public updateNextPlaybackRate = (isForward = true) => { const idx = PLAYBACK_RATES.findIndex((r) => r === this.state.playbackRate); let nextIdx = isForward ? Math.min(idx + 1, PLAYBACK_RATES.length - 1) : Math.max(idx - 1, 0); this.changePlaybackPate(PLAYBACK_RATES[nextIdx]); @@ -173,15 +173,14 @@ export class VideoPlayer extends React.Component { - this.setState( - { - isPlay: false, - }, - this.onVideoStopped, - ); + this.onVideoStopped(); }; public onVideoStopped = () => { + this.setState({ + isPlay: false, + }); + if (this.timeInterval) { clearInterval(this.timeInterval); this.timeInterval = undefined; @@ -212,6 +211,7 @@ export class VideoPlayer extends React.Component { return ( result?.reduce((exitsTags: ITagLabelsArray, res: { result: { [key: string]: string } }) => { tagsSortThruInputList(Object.keys(res.result), inputList).forEach((key) => { - const values = res.result[key]; - const valuesArray = values.split(';'); - valuesArray.forEach((value) => { - const { keyLabel, valueLabel } = findTagLabel(key, value, inputList); - const tagHasAssign = exitsTags.find((i) => i.keyLabel === keyLabel); - if (tagHasAssign) { - tagHasAssign.valuesLabelArray.push(valueLabel); - } else { - exitsTags.push({ keyLabel, valuesLabelArray: [valueLabel] }); - } - }); + const valuesArray = res.result[key]?.split(';'); + findLabelFromValuesArray(valuesArray, key, inputList, exitsTags); }); return exitsTags; }, []) ?? [] @@ -58,6 +49,30 @@ export const result2LabelKey = (result: any[], inputList: any[]) => { } }; +/** + * find label from valuesArray and push to exitsTags + * @param valuesArray + * @param key + * @param inputList + * @param exitsTags + */ +const findLabelFromValuesArray = ( + valuesArray: string[], + key: string, + inputList: any[], + exitsTags: ITagLabelsArray, +) => { + valuesArray.forEach((value) => { + const { keyLabel, valueLabel } = findTagLabel(key, value, inputList); + const tagHasAssign = exitsTags.find((i) => i.keyLabel === keyLabel); + if (tagHasAssign) { + tagHasAssign.valuesLabelArray.push(valueLabel); + } else { + exitsTags.push({ keyLabel, valuesLabelArray: [valueLabel] }); + } + }); +}; + /** * Get key number through keyCode, Such as 49(keycode) => 1(number) * @param {Number} keyCode @@ -81,5 +96,5 @@ export const getKeyCodeNumber = (keyCode: number) => { * @param places * @returns {Number} */ -export const decimalReserved = (num: number, places: number = 2) => +export const decimalReserved = (num: number, places = 2) => typeof num === 'number' ? parseFloat(num.toFixed(places)) : num; diff --git a/packages/lb-components/src/store/annotation/reducer.ts b/packages/lb-components/src/store/annotation/reducer.ts index cdf4dce27..20bcb40a7 100644 --- a/packages/lb-components/src/store/annotation/reducer.ts +++ b/packages/lb-components/src/store/annotation/reducer.ts @@ -209,7 +209,7 @@ export const annotationReducer = ( } const oldResultString = imgList[imgIndex]?.result || ''; - const [, basicImgInfo] = toolInstance?.exportData(); + const [, basicImgInfo] = toolInstance?.exportData() ?? []; const resultWithBasicInfo = composeResultWithBasicImgInfo(oldResultString, basicImgInfo); const newResultString = composeResult( @@ -251,7 +251,7 @@ export const annotationReducer = ( return state; } - const [exportResult] = toolInstance?.exportData(); + const [exportResult] = toolInstance?.exportData() ?? []; let previousResultList = exportResult; diff --git a/packages/lb-components/src/views/MainView/toolFooter/FooterTips/ToolHotKey/index.tsx b/packages/lb-components/src/views/MainView/toolFooter/FooterTips/ToolHotKey/index.tsx index d862e5549..24e13c16a 100644 --- a/packages/lb-components/src/views/MainView/toolFooter/FooterTips/ToolHotKey/index.tsx +++ b/packages/lb-components/src/views/MainView/toolFooter/FooterTips/ToolHotKey/index.tsx @@ -21,7 +21,7 @@ const { EVideoToolName } = cTool; interface IProps { style?: any; - title?: JSX.Element; + title?: React.ReactElement; toolName?: string; } diff --git a/packages/lb-demo/package.json b/packages/lb-demo/package.json index 046fabc81..7f2c0485c 100644 --- a/packages/lb-demo/package.json +++ b/packages/lb-demo/package.json @@ -1,11 +1,11 @@ { "name": "lb-demo", - "version": "1.4.0-alpha.0", + "version": "1.4.0", "private": true, "dependencies": { - "@labelbee/lb-annotation": "^1.8.0-alpha.0", - "@labelbee/lb-components": "^1.5.0-alpha.0", - "@labelbee/lb-utils": "^1.2.0-alpha.0", + "@labelbee/lb-annotation": "^1.8.0", + "@labelbee/lb-components": "^1.5.0", + "@labelbee/lb-utils": "^1.2.0", "three": ">=0.141.0", "@types/three": ">=0.141.0", "@testing-library/jest-dom": "^5.11.4", diff --git a/packages/lb-utils/package.json b/packages/lb-utils/package.json index 7785433b6..8ae35cb06 100644 --- a/packages/lb-utils/package.json +++ b/packages/lb-utils/package.json @@ -1,6 +1,6 @@ { "name": "@labelbee/lb-utils", - "version": "1.2.0-alpha.0", + "version": "1.2.0", "description": "utils for label-bee", "author": "Glenfiddish ", "license": "Apache-2.0",