Skip to content

Commit

Permalink
chore(workspace): merge release
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-Shen committed Oct 29, 2024
2 parents 018e589 + 95efa6c commit 1854fa5
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 39 deletions.
14 changes: 7 additions & 7 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "@labelu/frontend",
"version": "5.3.0-alpha.5",
"version": "5.4.0",
"private": true,
"dependencies": {
"@ant-design/icons": "^4.6.2",
"@labelu/audio-annotator-react": "1.5.3-alpha.1",
"@labelu/components-react": "1.4.3-alpha.1",
"@labelu/image": "1.1.1-alpha.4",
"@labelu/audio-annotator-react": "1.5.3",
"@labelu/components-react": "1.5.0",
"@labelu/image": "1.1.1",
"@labelu/formatter": "1.0.2",
"@labelu/image-annotator-react": "2.1.2-alpha.5",
"@labelu/image-annotator-react": "2.1.2",
"@labelu/interface": "1.3.1",
"@labelu/video-annotator-react": "1.3.5-alpha.1",
"@labelu/video-react": "1.3.4-alpha.1",
"@labelu/video-annotator-react": "1.3.5",
"@labelu/video-react": "1.3.4",
"@tanstack/react-query": "^5.0.0",
"antd": "5.10.1",
"axios": "^1.3.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ const AnnotationRightCorner = ({ noSave, fetchNext, totalSize }: AnnotationRight
),
);

await saveCurrentSample();
// 切换到下一个文件
if (!isLastSample) {
navigateWithSearch(`/tasks/${taskId}/samples/${_.get(samples, `[${sampleIndex + 1}].id`)}`);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"packages/*",
"apps/*"
],
"version": "5.3.0-alpha.5",
"version": "5.4.0",
"scripts": {
"prepare": "husky install",
"build": "pnpm --filter @labelu/utils --filter @labelu/interface --filter @labelu/formatter --filter @labelu/image --filter @labelu/components-react --filter @labelu/image-annotator-react --filter @labelu/audio-react --filter @labelu/video-react --filter @labelu/audio-annotator-react --filter @labelu/video-annotator-react build",
Expand Down
6 changes: 3 additions & 3 deletions packages/audio-annotator-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@labelu/audio-annotator-react",
"version": "1.5.3-alpha.1",
"version": "1.5.3",
"description": "audio annotator for react",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
Expand Down Expand Up @@ -29,9 +29,9 @@
],
"dependencies": {
"lodash.clonedeep": "^4.5.0",
"@labelu/components-react": "1.4.3-alpha.1",
"@labelu/components-react": "1.5.0",
"@labelu/interface": "1.3.1",
"@labelu/audio-react": "1.3.4-alpha.1",
"@labelu/audio-react": "1.3.4",
"polished": "^4.2.2",
"react-hotkeys-hook": "^4.4.1",
"styled-components": "^5.3.6"
Expand Down
4 changes: 2 additions & 2 deletions packages/audio-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@labelu/audio-react",
"version": "1.3.4-alpha.1",
"version": "1.3.4",
"description": "labelu audio annotation component for react",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
Expand Down Expand Up @@ -41,7 +41,7 @@
"vite-tsconfig-paths": "^3.5.0"
},
"dependencies": {
"@labelu/components-react": "1.4.3-alpha.1",
"@labelu/components-react": "1.5.0",
"polished": "^4.2.2",
"react-hotkeys-hook": "^4.4.1",
"styled-components": "^5.3.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/components-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@labelu/components-react",
"version": "1.4.3-alpha.1",
"version": "1.5.0",
"description": "basic react components for labelU",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
Expand Down
5 changes: 4 additions & 1 deletion packages/components-react/src/DraggableModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ export interface DraggableModalRef {
toggleVisibility: (value: boolean) => void;
setPosition: (position: Position) => void;
getModalRef: () => React.RefObject<HTMLDivElement | null>;

getVisibility: () => boolean;
}

const ForwardDraggableModel = (props: Iprops, ref: React.ForwardedRef<DraggableModalRef>) => {
Expand Down Expand Up @@ -163,8 +165,9 @@ const ForwardDraggableModel = (props: Iprops, ref: React.ForwardedRef<DraggableM
},
setPosition: updatePosition,
getModalRef: () => modalRef,
getVisibility: () => isVisible,
}),
[updatePosition],
[updatePosition, isVisible],
);

const bodyStyle = useMemo(() => {
Expand Down
6 changes: 3 additions & 3 deletions packages/image-annotator-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@labelu/image-annotator-react",
"version": "2.1.2-alpha.5",
"version": "2.1.2",
"description": "image annotator for react",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
Expand Down Expand Up @@ -29,8 +29,8 @@
"react"
],
"dependencies": {
"@labelu/components-react": "1.4.3-alpha.1",
"@labelu/image": "1.1.1-alpha.4",
"@labelu/components-react": "1.5.0",
"@labelu/image": "1.1.1",
"@labelu/interface": "1.3.1",
"lodash.clonedeep": "^4.5.0",
"polished": "^4.2.2",
Expand Down
44 changes: 32 additions & 12 deletions packages/image-annotator-react/src/ImageAnnotator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ function ForwardAnnotator(
rotate: currentSample?.meta?.rotate ?? 0,
})
.then(() => {
// 避免重复添加
engine.clearData();

Object.keys(annotationsFromSample).forEach((key) => {
if (TOOL_NAMES.includes(key as ToolName)) {
engine?.loadData(key as ToolName, annotationsFromSample[key as ToolName] as AnnotationToolData<ToolName>);
Expand Down Expand Up @@ -487,6 +490,21 @@ function ForwardAnnotator(
[updateAnnotationsWithGlobal],
);

const onAnnotationDelete = useCallback(
(restAnnotations: AnnotationWithTool[]) => {
const annotationGroupByTool: AllAnnotationMapping = {};

restAnnotations.forEach((item) => {
annotationGroupByTool[item.id] = item;
});

updateAnnotationsWithGlobal(() => {
return annotationGroupByTool;
});
},
[updateAnnotationsWithGlobal],
);

const onAnnotationChange = useCallback(
(_annotation: AnnotationWithTool) => {
updateAnnotationsWithGlobal((pre) => {
Expand Down Expand Up @@ -574,6 +592,20 @@ function ForwardAnnotator(
);

// effects
useEffect(() => {
// 删除标记
engine?.on('delete', (annotation: AnnotationData) => {
onAnnotationDelete(addToolNameToAnnotationData(engine!.getDataByTool()));
setSelectedAnnotation((pre) => {
if (pre?.id === annotation.id) {
return undefined;
}

return pre;
});
});
}, [engine, onAnnotationDelete]);

useEffect(() => {
const _onAnnotationsChange = () => {
onAnnotationsChange(addToolNameToAnnotationData(engine!.getDataByTool()));
Expand All @@ -588,18 +620,6 @@ function ForwardAnnotator(
});
});

// 删除标记
engine?.on('delete', (annotation: AnnotationData) => {
_onAnnotationsChange();
setSelectedAnnotation((pre) => {
if (pre?.id === annotation.id) {
return undefined;
}

return pre;
});
});

// 改变标签
engine?.on('labelChange', (label) => {
_onAnnotationsChange();
Expand Down
12 changes: 11 additions & 1 deletion packages/image-annotator-react/src/Toolbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Toolbar, Tooltip, HotkeyPanel } from '@labelu/components-react';
import { useHotkeys } from 'react-hotkeys-hook';
import styled from 'styled-components';
import type { ToolName } from '@labelu/image';
import { useCallback } from 'react';

import { ReactComponent as PointIcon } from '@/assets/tools/point.svg';
import { ReactComponent as LineIcon } from '@/assets/tools/line.svg';
Expand All @@ -11,6 +12,7 @@ import { ReactComponent as CuboidIcon } from '@/assets/tools/cuboid.svg';
import { useTool } from '@/context/tool.context';
import { useAnnotationCtx } from '@/context/annotation.context';
import { useHistoryCtx } from '@/context/history.context';
import { dragModalRef } from '@/LabelSection';

import ToolStyle from './ToolStyle';
import hotkeysConst from './hotkeys.const';
Expand Down Expand Up @@ -57,11 +59,19 @@ export function AnnotatorToolbar({ right }: IToolbarInEditorProps) {
const { onOrderVisibleChange, orderVisible } = useAnnotationCtx();
const { redo, undo, futureRef, pastRef } = useHistoryCtx();

const handleUndo = useCallback(() => {
if (dragModalRef.current?.getVisibility()) {
return;
}

undo();
}, [undo]);

const handleToolChange = (tool: ToolName) => () => {
engine.switch(tool);
};

useHotkeys('ctrl+z, meta+z', undo, [undo]);
useHotkeys('ctrl+z, meta+z', handleUndo, [handleUndo]);
useHotkeys('ctrl+shift+z, meta+shift+z', redo, [undo]);

return (
Expand Down
2 changes: 1 addition & 1 deletion packages/image/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@labelu/image",
"version": "1.1.1-alpha.4",
"version": "1.1.1",
"description": "Image annotation tool for labelU",
"author": {
"name": "GaryShen",
Expand Down
5 changes: 5 additions & 0 deletions packages/image/src/tools/Rect.tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ export class RectTool extends Tool<RectData, RectStyle, RectToolOptions> {
this.setupShapes();
}

/**
* load 不会清空原有数据,会在原来数据上追加
* NOTE: 如果不希望追加,需要在load之前调用标注器实例的clearData方法
* @param data
*/
public load(data: RectData[]) {
this._data.push(...RectTool.convertToCanvasCoordinates(data));
this.clearDrawing();
Expand Down
8 changes: 4 additions & 4 deletions packages/video-annotator-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@labelu/video-annotator-react",
"version": "1.3.5-alpha.1",
"version": "1.3.5",
"description": "video annotator for react",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
Expand Down Expand Up @@ -29,10 +29,10 @@
"react"
],
"dependencies": {
"@labelu/components-react": "1.4.3-alpha.1",
"@labelu/components-react": "1.5.0",
"@labelu/interface": "1.3.1",
"@labelu/audio-annotator-react": "1.5.3-alpha.1",
"@labelu/video-react": "1.3.4-alpha.1",
"@labelu/audio-annotator-react": "1.5.3",
"@labelu/video-react": "1.3.4",
"polished": "^4.2.2",
"react-hotkeys-hook": "^4.4.1",
"styled-components": "^5.3.6"
Expand Down
4 changes: 2 additions & 2 deletions packages/video-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@labelu/video-react",
"version": "1.3.4-alpha.1",
"version": "1.3.4",
"description": "labelu video annotation component for react",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
Expand Down Expand Up @@ -38,7 +38,7 @@
"vite-tsconfig-paths": "^3.5.0"
},
"dependencies": {
"@labelu/components-react": "1.4.3-alpha.1",
"@labelu/components-react": "1.5.0",
"polished": "^4.2.2",
"rc-tooltip": "^6.0.1",
"react-hotkeys-hook": "^4.4.1",
Expand Down

0 comments on commit 1854fa5

Please sign in to comment.