repo stringlengths 7 64 | file_url stringlengths 81 338 | file_path stringlengths 5 257 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:25:31 2026-01-05 01:50:38 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/tools/Tool.ts | packages/image/src/tools/Tool.ts | import { type Attribute, type ILabel } from '@labelu/interface';
import cloneDeep from 'lodash.clonedeep';
import type { RelationData } from '@/annotations/Relation.annotation';
import type { Annotation } from '../annotations/Annotation';
import type { ToolName, BasicImageAnnotation, EditType, AnyTool } from '../inte... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/tools/Polygon.tool.ts | packages/image/src/tools/Polygon.tool.ts | import cloneDeep from 'lodash.clonedeep';
import Color from 'color';
import uid from '@/utils/uid';
import type { BasicToolParams } from './Tool';
import { Tool } from './Tool';
import { AnnotationPolygon } from '../annotations';
import type { AxisPoint, PolygonStyle } from '../shapes';
import { Spline, ClosedSpline,... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/tools/Tool.decorator.ts | packages/image/src/tools/Tool.decorator.ts | import cloneDeep from 'lodash.clonedeep';
import { ControllerPoint } from '@/drafts/ControllerPoint';
import { ControllerEdge } from '@/drafts/ControllerEdge';
import { axis, eventEmitter, monitor } from '../singletons';
import { EInternalEvent } from '../enums';
import type { BasicImageAnnotation } from '../interfac... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/tools/Point.tool.ts | packages/image/src/tools/Point.tool.ts | import cloneDeep from 'lodash.clonedeep';
import uid from '@/utils/uid';
import { EInternalEvent } from '../enums';
import type { PointStyle } from '../shapes/Point.shape';
import { Point } from '../shapes/Point.shape';
import type { BasicToolParams } from './Tool';
import { Tool } from './Tool';
import type { PointD... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/tools/Cuboid.tool.ts | packages/image/src/tools/Cuboid.tool.ts | import cloneDeep from 'lodash.clonedeep';
import uid from '@/utils/uid';
import type { BasicToolParams } from './Tool';
import { Tool } from './Tool';
import type { CuboidData, CuboidStyle } from '../annotations';
import { Annotation, AnnotationCuboid } from '../annotations';
import type { AxisPoint } from '../shapes... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/tools/Line.tool.ts | packages/image/src/tools/Line.tool.ts | import cloneDeep from 'lodash.clonedeep';
import uid from '@/utils/uid';
import type { LineStyle } from '../shapes/Line.shape';
import { Line } from '../shapes/Line.shape';
import type { BasicToolParams } from './Tool';
import { Tool } from './Tool';
import type { LineData, PointItem } from '../annotations';
import {... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/tools/index.ts | packages/image/src/tools/index.ts | export * from './Cuboid.tool';
export * from './Polygon.tool';
export * from './Rect.tool';
export * from './Line.tool';
export * from './Point.tool';
export * from './Relation.tool';
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/tools/Relation.tool.ts | packages/image/src/tools/Relation.tool.ts | import cloneDeep from 'lodash.clonedeep';
import uid from '@/utils/uid';
import type { RelationData, ValidAnnotationType } from '@/annotations/Relation.annotation';
import { DraftRelation } from '@/drafts/Relation.draft';
import type { ToolName } from '@/interface';
import type { AxisPoint } from '@/shapes';
import { ... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/annotations/Annotation.ts | packages/image/src/annotations/Annotation.ts | import type { Line } from '../shapes';
import type { BasicImageAnnotation, ToolName } from '../interface';
import { Group } from '../shapes/Group';
import { eventEmitter, monitor } from '../singletons';
import { DEFAULT_LABEL_COLOR } from '../constant';
import { DomPortal } from '../core/DomPortal';
import { EInternalE... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/annotations/Cuboid.annotation.ts | packages/image/src/annotations/Cuboid.annotation.ts | import Color from 'color';
import type { ILabel } from '@labelu/interface';
import uid from '@/utils/uid';
import { DomPortal } from '@/core/DomPortal';
import type { BasicImageAnnotation } from '../interface';
import type { AnnotationParams } from './Annotation';
import { Annotation } from './Annotation';
import { t... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/annotations/Relation.annotation.ts | packages/image/src/annotations/Relation.annotation.ts | import type { ILabel } from '@labelu/interface';
import Color from 'color';
import uid from '@/utils/uid';
import type { BasicImageAnnotation } from '../interface';
import type { AnnotationParams } from './Annotation';
import { Annotation } from './Annotation';
import type { LineStyle } from '../shapes/Line.shape';
i... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/annotations/Rect.annotation.ts | packages/image/src/annotations/Rect.annotation.ts | import type { ILabel } from '@labelu/interface';
import Color from 'color';
import uid from '@/utils/uid';
import type { BasicImageAnnotation } from '../interface';
import type { AnnotationParams } from './Annotation';
import { Annotation } from './Annotation';
import { Rect, type RectStyle } from '../shapes/Rect.sha... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/annotations/Point.annotation.ts | packages/image/src/annotations/Point.annotation.ts | import type { ILabel } from '@labelu/interface';
import Color from 'color';
import uid from '@/utils/uid';
import { DomPortal } from '@/core/DomPortal';
import type { BasicImageAnnotation } from '../interface';
import type { AnnotationParams } from './Annotation';
import { Annotation } from './Annotation';
import { P... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/annotations/Line.annotation.ts | packages/image/src/annotations/Line.annotation.ts | import type { ILabel } from '@labelu/interface';
import Color from 'color';
import { DomPortal } from '@/core/DomPortal';
import type { BasicImageAnnotation } from '../interface';
import type { AnnotationParams } from './Annotation';
import { Annotation } from './Annotation';
import type { LineStyle } from '../shapes... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/annotations/Polygon.annotation.ts | packages/image/src/annotations/Polygon.annotation.ts | import cloneDeep from 'lodash.clonedeep';
import type { ILabel } from '@labelu/interface';
import Color from 'color';
import uid from '@/utils/uid';
import { DomPortal } from '@/core/DomPortal';
import type { BasicImageAnnotation } from '../interface';
import type { AnnotationParams } from './Annotation';
import { An... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/annotations/index.ts | packages/image/src/annotations/index.ts | import { AnnotationCuboid } from './Cuboid.annotation';
import { AnnotationLine } from './Line.annotation';
import { AnnotationPoint } from './Point.annotation';
import { AnnotationPolygon } from './Polygon.annotation';
import { AnnotationRect } from './Rect.annotation';
import { AnnotationRelation } from './Relation.a... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/annotations/Label.base.ts | packages/image/src/annotations/Label.base.ts | import type { AttributeOption, ILabel } from '@labelu/interface';
import { DEFAULT_LABEL_COLOR, DEFAULT_LABEL_TEXT, DEFAULT_LABEL_VALUE } from '../constant';
/**
* Label 基类
*/
export class LabelBase {
static DEFAULT_COLOR = DEFAULT_LABEL_COLOR;
static DEFAULT_LABEL_TEXT = DEFAULT_LABEL_TEXT;
static DEFAULT_... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/utils/mapValues.ts | packages/image/src/utils/mapValues.ts | export default function mapValues<T extends Record<string, any>, U>(
obj: T,
fn: (value: T[keyof T]) => U,
): { [K in keyof T]: U } {
const result: { [K in keyof T]?: U } = {};
Object.keys(obj).forEach((key) => {
result[key as keyof T] = fn(obj[key as keyof T]);
});
return result as { [K in keyof T]: ... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/utils/uid.ts | packages/image/src/utils/uid.ts | export default function uid() {
return Math.random().toString(36).slice(2);
}
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/singletons/annotationConfig.ts | packages/image/src/singletons/annotationConfig.ts | import type { AnnotatorOptions } from '@/core/AnnotatorConfig';
import AnnotatorConfig from '@/core/AnnotatorConfig';
let config: AnnotatorConfig | null = null;
export function createConfig(params: AnnotatorOptions) {
config = new AnnotatorConfig(params);
return config;
}
export { config };
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/singletons/rbush.ts | packages/image/src/singletons/rbush.ts | import { CustomRBush } from '../core/CustomRBush';
/**
* 以 R-Tree 为基础的空间索引
* 使用 rbush,用于吸附和高亮等交互
*
* @see https://github.com/mourner/rbush#readme
*/
export const rbush = new CustomRBush();
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/singletons/axis.ts | packages/image/src/singletons/axis.ts | import type { AxisParams } from '../core/Axis';
import { Axis } from '../core/Axis';
let axis: Axis | null = null;
export function createAxis(params: AxisParams) {
axis = new Axis(params);
return axis;
}
export { axis };
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/singletons/monitor.ts | packages/image/src/singletons/monitor.ts | import type { MonitorOption } from '../core/Monitor';
import { Monitor } from '../core/Monitor';
let monitor: Monitor | null = null;
export function createMonitor(canvas: HTMLCanvasElement, options: MonitorOption) {
monitor = new Monitor(canvas, options);
return monitor;
}
export { monitor };
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/singletons/cursorManager.ts | packages/image/src/singletons/cursorManager.ts | import { CursorManager } from '@/core/CursorManager';
import type { AxisPoint } from '@/shapes';
let cursorManager: CursorManager | null = null;
export function createCursorManager(container: HTMLDivElement | null, coordinate: AxisPoint, color?: string) {
cursorManager = new CursorManager(container, coordinate, col... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/singletons/index.ts | packages/image/src/singletons/index.ts | export * as eventEmitter from './eventEmitter';
export * from './rbush';
export * from './axis';
export * from './monitor';
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/singletons/eventEmitter.ts | packages/image/src/singletons/eventEmitter.ts | import EventEmitter from 'eventemitter3';
import type { EInternalEvent } from '../enums';
export type EventName =
| EInternalEvent
| 'hover'
| 'move'
| 'change'
| 'zoom'
| 'select'
| 'unselect'
| 'add'
| 'delete'
| 'relatedRelationDelete'
| 'clear'
| 'load'
| 'labelChange'
| 'attributesCha... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/core/BackgroundRenderer.ts | packages/image/src/core/BackgroundRenderer.ts | import type { RendererOptions } from './Renderer';
import { Renderer } from './Renderer';
import { axis, eventEmitter } from '../singletons';
import type { AxisPoint } from '../shapes';
import { DEFAULT_BACKGROUND_COLOR } from '../constant';
const ImageProperties = ['contrast', 'saturation', 'brightness'] as const;
e... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/core/CursorManager.ts | packages/image/src/core/CursorManager.ts | import type { AxisPoint } from '@/shapes';
import { CrossCursor, Cursor } from '@/shapes';
import { DEFAULT_LABEL_COLOR } from '../constant';
export type CursorType =
| 'default'
| 'grab'
| 'grabbing'
| 'move'
| 'not-allowed'
| 'n-resize'
| 'e-resize'
| 's-resize'
| 'w-resize'
| 'ne-resize'
| 'n... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/core/Axis.ts | packages/image/src/core/Axis.ts | import type { BBox } from 'rbush';
import { cursorManager } from '@/singletons/cursorManager';
import { config } from '@/singletons/annotationConfig';
import type { AxisPoint } from '../shapes/Point.shape';
import { Ticker } from './Ticker';
import { EInternalEvent } from '../enums';
import * as eventEmitter from '..... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/core/Layer.ts | packages/image/src/core/Layer.ts | export class Layer {}
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/core/DomPortal.ts | packages/image/src/core/DomPortal.ts | import { EInternalEvent } from '../enums';
import { axis, eventEmitter } from '../singletons';
import type { AllShape } from '../shapes/types';
interface DomPortalPosition {
x: number;
y: number;
rotate?: number;
}
export interface DomPortalParams {
rotate?: number;
order?: number;
getPosition?: (shape: A... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/core/Monitor.ts | packages/image/src/core/Monitor.ts | import { config } from '@/singletons/annotationConfig';
import { EInternalEvent } from '../enums';
import { eventEmitter, rbush } from '../singletons';
import type { AnnotationShape, AnnotationTool, GroupInAnnotation, ToolName } from '../interface';
import { Group } from '../shapes';
const keyEventMapping = {
Space... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/core/Ticker.ts | packages/image/src/core/Ticker.ts | export class Ticker {
private _fps: number;
private _interval: number;
private _lastTick: number;
private _rafId: number | null = null;
private _shouldUpdate: boolean;
private _tickHandler: () => void;
/**
* constructor
* @param tickHandler 每一帧执行的函数
* @param fps 默认60
*/
constructor(tickHand... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/core/Renderer.ts | packages/image/src/core/Renderer.ts | import EventEmitter from 'eventemitter3';
export interface RendererOptions {
container: HTMLElement;
width: number;
height: number;
zIndex: number;
}
export class Renderer extends EventEmitter {
public ratio: number = 1;
public options: RendererOptions;
public canvas: HTMLCanvasElement = document.crea... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/core/AnnotatorConfig.ts | packages/image/src/core/AnnotatorConfig.ts | import type { EditType, ToolName } from '@/interface';
import type {
CuboidToolOptions,
LineToolOptions,
PointToolOptions,
PolygonToolOptions,
RectToolOptions,
RelationToolOptions,
} from '@/tools';
export interface AnnotatorOptions {
container: HTMLDivElement;
width: number;
height: number;
lin... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/core/CustomRBush.ts | packages/image/src/core/CustomRBush.ts | import type { BBox } from 'rbush';
import RBush from 'rbush';
import uid from '@/utils/uid';
import type { AllShape } from '@/shapes/types';
import type { AxisPoint, Shape } from '../shapes';
import { Line, Point, ShapeText } from '../shapes';
import type { Group } from '../shapes/Group';
import { axis, eventEmitter ... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/shapes/ClosedSpline.ts | packages/image/src/shapes/ClosedSpline.ts | import Color from 'color';
import cloneDeep from 'lodash.clonedeep';
import { Shape } from './Shape';
import type { AxisPoint } from './Point.shape';
import { axis } from '../singletons';
import type { PolygonParams, PolygonStyle } from './Polygon.shape';
import { DEFAULT_LABEL_COLOR } from '../constant';
export inte... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/shapes/Spline.shape.ts | packages/image/src/shapes/Spline.shape.ts | import cloneDeep from 'lodash.clonedeep';
import { Shape } from './Shape';
import type { AxisPoint } from './Point.shape';
import type { LineParams, LineStyle } from './Line.shape';
import { axis } from '../singletons';
import { DEFAULT_LABEL_COLOR } from '../constant';
export interface CurveParams extends LineParams... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/shapes/Rect.shape.ts | packages/image/src/shapes/Rect.shape.ts | import cloneDeep from 'lodash.clonedeep';
import { DEFAULT_LABEL_COLOR } from '../constant';
import { axis } from '../singletons';
import type { AxisPoint } from './Point.shape';
import { Shape } from './Shape';
export interface RectStyle {
/**
* 边框颜色
*
* @default #999
*/
stroke?: string;
/**
* ... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/shapes/Point.shape.ts | packages/image/src/shapes/Point.shape.ts | import cloneDeep from 'lodash.clonedeep';
import { DEFAULT_LABEL_COLOR } from '../constant';
import { Shape } from './Shape';
export interface AxisPoint {
x: number;
y: number;
}
export interface PointStyle {
/**
* 点边框颜色
*
* @default #999
*/
stroke?: string;
/**
* 点边框宽度
*
* @default 0... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/shapes/Group.ts | packages/image/src/shapes/Group.ts | import EventEmitter from 'eventemitter3';
import type { BBox } from 'rbush';
import { EInternalEvent } from '../enums';
import type { RBushItem } from '../core/CustomRBush';
import { eventEmitter, rbush } from '../singletons';
import type { PointStyle, AxisPoint } from './Point.shape';
import { ShapeText } from './Tex... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/shapes/Text.shape.ts | packages/image/src/shapes/Text.shape.ts | import cloneDeep from 'lodash.clonedeep';
import { Shape } from './Shape';
import type { AxisPoint } from './Point.shape';
import { DEFAULT_LABEL_COLOR } from '../constant';
export interface TextStyle {
/**
* 字号设置
*
* @default 14
*/
fontSize?: number;
/**
* 字体
*
* @default Arial
*/
fo... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/shapes/CrossCursor.shape.ts | packages/image/src/shapes/CrossCursor.shape.ts | import { DEFAULT_LABEL_COLOR } from '../constant';
export interface CursorStyle {
/** 线条颜色 */
stroke?: string;
/** 线条宽度 */
strokeWidth?: number;
fill?: string;
}
export interface CursorParams {
/** 起始点x坐标 */
x: number;
/** 起始点y坐标 */
y: number;
/** 线条样式 */
style?: CursorStyle;
}
const dpr = ... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/shapes/Polygon.shape.ts | packages/image/src/shapes/Polygon.shape.ts | import cloneDeep from 'lodash.clonedeep';
import { Shape } from './Shape';
import type { AxisPoint } from './Point.shape';
import { isPointInPolygon } from './math.util';
import type { LineStyle } from './Line.shape';
import { DEFAULT_LABEL_COLOR } from '../constant';
export interface PolygonStyle extends LineStyle {... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/shapes/Line.shape.ts | packages/image/src/shapes/Line.shape.ts | import cloneDeep from 'lodash.clonedeep';
import { Shape } from './Shape';
import { getDistanceToLine } from './math.util';
import { DEFAULT_LABEL_COLOR } from '../constant';
import type { AxisPoint } from './Point.shape';
export interface LineStyle {
stroke?: string;
strokeWidth?: number;
opacity?: number;
/... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/shapes/types.ts | packages/image/src/shapes/types.ts | import type { Rect, Line, Polygon, Point, Spline, ClosedSpline } from './index';
export type AllShape = Rect | Line | Polygon | Point | Spline | ClosedSpline;
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/shapes/index.ts | packages/image/src/shapes/index.ts | export * from './Polygon.shape';
export * from './Line.shape';
export * from './Rect.shape';
export * from './Point.shape';
export * from './CrossCursor.shape';
export * from './Spline.shape';
export * from './ClosedSpline';
export * from './Text.shape';
export * from './Group';
export * from './Shape';
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/shapes/Shape.ts | packages/image/src/shapes/Shape.ts | import EventEmitter from 'eventemitter3';
import type { BBox } from 'rbush';
import type { RBushItem } from '../core/CustomRBush';
import { rbush, eventEmitter, axis } from '../singletons';
import { EInternalEvent } from '../enums';
import type { AxisPoint } from './Point.shape';
type Coord = AxisPoint | AxisPoint[];... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/shapes/math.util.ts | packages/image/src/shapes/math.util.ts | import type { BBox } from 'rbush';
import type { AxisPoint } from './Point.shape';
/**
* 获取两点之间的距离
*
* @param start 起始点
* @param end 结束点
*/
export function getDistance(start: AxisPoint, end: AxisPoint) {
const { x: x1, y: y1 } = start;
const { x: x2, y: y2 } = end;
return Math.sqrt(Math.pow(x1 - x2, 2) + ... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/enums/internalEvent.enum.ts | packages/image/src/enums/internalEvent.enum.ts | /** 内部事件名列表 */
export enum EInternalEvent {
/** 工具变更 */
ToolChange = '__tool_change__',
/** 拖拽开始 */
PanStart = '__pan_start__',
/** 拖拽中 */
Pan = '__pan__',
/** 鼠标滚轮事件 */
Wheel = '__wheel__',
/** 移动结束 */
PanEnd = '__pan_end__',
/** 按下键盘 */
KeyDown = '__key_down__',
/** 松开键盘 */
KeyUp = '_... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/src/enums/index.ts | packages/image/src/enums/index.ts | export * from './internalEvent.enum';
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/example/vite.config.ts | packages/image/example/vite.config.ts | import { resolve } from 'path';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
// https://vitejs.dev/config/
export default defineConfig({
optimizeDeps: {
include: ['react/jsx-runtime'],
},
plugins: [react()],
build: {
target: 'es2015',
terserOptions: {
compr... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/example/src/App.tsx | packages/image/example/src/App.tsx | import React, { useEffect, useLayoutEffect, useRef } from 'react';
import { useState } from 'react';
import { Annotator } from '@labelu/image';
export const useEngine = (containerRef: React.RefObject<HTMLDivElement>, options?: any) => {
const [engine, setAnnotationEngine] = useState<any | null>(null);
const [optio... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/image/example/src/index.tsx | packages/image/example/src/index.tsx | import ReactDOM from 'react-dom/client';
import React from 'react';
import App from './App';
ReactDOM.createRoot(document.getElementById('root')!).render(<App />);
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/interface/src/base.ts | packages/interface/src/base.ts | /**
* 属性值或文本描述、标签分类的值内容
*
* @description 属性值是一个字符串或字符串数组,用于描述一个标注的属性。当表单项是单选时为字符串;复选时为字符串数组。
*
* @example ```{ "color": "red" }```、```{ "color": ["red", "blue"] }```
*/
export type AttributeValue = Record<string, string | string[]>;
/** 标签值,包含标签属性值 */
export interface LabelValue {
/** 标签id,通常为英文字符 */
label: ... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/interface/src/index.ts | packages/interface/src/index.ts | export * from './base';
export * from './configuration';
export * from './annotation';
export * from './utils';
export * from './enums';
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/interface/src/configuration/index.ts | packages/interface/src/configuration/index.ts | export * from './attribute';
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/interface/src/configuration/attribute/index.ts | packages/interface/src/configuration/attribute/index.ts | /**
* 标签的基础信息
*/
export interface AttributeItem {
/** 控制标签属性显隐性的条件 */
conditions?: ConditionItem[];
/** 是否必填 */
required?: boolean;
/** 标签名称 */
key: string;
/** 标签值,通常为英文字符 */
value: string;
}
/**
* 标签配置中的选项
*/
export interface AttributeOption extends AttributeItem {
/** 是否默认选中 */
isDefault?: b... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/interface/src/utils/index.ts | packages/interface/src/utils/index.ts | /**
* 标注数据结构体的工具类型
*
* @param Type 标注类型
* @param ValueType 标注值类型
*
* @description 通常在全局使用的标注数据结构体,包含标注的基本信息。
*
* @example 标签分类、文本描述。
*
* @see {@link TagAnnotationEntity}
* @see {@link TextAnnotationEntity}
*/
export interface AnnotationWrapper<Type, ValueType> {
/** 标注id */
id: string;
/** 标注类型 */
t... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/interface/src/annotation/index.ts | packages/interface/src/annotation/index.ts | import type {
AudioAnnotationData,
AudioAnnotationInUI,
AudioAnnotationType,
AudioFrameAnnotation,
AudioSegmentAnnotation,
} from './audio';
import type { TagAnnotationEntity, TextAnnotationEntity } from './others';
import type {
VideoAnnotationData,
VideoAnnotationInUI,
VideoAnnotationType,
VideoFram... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/interface/src/annotation/audio/index.ts | packages/interface/src/annotation/audio/index.ts | import type { LabelValue } from '../../base';
/**
* 音频片断分割
*/
export type AudioSegmentName = 'segment';
/**
* 音频时间戳标注
*/
export type AudioFrameName = 'frame';
/**
* 音频标注类型
*/
export type AudioAnnotationType = AudioSegmentName | AudioFrameName;
/**
* 音频片断分割标注数据
*/
export interface AudioSegmentAnnotation exte... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/interface/src/annotation/video/index.ts | packages/interface/src/annotation/video/index.ts | import type { AudioSegmentAnnotation } from '../audio';
/**
* 视频片断分割
*
* @description
* 与音频片断分割标注一致,组件层面其实与视频标注没有区别。
* 但是在业务层面,音频片断分割与音频断分割是两种不同的标注类型,因此在上层的业务层需要区分。
*
* @see {@link AudioSegmentName}
*/
export type VideoSegmentName = 'segment';
/**
* 视频帧标注
*
* @description 与视频分割同理
*
* @see {@link VideoSeg... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/interface/src/annotation/others/index.ts | packages/interface/src/annotation/others/index.ts | import type { AttributeValue } from '../../base';
import type { AnnotationWrapper } from '../../utils';
/**
* 文本描述标注类型
*/
export type TextAnnotationType = 'text';
/**
* 标签分类标注类型
*/
export type TagAnnotationType = 'tag';
/**
* 全局标注类型,包含文本描述和标签分类
*/
export type GlobalAnnotationType = TextAnnotationType | TagAnno... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/interface/src/enums/tool.ts | packages/interface/src/enums/tool.ts | /** 标签工具名称枚举类型 */
export enum ToolName {
/** 拉框工具 */
Rect = 'rect',
/** 标点工具 */
Point = 'point',
/** 多边形工具 */
Polygon = 'polygon',
/** 线条 */
Line = 'line',
/** 标签工具 */
Tag = 'tag',
/** 文本工具 */
Text = 'text',
/** 列表标点工具 */
PointMarker = 'point-marker',
/** 前景分割工具 */
Segmentation = 'segmen... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/interface/src/enums/index.ts | packages/interface/src/enums/index.ts | export * from './tool';
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/formatter/vite.config.ts | packages/formatter/vite.config.ts | import { resolve } from 'path';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import type { PluginOption } from 'vite';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [peerDepsExternal() as... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/formatter/src/utils.ts | packages/formatter/src/utils.ts | export function isNil(input: any) {
return input === null || input === undefined;
}
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/formatter/src/index.ts | packages/formatter/src/index.ts | import * as formats from './formats';
type AllFormatters = typeof formats & Record<string, Formatter>;
const allFormatters: AllFormatters = {
...formats,
};
export interface Formatter<T = any, O = any> {
type: string;
name: string;
desc?: string;
format: (value: T, opts: O) => T | any;
}
function add<T ex... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/formatter/src/formats/fileSize.ts | packages/formatter/src/formats/fileSize.ts | import type { partial } from 'filesize';
import { filesize as fileSizeUtil } from 'filesize';
import { isNil } from '@/utils';
/**
* 格式化文件大小
* 格式化参数请查阅filesize:https://github.com/avoidwork/filesize.js#optional-settings
*/
export const fileSize = {
type: 'fileSize',
name: '文件大小',
desc: '格式化文件大小',
format: (v... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/formatter/src/formats/basename.ts | packages/formatter/src/formats/basename.ts | /**
* 从路径提取basename如文件名
*/
export const basename = {
type: 'basename',
name: '文件名提取',
desc: '文件名提取',
format: (value: string): string => {
if (!value) {
return value;
}
const paths = value.split(/[\\/]/);
const lastPath = paths[paths.length - 1];
const dotIndex = lastPath.lastIndexOf(... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/formatter/src/formats/extension.ts | packages/formatter/src/formats/extension.ts | import { isNil } from '@/utils';
/**
* 格式化文件扩展名
*/
export const extension = {
type: 'extension',
name: '文件扩展名',
desc: '格式化文件扩展名',
format: (value: string) => {
if (isNil(value)) {
return '';
}
const paths = value.split(/[\\/]/);
const filePath = paths[paths.length - 1];
return fileP... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/formatter/src/formats/index.ts | packages/formatter/src/formats/index.ts | export * from './basename';
export * from './date';
export * from './extension';
export * from './fileSize';
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/formatter/src/formats/date.ts | packages/formatter/src/formats/date.ts | import dayjs from 'dayjs';
export interface IDateFormatterOption {
style?:
| 'YYYY-MM-DD HH:mm:ss'
| 'YYYY-MM-DD'
| 'HH:mm:ss'
| 'YYYY-MM-DD HH:mm'
| 'YYYY-MM-DD HH'
| 'YYYY-MM-DD'
| 'YYYY-MM'
| 'YYYY'
| 'MM-DD'
| 'MM-DD HH:mm:ss'
| 'MM-DD HH:mm'
| 'MM-DD HH'
| 'MM... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/audio-react/vite.config.ts | packages/audio-react/vite.config.ts | import { resolve } from 'path';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import svgr from 'vite-plugin-svgr';
import type { PluginOption } from 'vite';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
// https://vitejs.dev/config/
export default defineConfi... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/audio-react/src/index.ts | packages/audio-react/src/index.ts | import { AudioAnnotator } from './Audio';
export * from './Audio';
export default AudioAnnotator;
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/audio-react/src/Audio.tsx | packages/audio-react/src/Audio.tsx | import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
import type WaveSurfer from 'wavesurfer.js';
import styled from 'styled-components';
import { useHotkeys } from 'react-hotkeys-hook';
import type { MediaAnnotatorProps, MediaAnnotatorRef, PlayerControllerRef } fr... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/audio-react/src/AudioPlayer.tsx | packages/audio-react/src/AudioPlayer.tsx | import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
import styled from 'styled-components';
import type { WaveSurferOptions } from 'wavesurfer.js';
import WaveSurfer from 'wavesurfer.js';
export const useWaveSurfer = (
containerRef: React.RefObject<HTMLDivElement>,
option... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/audio-react/example/vite.config.ts | packages/audio-react/example/vite.config.ts | import { resolve } from 'path';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
// https://vitejs.dev/config/
export default defineConfig({
optimizeDeps: {
include: ['react/jsx-runtime'],
},
plugins: [react()],
build: {
target: 'es2015',
terserOptions: {
compr... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/audio-react/example/src/App.tsx | packages/audio-react/example/src/App.tsx | import React from 'react';
import { useState } from 'react';
import { AudioAnnotator, type AudioAnnotatorProps } from '@labelu/audio-react';
import type { AudioAnnotationType, MediaAnnotationInUI } from '@labelu/interface';
const mockData: any[] = [
{
id: '1',
start: 6.087957,
end: 11.533612,
label:... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/audio-react/example/src/index.tsx | packages/audio-react/example/src/index.tsx | import ReactDOM from 'react-dom/client';
import React from 'react';
import App from './App';
ReactDOM.createRoot(document.getElementById('root')!).render(<App />);
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/video-react/vite.config.app.ts | packages/video-react/vite.config.app.ts | import { resolve } from 'path';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import svgr from 'vite-plugin-svgr';
import tsMonoAlias from 'vite-plugin-ts-mono-alias';
import { ViteEjsPlugin } from 'vite-plugin-ejs';
// https://vitejs.dev/config/
export default defineConfig({
base: ... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/video-react/vite.config.ts | packages/video-react/vite.config.ts | import { resolve } from 'path';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import svgr from 'vite-plugin-svgr';
import type { PluginOption } from 'vite';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
// https://vitejs.dev/config/
export default defineConfi... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/video-react/src/utils.ts | packages/video-react/src/utils.ts | import type { VideoAnnotationData, VideoFrameAnnotation, VideoSegmentAnnotation } from '@labelu/interface';
/**
* 把毫秒转换成时长
* 1.若小于等于60秒,显示秒数
* 2.若大于1分钟小于1小时,显示分钟
* 3.若大于1小时,显示x小时x分钟
* @param s 秒数
* @returns string
*/
export function secondsToMinute(s: number) {
let sTime = Math.floor(s); // 秒
let mTime = 0;... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/video-react/src/Video.tsx | packages/video-react/src/Video.tsx | import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
import { useHotkeys } from 'react-hotkeys-hook';
import type {
VideoAnnotationType,
Attribute,
VideoSegmentName,
VideoFrameName,
EnumerableAttribute,
VideoAnnotationInUI,
} from '@labelu/interface';
i... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/video-react/src/vite-env.d.ts | packages/video-react/src/vite-env.d.ts | /// <reference types="vite/client" />
/// <reference types="vite-plugin-svgr/client" />
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/video-react/src/index.ts | packages/video-react/src/index.ts | import Video from './Video';
export default Video;
export * from './utils';
export * from './VideoPlayer';
export * from './Video';
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/video-react/src/example/App.tsx | packages/video-react/src/example/App.tsx | import { useState } from 'react';
import Video from '../Video';
const mockData: any[] = [
{
id: '1',
start: 6.087957,
end: 11.533612,
label: 'xfasd',
attributes: { eeeee: 'ddddasdqwe爱大赛请问', gffffffasd: ['ddd'] },
type: 'segment',
},
{
id: '2',
time: 14,
label: 'label-2',
... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/video-react/src/example/index.tsx | packages/video-react/src/example/index.tsx | import ReactDOM from 'react-dom/client';
import App from './App';
ReactDOM.createRoot(document.getElementById('root')!).render(<App />);
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/video-react/src/VideoPlayer/index.tsx | packages/video-react/src/VideoPlayer/index.tsx | import React, {
forwardRef,
memo,
useCallback,
useEffect,
useImperativeHandle,
useLayoutEffect,
useRef,
useState,
} from 'react';
import styled from 'styled-components';
import type { PlayerControllerRef } from '@labelu/components-react';
import { PlayerController, VIDEO_PLAYBACK_RATE_SPEED } from '@lab... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/i18n/vite.config.ts | packages/i18n/vite.config.ts | import { resolve } from 'path';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import type { PluginOption } from 'vite';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [peerDepsExternal() as... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/i18n/src/utils.ts | packages/i18n/src/utils.ts |
function isObject(obj: any) {
return obj && typeof obj === 'object' && !Array.isArray(obj);
}
export function merge(target: any, ...sources: any[]): any {
if (!sources.length) {
return target;
}
const source = sources.shift();
if (isObject(target) && isObject(source)) {
for (const key in source)... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/i18n/src/provider.tsx | packages/i18n/src/provider.tsx | import React, { useCallback, useEffect } from 'react';
import { I18nextProvider } from 'react-i18next';
import { merge } from './utils';
import { useLocalStorage } from './useLocalStorage';
import { i18n } from './i18n';
import { resources } from './locales';
const LANG_CHANGE_EVENT = 'labelu-lang-change';
export typ... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/i18n/src/useLocalStorage.ts | packages/i18n/src/useLocalStorage.ts | import { useEffect, useState } from 'react';
export const useLocalStorage = (key: string, value: any) => {
const [state, setState] = useState<any>(() => {
try {
const localStorageValue = localStorage.getItem(key);
if (typeof localStorageValue !== 'string') {
localStorage.setItem(key, JSON.str... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/i18n/src/i18n.ts | packages/i18n/src/i18n.ts |
import { initReactI18next } from 'react-i18next';
import i18n from 'i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import { resources } from './locales';
i18n
.use(LanguageDetector)
.use(initReactI18next)
.init({
resources,
fallbackLng: 'zh-CN',
interpolation: {
es... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/i18n/src/index.ts | packages/i18n/src/index.ts | export * from './i18n';
export * from './provider';
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/i18n/src/locales/index.ts | packages/i18n/src/locales/index.ts | import translation_en_us from './en-US.json';
import translation_zh_cn from './zh-CN.json';
export const resources = {
'en-US': {
translation: translation_en_us as Record<string, unknown>,
},
'zh-CN': {
translation: translation_zh_cn as Record<string, unknown>,
},
} as Record<string, { translation: Rec... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/components-react/vite.config.ts | packages/components-react/vite.config.ts | import { resolve } from 'path';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import svgr from 'vite-plugin-svgr';
// import dts from 'vite-plugin-dts';
import type { PluginOption } from 'vite';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
// https://vitejs.... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/components-react/src/utils.ts | packages/components-react/src/utils.ts | import type { VideoAnnotationData, VideoFrameAnnotation, VideoSegmentAnnotation } from '@labelu/interface';
/**
* Get the current operating system
* @returns string
*/
export function getOS() {
const userAgent = navigator.userAgent;
let operatingSystem = 'Unknown';
if (userAgent.indexOf('Win') !== -1) {
... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/components-react/src/vite-env.d.ts | packages/components-react/src/vite-env.d.ts | /// <reference types="vite/client" />
/// <reference types="vite-plugin-svgr/client" />
| typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
opendatalab/labelU-Kit | https://github.com/opendatalab/labelU-Kit/blob/6ed8ca2adc09525ba712eb73227f2a4e2cecb81a/packages/components-react/src/index.ts | packages/components-react/src/index.ts | export * from './Modal';
export * from './DraggableModal';
export * from './AttributeForm';
export * from './Divider';
export * from './Toolbar';
export * from './Tooltip';
export * from './EllipsisText';
export * from './StatusCard';
export * from './VideoCard';
export * from './AttributeTree';
export * from './Hotkey... | typescript | Apache-2.0 | 6ed8ca2adc09525ba712eb73227f2a4e2cecb81a | 2026-01-05T04:58:37.178097Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.