Skip to content

Commit

Permalink
chore(workspace): merge alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-Shen committed Oct 28, 2024
2 parents 3dbc0d9 + a1d13a5 commit 018e589
Show file tree
Hide file tree
Showing 30 changed files with 105 additions and 41 deletions.
4 changes: 2 additions & 2 deletions apps/frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ search labelu in [Test Pypi](https://test.pypi.org/), to find the right version

```bash
# change version '0.1.220' to the version you need.
pip install -i https://test.pypi.org/simple/ labelu==0.1.220
pip install -i https://test.pypi.org/simple/ labelu==1.0.6a5
labelu --help
labelu --port 8000
```
Expand All @@ -24,4 +24,4 @@ vim vite.config.js
npm run start

open http://localhost:3000/
```
```
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.2.1",
"version": "5.3.0-alpha.5",
"private": true,
"dependencies": {
"@ant-design/icons": "^4.6.2",
"@labelu/audio-annotator-react": "1.5.2",
"@labelu/components-react": "1.4.2",
"@labelu/image": "1.1.0",
"@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/formatter": "1.0.2",
"@labelu/image-annotator-react": "2.1.1",
"@labelu/image-annotator-react": "2.1.2-alpha.5",
"@labelu/interface": "1.3.1",
"@labelu/video-annotator-react": "1.3.4",
"@labelu/video-react": "1.3.3",
"@labelu/video-annotator-react": "1.3.5-alpha.1",
"@labelu/video-react": "1.3.4-alpha.1",
"@tanstack/react-query": "^5.0.0",
"antd": "5.10.1",
"axios": "^1.3.4",
Expand Down
36 changes: 36 additions & 0 deletions apps/frontend/src/assets/svg/mineru.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions apps/frontend/src/components/AppPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Avatar } from 'antd';
import _ from 'lodash';

import { ReactComponent as LabelLLM } from '@/assets/svg/labelllm.svg';
import { ReactComponent as MinorU } from '@/assets/svg/minoru.svg';
import { ReactComponent as MinerU } from '@/assets/svg/mineru.svg';
import { ReactComponent as OpenDataLab } from '@/assets/svg/opendatalab.svg';

import styles from './index.module.css';
Expand Down Expand Up @@ -43,7 +43,7 @@ const apps = [
{ name: 'Github', link: 'https://github.com/opendatalab/MinerU' },
{ name: '在线体验', link: 'https://opendatalab.com/OpenSourceTools/Extractor/PDF' },
],
icon: <MinorU />,
icon: <MinerU />,
description: '一站式开源高质量数据提取工具,支持多格式(PDF/网页/电子书),智能萃取,生成高质量语料',
},
];
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default defineConfig({
host: '0.0.0.0',
proxy: {
'/api': {
target: isOnline ? 'https://labelu.shlab.tech' : 'http://127.0.0.1:8000',
target: 'https://labelu.shlab.tech',
changeOrigin: true,
},
},
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"packages/*",
"apps/*"
],
"version": "5.2.1",
"version": "5.3.0-alpha.5",
"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 Expand Up @@ -44,7 +44,7 @@
"devDependencies": {
"@commitlint/cli": "8.3.5",
"@commitlint/config-conventional": "8.3.4",
"@manypkg/get-packages": "^2.1.0",
"@manypkg/get-packages": "^2.2.2",
"@octokit/rest": "^19.0.7",
"@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/git": "^10.0.1",
Expand Down Expand Up @@ -100,4 +100,4 @@
"gauge": "^2.7.4",
"react-ace": "^10.1.0"
}
}
}
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.2",
"version": "1.5.3-alpha.1",
"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.2",
"@labelu/components-react": "1.4.3-alpha.1",
"@labelu/interface": "1.3.1",
"@labelu/audio-react": "1.3.3",
"@labelu/audio-react": "1.3.4-alpha.1",
"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.3",
"version": "1.3.4-alpha.1",
"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.2",
"@labelu/components-react": "1.4.3-alpha.1",
"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.2",
"version": "1.4.3-alpha.1",
"description": "basic react components for labelU",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
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.1",
"version": "2.1.2-alpha.5",
"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.2",
"@labelu/image": "1.1.0",
"@labelu/components-react": "1.4.3-alpha.1",
"@labelu/image": "1.1.1-alpha.4",
"@labelu/interface": "1.3.1",
"lodash.clonedeep": "^4.5.0",
"polished": "^4.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/image-annotator-react/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @labelu/video-annotator-react
# @labelu/image-annotator-react

[![npm](https://img.shields.io/npm/v/%40labelu/image-annotator-react.svg)](https://www.npmjs.com/package/@labelu/image-annotator-react)

Expand Down
6 changes: 6 additions & 0 deletions packages/image-annotator-react/src/ImageAnnotator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@ function ForwardAnnotator(
imageAnnotations![toolName]!.push(_item as AnnotationDataInUI);
}
});

Object.keys(imageAnnotations).forEach((key) => {
engine?.loadData(key as ToolName, imageAnnotations[key as ToolName] as AnnotationToolData<ToolName>);
});
},
[engine],
);
Expand Down Expand Up @@ -415,6 +419,8 @@ function ForwardAnnotator(
onUndo: onRedoUndo,
});

console.log('annotationsWithGlobal', annotationsWithGlobal);

const onAnnotationClear = useCallback(() => {
engine?.clearData();
updateAnnotationsWithGlobal(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Image annotation engine for LabelU

Try it out at [opendatalab.github.io/labelU-Kit/](https://opendatalab.github.io/labelU-Kit/image)
Try it out at [opendatalab.github.io/labelU-Kit/](https://opendatalab.github.io/labelU-Kit/#/image)

## Usage

Expand Down
3 changes: 2 additions & 1 deletion packages/image/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
"author": "",
"license": "ISC",
"devDependencies": {
"typescript": "4.8.4",
"@labelu/image": "^1.1.0",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "4.8.4",
"vite": "^4.4.9"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/image/example/readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# StackBlitz Example

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/opendatalab/labelU-Kit/tree/website/packages/audio-react/example)
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/opendatalab/labelU-Kit/tree/main/packages/image/example)
1 change: 0 additions & 1 deletion packages/image/example/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default defineConfig({
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
'@labelu/image': resolve(__dirname, '../src'),
},
},
});
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.0",
"version": "1.1.1-alpha.4",
"description": "Image annotation tool for labelU",
"author": {
"name": "GaryShen",
Expand Down
7 changes: 7 additions & 0 deletions packages/image/src/core/Axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,13 @@ export class Axis {
eventEmitter.emit(EInternalEvent.AxisChange, e);
};

public resetOffset() {
this._distanceX = 0;
this._distanceY = 0;
this._startPanPoint = null;
this._startMovePoint = null;
}

/**
* 根据图片的初始位置和缩放比例,计算在画布上的精确位置
*
Expand Down
1 change: 1 addition & 0 deletions packages/image/src/drafts/ClosedSpline.draft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class DraftPolygonCurve extends Draft<PolygonData, Line | Point | any, Li

this._setupShapes();
this.onMouseUp(this._onMouseUp);
this.finishSetup();
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/image/src/drafts/Cuboid.draft/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export class DraftCuboid extends Draft<CuboidData, ControllerEdge | Point | Line

this._setupShapes();
this.onMouseUp(this._onMouseUp);
this.finishSetup();
}

/**
Expand Down
13 changes: 11 additions & 2 deletions packages/image/src/drafts/Draft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class Draft<

// 应该让草稿内的图形对象先于草稿对象监听鼠标事件
// TODO:模仿DOM的事件设计冒泡机制,处理重叠的图形鼠标事件
setTimeout(() => {
this.on('setup', () => {
eventEmitter.on(EInternalEvent.LeftMouseDown, this._handleMouseDown);
eventEmitter.on(EInternalEvent.MouseMove, this._handleMouseMove);
eventEmitter.on(EInternalEvent.LeftMouseUp, this._handleLeftMouseUp);
Expand Down Expand Up @@ -180,6 +180,10 @@ export class Draft<
private _handleRightMouseUp = (e: MouseEvent) => {
const isUnderCursor = this.isUnderCursor({ x: e.offsetX, y: e.offsetY });

/**
* 因为清除isMoved是异步的
* see https://github.com/opendatalab/labelU-Kit/blob/main/packages/image/src/core/Axis.ts#L230
*/
if (!isUnderCursor && !axis?.isMoved) {
this.group.emit(EInternalEvent.UnSelect, e, this);
}
Expand Down Expand Up @@ -214,6 +218,10 @@ export class Draft<
return (this._serializeData?.shapes?.map(loop) as AxisPoint[] | AxisPoint[][]) ?? [];
}

public finishSetup() {
this.emit('setup');
}

public onMove(handler: MouseEventHandler) {
this._onMoveHandlers.push(handler);
}
Expand Down Expand Up @@ -342,7 +350,8 @@ export class Draft<
this.data = null as any;
this.group.destroy();
this.clearHandlers();

axis?.resetOffset();
this.removeAllListeners();
eventEmitter.off(EInternalEvent.LeftMouseDown, this._handleMouseDown);
eventEmitter.off(EInternalEvent.MouseMove, this._handleMouseMove);
eventEmitter.off(EInternalEvent.LeftMouseUp, this._handleLeftMouseUp);
Expand Down
1 change: 1 addition & 0 deletions packages/image/src/drafts/Line.draft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class DraftLine extends Draft<LineData, Line | Point, LineStyle | PointSt
this._createSelection();

eventEmitter.on(EInternalEvent.KeyUp, this._onKeyUp);
this.finishSetup();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/image/src/drafts/Point.draft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export class DraftPoint extends Draft<PointData, Point | ShapeText, PointStyle>
this.config = config;

this._setupShapes();

this.onMouseUp(this._onMouseUp);
this.finishSetup();
}

private _setupShapes() {
Expand Down
1 change: 1 addition & 0 deletions packages/image/src/drafts/Polygon.draft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export class DraftPolygon extends Draft<PolygonData, Polygon | Point | Line, Pol

eventEmitter.on(EInternalEvent.KeyDown, this._onKeyDown);
eventEmitter.on(EInternalEvent.KeyUp, this._onKeyUp);
this.finishSetup();
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/image/src/drafts/Rect.draft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class DraftRect extends Draft<RectData, ControllerEdge | Point | Rect, Re

this._setupShapes();
this.onMouseUp(this._onMouseUp);
this.finishSetup();
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/image/src/drafts/Spline.draft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class DraftLineCurve extends Draft<LineData, Line | Point | any, LineStyl

this._setupShapes();
this.onMouseUp(this._onMouseUp);
this.finishSetup();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/image/src/shapes/Group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class Group<T extends Shape<Style>, Style> {

private _onAxisChange = () => {
// 组合在图形之后创建,所以需要延迟一帧更新
setTimeout(() => {
Promise.resolve().then(() => {
this._updateBBox()._updateRBush();
});
};
Expand Down
2 changes: 1 addition & 1 deletion packages/image/src/shapes/Shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class Shape<Style> {
},
};

private _bindEvents() {
private async _bindEvents() {
eventEmitter.on(EInternalEvent.AxisChange, this.update);
eventEmitter.on(EInternalEvent.LeftMouseUp, this.update);
}
Expand Down
Loading

0 comments on commit 018e589

Please sign in to comment.