@aivex/ui 1.2.0-dev.3 → 1.2.0-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ShapeEditor/ShapeEditor.d.ts +1 -1
- package/dist/components/ShapeEditor/ShapeViewer.d.ts +42 -0
- package/dist/components/ShapeEditor/_components/ContextMenu.d.ts +1 -1
- package/dist/components/ShapeEditor/_components/Minimap.d.ts +4 -4
- package/dist/components/ShapeEditor/_components/RegionOverlay.d.ts +21 -0
- package/dist/components/ShapeEditor/_model/geometry.d.ts +2 -0
- package/dist/components/ShapeEditor/_model/imageFetch.d.ts +9 -0
- package/dist/components/ShapeEditor/_model/overlays.d.ts +82 -15
- package/dist/components/ShapeEditor/_model/overlays.test.d.ts +1 -0
- package/dist/components/ShapeEditor/_model/props.d.ts +26 -6
- package/dist/components/ShapeEditor/_model/strings.d.ts +1 -1
- package/dist/components/ShapeEditor/_model/viewSettings.d.ts +1 -1
- package/dist/components/ShapeEditor/_renderers/KonvaRenderer.d.ts +6 -5
- package/dist/components/ShapeEditor/_renderers/PixiRenderer.d.ts +9 -9
- package/dist/components/ShapeEditor/_renderers/transformSession.d.ts +5 -0
- package/dist/components/ShapeEditor/_renderers/types.d.ts +8 -8
- package/dist/components/ShapeEditor/_state/useDrawSession.d.ts +2 -1
- package/dist/components/ShapeEditor/_state/useEditorHotkeys.d.ts +2 -0
- package/dist/components/ShapeEditor/_state/useEngineLifecycle.d.ts +6 -6
- package/dist/components/ShapeEditor/index.d.ts +3 -1
- package/dist/shape-editor.cjs +1 -1
- package/dist/shape-editor.cjs.map +1 -1
- package/dist/shape-editor.js +1825 -1379
- package/dist/shape-editor.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/ShapeEditor/_components/RoiOverlay.d.ts +0 -21
|
@@ -4,6 +4,6 @@ import type { ShapeEditorProps } from "./_model/props";
|
|
|
4
4
|
* 그리기·히트테스트·뷰포트는 `EditorRenderer`(Konva/Pixi)에 위임한다. `backend`로 교체.
|
|
5
5
|
* 갭(회전/꼭짓점추가 등)은 여기서 한 번 구현하면 양쪽 렌더러에 적용된다.
|
|
6
6
|
*/
|
|
7
|
-
export default function ShapeEditor<TMeta, TMarkerMeta = unknown>({ imageUrl, displayImageUrl, renderImageState, dimmed, initialShapes, selectedIds: controlledSelectedIds, activeTool, draftStyle, draftMeta, readOnly, disableMarquee, locked, onLockedInteraction, onIdleEscape, overrideShapeInteraction, defaultViewSettings, viewSettings, onViewSettingsChange, showMinimap, showViewSettings, getContextMenuItems, strings, canMergeSelection, brushSize, zoomBound, zoomAnimationDuration,
|
|
7
|
+
export default function ShapeEditor<TMeta, TMarkerMeta = unknown>({ imageUrl, displayImageUrl, renderImageState, dimmed, initialShapes, selectedIds: controlledSelectedIds, activeTool, draftStyle, draftMeta, readOnly, disableMarquee, locked, onLockedInteraction, onIdleEscape, overrideShapeInteraction, defaultViewSettings, viewSettings, onViewSettingsChange, showMinimap, showViewSettings, getContextMenuItems, strings, canMergeSelection, brushSize, zoomBound, zoomAnimationDuration, decorationShapes, regionMask, guideMask, maskPalette, overlayMarkers, renderOverlayMarker, onOverlayMarkerClick, renderImageOverlay, getSelectionLabel, hideSelectionLabelDot, formatSelectionInfo, externalTools, assistant, keymap, handleRef, backend, onActiveToolChange, onSelectionChange, onEditingChange, onShapesCreated, onShapesUpdated, onShapesDeleted, onDrawSessionChange, onDraftShapeChange, onViewportChange, onShapesTransformPreview, }: ShapeEditorProps<TMeta, TMarkerMeta> & {
|
|
8
8
|
backend?: "konva" | "pixi";
|
|
9
9
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
+
import { type EditorShape } from "./_model/geometry";
|
|
3
|
+
import { type GuideMaskRaster, type MaskPalette, type RegionMask } from "./_model/overlays";
|
|
4
|
+
/**
|
|
5
|
+
* ShapeViewer가 지원하는 EditorShape **표시 서브셋 계약**:
|
|
6
|
+
* - 도형: POINT / RECTANGLE / ELLIPSE / POLYGON / LINE / ROTATED_RECTANGLE(꼭짓점 배열)
|
|
7
|
+
* - 스타일: color·alternateColor·strokeWidth·dash·opacity·filled·fillOpacity·
|
|
8
|
+
* pointRadius·zIndex, readOnly 줄무늬 — 에디터 렌더러와 같은 의미
|
|
9
|
+
* (resolveShapeRenderStyle 공유)로 그린다.
|
|
10
|
+
* - 상호작용·선택·핸들·마커 등 편집 표현은 렌더링하지 않는다(interaction.visible만 존중).
|
|
11
|
+
*/
|
|
12
|
+
export interface ShapeViewerProps<TMeta = unknown> {
|
|
13
|
+
imageUrl: string;
|
|
14
|
+
alt?: string;
|
|
15
|
+
/** 도형 좌표계 크기. 썸네일 이미지의 실제 픽셀 크기와 다를 때 지정한다. */
|
|
16
|
+
coordinateSize?: {
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
};
|
|
20
|
+
shapes?: EditorShape<TMeta>[];
|
|
21
|
+
regionMask?: RegionMask;
|
|
22
|
+
guideMask?: GuideMaskRaster | null;
|
|
23
|
+
maskPalette?: MaskPalette;
|
|
24
|
+
/** 지정한 도형이 화면을 채우도록 확대한다. */
|
|
25
|
+
focusedShapeId?: string;
|
|
26
|
+
/**
|
|
27
|
+
* 포커스 줌 시 이미지 밖 여백 처리. "cover"면 이미지가 항상 컨테이너를
|
|
28
|
+
* 가득 채우도록 배율을 올리고 오프셋을 이미지 안쪽으로 클램프한다(썸네일용).
|
|
29
|
+
*/
|
|
30
|
+
focusFit?: "contain" | "cover";
|
|
31
|
+
zoomPadding?: number;
|
|
32
|
+
strokeSize?: number;
|
|
33
|
+
brightness?: number;
|
|
34
|
+
contrast?: number;
|
|
35
|
+
imageSmoothing?: boolean;
|
|
36
|
+
lazy?: boolean;
|
|
37
|
+
className?: string;
|
|
38
|
+
style?: CSSProperties;
|
|
39
|
+
renderImageState?: (status: "loading" | "error") => ReactNode;
|
|
40
|
+
}
|
|
41
|
+
/** 목록·카드 미리보기를 위한 상호작용 없는 Canvas2D 도형 뷰어. */
|
|
42
|
+
export default function ShapeViewer<TMeta = unknown>({ imageUrl, alt, coordinateSize, shapes, regionMask, guideMask, maskPalette, focusedShapeId, focusFit, zoomPadding, strokeSize, brightness, contrast, imageSmoothing, lazy, className, style, renderImageState, }: ShapeViewerProps<TMeta>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,7 +5,7 @@ export type { ContextMenuItem };
|
|
|
5
5
|
* @aivex/ui Menu(Radix Dropdown)를 커서 위치의 0크기 트리거에 앵커해 띄운다.
|
|
6
6
|
* 바깥 클릭·Escape·스크롤 닫힘은 Radix가 onOpenChange로 처리한다(비모달).
|
|
7
7
|
*/
|
|
8
|
-
export declare function ContextMenu({ x, y, items, onClose, }: {
|
|
8
|
+
export declare function ContextMenu({ x, y, items: rawItems, onClose, }: {
|
|
9
9
|
x: number;
|
|
10
10
|
y: number;
|
|
11
11
|
items: ContextMenuItem[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
2
|
import { type EditorShape } from "../_model/geometry";
|
|
3
|
-
import type {
|
|
3
|
+
import type { RegionOverlayData } from "../_model/overlays";
|
|
4
4
|
import { type EditorStrings } from "../_model/strings";
|
|
5
5
|
import type { ViewSettings } from "../_model/viewSettings";
|
|
6
6
|
import type { MinimapNavigation } from "../_state/useMinimapNavigation";
|
|
@@ -11,7 +11,7 @@ import type { MinimapNavigation } from "../_state/useMinimapNavigation";
|
|
|
11
11
|
* 내비게이션 로직(패닝/줌)은 useMinimapNavigation(nav)에, 뷰포트 사각형/줌라벨의 실시간
|
|
12
12
|
* 갱신은 호스트의 syncMinimap이 rectRef/zoomLabelRef로 담당한다. 여긴 순수 표시.
|
|
13
13
|
*/
|
|
14
|
-
export declare function Minimap<TMeta>({ image, imageUrl, imageVisible, maskDataUrl,
|
|
14
|
+
export declare function Minimap<TMeta>({ image, imageUrl, imageVisible, maskDataUrl, region, roiMaskId, shapes, view, onChangeView, nav, registerShape, rectRef, zoomLabelRef, onZoom100, open, onToggleOpen, showSettings, settingsOpen, onToggleSettings, onCloseSettings, labels, settingsLabels, }: {
|
|
15
15
|
image: {
|
|
16
16
|
w: number;
|
|
17
17
|
h: number;
|
|
@@ -20,8 +20,8 @@ export declare function Minimap<TMeta>({ image, imageUrl, imageVisible, maskData
|
|
|
20
20
|
/** 메인 캔버스와 동기화된 표시 여부 — 전환 시 즉시 숨기고 로드 후 페이드인. */
|
|
21
21
|
imageVisible?: boolean;
|
|
22
22
|
maskDataUrl: string | null;
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
/** 리졸브된 영역 마스크 오버레이(딤·윤곽 벡터). */
|
|
24
|
+
region?: RegionOverlayData | null;
|
|
25
25
|
roiMaskId: string;
|
|
26
26
|
shapes: EditorShape<TMeta>[];
|
|
27
27
|
view: ViewSettings;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
import type { RegionOverlayData } from "../_model/overlays";
|
|
3
|
+
/**
|
|
4
|
+
* 영역 마스크 오버레이 SVG — 미니맵용.
|
|
5
|
+
* 보이는 영역 밖을 딤으로 덮고, 가림 영역은 다시 덮으며, 경계선은 리졸브된
|
|
6
|
+
* 윤곽 선분만 점선으로 그린다(미니맵 축소 특성상 색은 단일 흰색).
|
|
7
|
+
* 좌표계는 이미지 좌표(viewBox=image), 화면 크기/선 두께는 호출부가 정한다.
|
|
8
|
+
*/
|
|
9
|
+
export declare function RegionOverlay({ image, region, maskId, width, height, strokeWidth, strokeDasharray, style, }: {
|
|
10
|
+
image: {
|
|
11
|
+
w: number;
|
|
12
|
+
h: number;
|
|
13
|
+
};
|
|
14
|
+
region: RegionOverlayData;
|
|
15
|
+
maskId: string;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
strokeWidth: number | string;
|
|
19
|
+
strokeDasharray: string;
|
|
20
|
+
style?: CSSProperties;
|
|
21
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -21,6 +21,8 @@ export type ShapeType = (typeof SHAPE_TYPE)[keyof typeof SHAPE_TYPE];
|
|
|
21
21
|
/** 도형 렌더 힌트. 호스트가 (예: 클래스→색) 계산해 주입한다. */
|
|
22
22
|
export interface ShapeStyle {
|
|
23
23
|
color?: string;
|
|
24
|
+
/** 점선의 빈 구간에 표시할 보조색. 지정하면 보조색 실선 위에 주색 점선을 그린다. */
|
|
25
|
+
alternateColor?: string;
|
|
24
26
|
filled?: boolean;
|
|
25
27
|
opacity?: number;
|
|
26
28
|
/** 도형별 선 두께(화면 px). 없으면 에디터 기본값을 사용한다. */
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CORS 안전 이미지 blob URL 로드 — HTTP 캐시를 우선 사용한다(재방문·페이지 전환·
|
|
3
|
+
* 화질 스왑 시 재다운로드 없음). 앱 다른 곳의 crossOrigin 없는 `<img>`가 캐시를
|
|
4
|
+
* CORS 헤더 없는 응답으로 채웠으면 cors fetch가 실패하므로, 그때만 cache:"reload"로
|
|
5
|
+
* 캐시 항목을 정상 CORS 응답으로 갈아끼우며 한 번 더 시도한다.
|
|
6
|
+
* 둘 다 실패하면 null — 호출부가 crossOrigin="anonymous" `<img>`로 폴백한다.
|
|
7
|
+
* Konva/Pixi 렌더러와 ShapeViewer가 공유한다.
|
|
8
|
+
*/
|
|
9
|
+
export declare function fetchImageObjectUrl(url: string): Promise<string | null>;
|
|
@@ -6,18 +6,57 @@ import type { Point } from "./geometry";
|
|
|
6
6
|
* 색(팔레트)만 안다. 호스트가 자기 도메인 데이터(클래스색·인덱스맵 등)에서 계산해
|
|
7
7
|
* 주입하고, 에디터는 그대로 그리기만 한다. 비즈니스 로직 비종속.
|
|
8
8
|
*/
|
|
9
|
-
/**
|
|
10
|
-
export interface
|
|
9
|
+
/** 이미지 좌표 사각형 영역 — 가림 효과에서 "보이는 창"(예: 호스트의 관심영역). */
|
|
10
|
+
export interface RectArea {
|
|
11
11
|
id?: string;
|
|
12
12
|
x: number;
|
|
13
13
|
y: number;
|
|
14
14
|
w: number;
|
|
15
15
|
h: number;
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
18
|
-
export interface
|
|
17
|
+
/** 이미지 좌표 다각형 영역 — 보이는 창 안에서 다시 가리는 부분(예: 호스트의 마스킹). */
|
|
18
|
+
export interface PolygonArea {
|
|
19
19
|
points: Point[];
|
|
20
20
|
}
|
|
21
|
+
/** @deprecated 도메인 중립화로 `RectArea`로 개명. 다음 릴리스에서 제거 예정. */
|
|
22
|
+
export type RoiRect = RectArea;
|
|
23
|
+
/** @deprecated 도메인 중립화로 `PolygonArea`로 개명. 다음 릴리스에서 제거 예정. */
|
|
24
|
+
export type ExcludedZone = PolygonArea;
|
|
25
|
+
/** 영역 윤곽 스트로크 — 화면 px 기준(줌과 무관하게 고정). */
|
|
26
|
+
export interface RegionOutlineStyle {
|
|
27
|
+
color?: string;
|
|
28
|
+
opacity?: number;
|
|
29
|
+
/** 두께(화면 px). */
|
|
30
|
+
width?: number;
|
|
31
|
+
/** 점선 패턴(화면 px). */
|
|
32
|
+
dash?: [number, number];
|
|
33
|
+
/** 점선 빈 구간의 밑선 색(대비용). null이면 밑선 없음. 기본 검정. */
|
|
34
|
+
underlayColor?: string | null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 이미지 위 가림 효과를 위한 순수 시각 계약. 영역의 제품 의미(관심영역·마스킹 등)는
|
|
38
|
+
* 호스트가 해석하고, 에디터는 "보이는 영역과 가려지는 영역"만 안다.
|
|
39
|
+
* 표시 정책(딤 농도·윤곽 색)은 기본값일 뿐 호스트가 전부 재정의할 수 있다.
|
|
40
|
+
*/
|
|
41
|
+
export interface RegionMask {
|
|
42
|
+
visibleAreas: RectArea[];
|
|
43
|
+
occludedAreas?: PolygonArea[];
|
|
44
|
+
/** 가림 면 스타일. 기본 검정 50%. */
|
|
45
|
+
dim?: {
|
|
46
|
+
color?: string;
|
|
47
|
+
opacity?: number;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* 윤곽 표시. false면 면만 그리고 윤곽은 도형 레이어에 맡긴다. 미지정=기본 스타일.
|
|
51
|
+
* mode "merged"(기본)=유효 영역(합집합 − 가림) 경계 하나를 visibleStyle로(보기 맥락),
|
|
52
|
+
* "separate"=사각형·가림 윤곽을 각각 visibleStyle/occludedStyle로 통째 표시(편집 맥락).
|
|
53
|
+
*/
|
|
54
|
+
outline?: false | {
|
|
55
|
+
mode?: "merged" | "separate";
|
|
56
|
+
visibleStyle?: RegionOutlineStyle;
|
|
57
|
+
occludedStyle?: RegionOutlineStyle;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
21
60
|
/** 마스크 팔레트 — 픽셀 인덱스값 → 색(hex). 호스트가 클래스색에서 계산해 주입. */
|
|
22
61
|
export type MaskPalette = Record<number, string>;
|
|
23
62
|
/**
|
|
@@ -37,19 +76,47 @@ export interface GuideMaskRaster {
|
|
|
37
76
|
* 실패하면 null. 결과 캔버스는 이미지 원본 해상도(width×height).
|
|
38
77
|
*/
|
|
39
78
|
export declare const buildMaskCanvas: (raster: GuideMaskRaster, palette: MaskPalette) => HTMLCanvasElement | null;
|
|
79
|
+
/** 이미지 좌표 선분. 렌더러가 화면고정(줌 무관) 점선 스트로크로 그린다. */
|
|
80
|
+
export type OutlineSegment = [Point, Point];
|
|
81
|
+
/**
|
|
82
|
+
* Canvas2D에 벡터 딤을 그린다 — 이미지 전체를 딤 색으로 덮되 보이는 영역 합집합을
|
|
83
|
+
* 구멍(dimHoles, 무겹침이라 nonzero에서 안전)으로 뚫고, 가림 영역은 합집합 안쪽만
|
|
84
|
+
* 다시 덮는다. Konva 렌더러와 ShapeViewer가 공유한다(전체 경로 커버리지 채움이라
|
|
85
|
+
* 인접 구멍 경계에 이음선이 생기지 않는다).
|
|
86
|
+
*/
|
|
87
|
+
export declare function drawRegionDim(ctx: CanvasRenderingContext2D, region: Pick<RegionOverlayData, "rects" | "zones" | "dimHoles" | "dim">, width: number, height: number): void;
|
|
88
|
+
/** 기본값이 채워진 윤곽 스트로크 — 렌더러가 그대로 그린다. */
|
|
89
|
+
export type ResolvedRegionOutlineStyle = Required<RegionOutlineStyle>;
|
|
40
90
|
/**
|
|
41
|
-
* 렌더러 오버레이용
|
|
42
|
-
*
|
|
91
|
+
* 렌더러 오버레이용 영역 데이터. 딤(면)·윤곽 모두 벡터로 넘긴다 —
|
|
92
|
+
* 래스터(캔버스 굽기 + 텍스처 업로드)가 없어 드래그 중 프레임마다 재계산해도 싸다.
|
|
93
|
+
* 딤은 rects/zones로 각 렌더러가 직접 그리고(이미지 전체 − 사각형 합집합, 가림은
|
|
94
|
+
* 합집합 안쪽만 다시 덮음), 윤곽은 선분 목록을 화면고정(줌 무관) 스트로크로 그린다.
|
|
43
95
|
*/
|
|
44
|
-
export interface
|
|
45
|
-
|
|
46
|
-
rects:
|
|
47
|
-
zones:
|
|
96
|
+
export interface RegionOverlayData {
|
|
97
|
+
/** 딤 계산용 보이는 창들. visibleAreas가 비어 있으면 전체 이미지 사각형 1개. */
|
|
98
|
+
rects: RectArea[];
|
|
99
|
+
zones: PolygonArea[];
|
|
100
|
+
/** 사각형 합집합의 무겹침 분해 — 캔버스 딤 경로의 구멍용(겹치는 영역 안전). */
|
|
101
|
+
dimHoles: RectArea[];
|
|
102
|
+
dim: {
|
|
103
|
+
color: string;
|
|
104
|
+
opacity: number;
|
|
105
|
+
};
|
|
106
|
+
/** visibleStyle로 그릴 경계 조각. merged면 유효 영역 경계 전체가 여기 담긴다. */
|
|
107
|
+
visibleOutline: OutlineSegment[];
|
|
108
|
+
/** occludedStyle로 그릴 가림 윤곽 조각(separate 모드에서만 비어있지 않음). */
|
|
109
|
+
occludedOutline: OutlineSegment[];
|
|
110
|
+
/** null이면 윤곽 생략(outline: false). */
|
|
111
|
+
outlineStyles: {
|
|
112
|
+
visible: ResolvedRegionOutlineStyle;
|
|
113
|
+
occluded: ResolvedRegionOutlineStyle;
|
|
114
|
+
} | null;
|
|
48
115
|
}
|
|
49
116
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* 렌더러 오버레이 레이어(이미지↔도형 사이)에
|
|
117
|
+
* RegionMask를 렌더러가 그릴 벡터 데이터로 리졸브한다(기본 표시 정책 주입 포함).
|
|
118
|
+
* outline.mode "merged"(기본)면 유효 영역(합집합 − 가림) 경계 하나를,
|
|
119
|
+
* "separate"면 사각형·가림 윤곽을 각각 통째로 넘긴다.
|
|
120
|
+
* 렌더러 오버레이 레이어(이미지↔도형 사이)에 그려 도형이 그 위에 보이게 한다.
|
|
54
121
|
*/
|
|
55
|
-
export declare const
|
|
122
|
+
export declare const buildRegionOverlayData: (mask: RegionMask, width: number, height: number) => RegionOverlayData | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode, Ref } from "react";
|
|
2
2
|
import type { EditorShape, Point, ShapeInteraction, ShapeStyle, Viewport } from "./geometry";
|
|
3
3
|
import type { EditorAction, KeymapOverrides } from "./keymap";
|
|
4
|
-
import type {
|
|
4
|
+
import type { GuideMaskRaster, MaskPalette, PolygonArea, RectArea, RegionMask, RegionOutlineStyle } from "./overlays";
|
|
5
5
|
import type { EditorStringsOverride } from "./strings";
|
|
6
6
|
import type { BrushScalarMode, Tool } from "./tools";
|
|
7
7
|
import type { ViewSettings } from "./viewSettings";
|
|
@@ -31,6 +31,8 @@ export interface EditorOverlayMarker<TMeta = unknown> {
|
|
|
31
31
|
}
|
|
32
32
|
/** 우클릭 컨텍스트 메뉴 항목(도메인 무관). */
|
|
33
33
|
export type ContextMenuItem = {
|
|
34
|
+
/** 기본 항목 식별자(예: "delete"). 호스트는 라벨 문자열 대신 이걸로 필터링한다. */
|
|
35
|
+
id?: string;
|
|
34
36
|
label: string;
|
|
35
37
|
onClick: () => void;
|
|
36
38
|
disabled?: boolean;
|
|
@@ -175,10 +177,15 @@ export interface ShapeEditorProps<TMeta = unknown, TMarkerMeta = unknown> {
|
|
|
175
177
|
* 잇는 데 쓴다(기존 Editor의 Esc 사슬 꼬리).
|
|
176
178
|
*/
|
|
177
179
|
onIdleEscape?: () => void;
|
|
178
|
-
/**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
/**
|
|
181
|
+
* 문서 밖 장식 도형(예: 다른 해상도 가이드 사각형). 도형 레이어에 렌더만 되고
|
|
182
|
+
* 선택·undo 히스토리·히트테스트·getShapes()에서 완전히 제외된다 — 스타일 변경
|
|
183
|
+
* (hover 강조 등)은 prop 교체로 반영되며 히스토리에 쌓이지 않는다.
|
|
184
|
+
* z순서는 style.zIndex로 제어한다(음수면 문서 도형 아래).
|
|
185
|
+
*/
|
|
186
|
+
decorationShapes?: EditorShape<TMeta>[];
|
|
187
|
+
/** 이미지 위 가림 효과. 제품 의미는 호스트가 해석하고 에디터는 순수 영역만 렌더링한다. */
|
|
188
|
+
regionMask?: RegionMask;
|
|
182
189
|
/**
|
|
183
190
|
* 가이드 마스크 래스터(디코딩된 width/height/indices). maskPalette와 함께 사용.
|
|
184
191
|
* 서버 와이어 포맷(바이너리 헤더 등) 디코딩은 호스트 책임(LabelEditor/guideMask.ts).
|
|
@@ -309,6 +316,13 @@ export interface ShapeEditorProps<TMeta = unknown, TMarkerMeta = unknown> {
|
|
|
309
316
|
*/
|
|
310
317
|
onShapesDeleted?: (ids: string[]) => void;
|
|
311
318
|
onViewportChange?: (viewport: EditorCanvasViewport) => void;
|
|
319
|
+
/** 이동·리사이즈·정점 편집 중인 도형 좌표. 문서 커밋 전 시각 동기화용이다. */
|
|
320
|
+
onShapesTransformPreview?: (updates: {
|
|
321
|
+
id: string;
|
|
322
|
+
points: Point[];
|
|
323
|
+
}[]) => void;
|
|
324
|
+
/** 그리는 중인 임시 도형. ROI 등 호스트 전용 실시간 오버레이 동기화에 사용한다. */
|
|
325
|
+
onDraftShapeChange?: (shape: Pick<EditorShape<TMeta>, "type" | "points" | "meta"> | null) => void;
|
|
312
326
|
/** 그리기 세션(붓·폴리곤·패스) 상태 — 호스트 undo/툴바 연동용. */
|
|
313
327
|
onDrawSessionChange?: (session: DrawSessionChange) => void;
|
|
314
328
|
/** 호스트發 수정/undo·redo/선택 제어용 명령형 핸들. */
|
|
@@ -330,6 +344,12 @@ export interface DrawSessionChange {
|
|
|
330
344
|
* 호스트가 에디터에 명령을 보내는 창구. 모든 변경은 에디터 히스토리에 쌓여 undo 가능.
|
|
331
345
|
*/
|
|
332
346
|
export interface ShapeEditorHandle<TMeta = unknown> {
|
|
347
|
+
/**
|
|
348
|
+
* 드래그·드로잉 중 고빈도 오버레이 프리뷰 — regionMask prop(React 왕복)을 우회해
|
|
349
|
+
* 렌더러에 즉시 반영한다(같은 프레임 보장). null이면 prop 기반 오버레이로 복귀.
|
|
350
|
+
* 문서 상태의 진실은 여전히 regionMask prop — 커밋 후 prop 갱신이 이 값을 덮어쓴다.
|
|
351
|
+
*/
|
|
352
|
+
previewRegionMask: (regionMask: RegionMask | null) => void;
|
|
333
353
|
/** 문서 undo. 그리기 세션이 있으면 `undoSession`이 우선. */
|
|
334
354
|
undo: () => void;
|
|
335
355
|
/** 문서 redo. 그리기 세션이 있으면 `redoSession`이 우선. */
|
|
@@ -406,4 +426,4 @@ export interface ShapeEditorHandle<TMeta = unknown> {
|
|
|
406
426
|
beginEditFromSelection: () => boolean;
|
|
407
427
|
};
|
|
408
428
|
}
|
|
409
|
-
export type { BrushScalarMode, EditorAction, EditorShape,
|
|
429
|
+
export type { BrushScalarMode, EditorAction, EditorShape, GuideMaskRaster, KeymapOverrides, MaskPalette, Point, PolygonArea, RectArea, RegionMask, RegionOutlineStyle, ShapeStyle, Tool, Viewport, ViewSettings, };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type BBox, type EditorShape, type Point } from "../_model/geometry";
|
|
2
|
-
import type
|
|
1
|
+
import { type BBox, type EditorShape, type Point, type ShapeStyle } from "../_model/geometry";
|
|
2
|
+
import { type RegionOverlayData } from "../_model/overlays";
|
|
3
3
|
import type { ScalarMaskRaster } from "../_model/scalarMask";
|
|
4
4
|
import type { EditorRenderer, EditorRendererCallbacks, PreviewKind, Viewport } from "./types";
|
|
5
5
|
/**
|
|
@@ -27,6 +27,7 @@ export declare class KonvaRenderer implements EditorRenderer {
|
|
|
27
27
|
private shapes;
|
|
28
28
|
private selected;
|
|
29
29
|
private nodes;
|
|
30
|
+
private altNodes;
|
|
30
31
|
private lastAppliedScale;
|
|
31
32
|
private imageLoadToken;
|
|
32
33
|
private transformEnabled;
|
|
@@ -65,7 +66,7 @@ export declare class KonvaRenderer implements EditorRenderer {
|
|
|
65
66
|
setFilter(brightness: number, contrast: number): void;
|
|
66
67
|
setStrokeSize(strokeSize: number): void;
|
|
67
68
|
setImageSmoothing(smooth: boolean): void;
|
|
68
|
-
setOverlays(maskCanvas: HTMLCanvasElement | null,
|
|
69
|
+
setOverlays(maskCanvas: HTMLCanvasElement | null, region: RegionOverlayData | null, dimmed: boolean): void;
|
|
69
70
|
get viewport(): Viewport;
|
|
70
71
|
applyViewport(v: Viewport): void;
|
|
71
72
|
fit(): void;
|
|
@@ -92,8 +93,8 @@ export declare class KonvaRenderer implements EditorRenderer {
|
|
|
92
93
|
clearMarquee(): void;
|
|
93
94
|
private preview;
|
|
94
95
|
private marquee;
|
|
95
|
-
previewBox(kind: PreviewKind, a: Point, b: Point,
|
|
96
|
-
previewPoly(points: Point[], cursor: Point | null,
|
|
96
|
+
previewBox(kind: PreviewKind, a: Point, b: Point, style: ShapeStyle): void;
|
|
97
|
+
previewPoly(points: Point[], cursor: Point | null, style: ShapeStyle, closed: boolean, selectedPointIndices?: number[], showVertices?: boolean): void;
|
|
97
98
|
previewScalarMask(raster: ScalarMaskRaster, color: string): void;
|
|
98
99
|
previewMarquee(a: Point, b: Point): void;
|
|
99
100
|
setTransformEnabled(enabled: boolean): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Application, ColorMatrixFilter, Container, type FederatedPointerEvent } from "pixi.js";
|
|
2
|
-
import { type EditorShape, type Point } from "../_model/geometry";
|
|
3
|
-
import type {
|
|
2
|
+
import { type EditorShape, type Point, type ShapeStyle } from "../_model/geometry";
|
|
3
|
+
import type { RegionOverlayData } from "../_model/overlays";
|
|
4
4
|
import { type ScalarMaskRaster } from "../_model/scalarMask";
|
|
5
5
|
import type { EditorRendererCallbacks, Viewport } from "./types";
|
|
6
6
|
export type { Viewport };
|
|
@@ -23,8 +23,8 @@ export declare class PixiRenderer {
|
|
|
23
23
|
private imageTileTextures;
|
|
24
24
|
private imageLoadToken;
|
|
25
25
|
private overlayTextures;
|
|
26
|
-
private
|
|
27
|
-
private
|
|
26
|
+
private region;
|
|
27
|
+
private regionOutlineG;
|
|
28
28
|
private cb;
|
|
29
29
|
private host;
|
|
30
30
|
private baseCursor;
|
|
@@ -77,7 +77,7 @@ export declare class PixiRenderer {
|
|
|
77
77
|
clearImage(): void;
|
|
78
78
|
private clearImageTiles;
|
|
79
79
|
setImageSmoothing(smooth: boolean): void;
|
|
80
|
-
setOverlays(maskCanvas: HTMLCanvasElement | null,
|
|
80
|
+
setOverlays(maskCanvas: HTMLCanvasElement | null, region: RegionOverlayData | null, dimmed: boolean): void;
|
|
81
81
|
get viewport(): Viewport;
|
|
82
82
|
applyViewport(v: Viewport): void;
|
|
83
83
|
fit(): void;
|
|
@@ -120,8 +120,8 @@ export declare class PixiRenderer {
|
|
|
120
120
|
private ensurePreview;
|
|
121
121
|
clearPreview(): void;
|
|
122
122
|
clearMarquee(): void;
|
|
123
|
-
previewBox(kind: "rect" | "ellipse", a: Point, b: Point,
|
|
124
|
-
previewPoly(points: Point[], cursor: Point | null,
|
|
123
|
+
previewBox(kind: "rect" | "ellipse", a: Point, b: Point, style: ShapeStyle): void;
|
|
124
|
+
previewPoly(points: Point[], cursor: Point | null, style: ShapeStyle, closed: boolean, selectedPointIndices?: number[], showVertices?: boolean): void;
|
|
125
125
|
previewScalarMask(raster: ScalarMaskRaster, color: string): void;
|
|
126
126
|
previewMarquee(a: Point, b: Point): void;
|
|
127
127
|
/** 줌 시 화면고정 선두께 유지 위해 다시 그림(도형 수 많으면 비용 — 후속 최적화). */
|
|
@@ -131,8 +131,8 @@ export declare class PixiRenderer {
|
|
|
131
131
|
* 도형이 많아도 줌이 무겁지 않게 한다. 노드가 아직 없으면 최초 1회만 전체 생성.
|
|
132
132
|
*/
|
|
133
133
|
private restrokeShapes;
|
|
134
|
-
/**
|
|
135
|
-
private
|
|
134
|
+
/** 영역 윤곽 점선 — 두께·점선을 화면 px로 유지(줌 시 재도색). */
|
|
135
|
+
private redrawRegionOutline;
|
|
136
136
|
private path;
|
|
137
137
|
private dashedStrokeShape;
|
|
138
138
|
private strokeDashedPolyline;
|
|
@@ -43,6 +43,11 @@ export declare function computeDragUpdates(d: ActiveDrag, img: Point, isRotatedR
|
|
|
43
43
|
updates: ShapeUpdate[];
|
|
44
44
|
box: BBox | null;
|
|
45
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* 포인터 이동 전(클릭 유지 상태) 드래그 지오메트리를 바꾸지 않는 포인터 이미지 좌표.
|
|
48
|
+
* 뷰포트 변경(줌/팬) 중 드래그 상태를 건드리지 않고 핸들·프리뷰만 재배치할 때 쓴다.
|
|
49
|
+
*/
|
|
50
|
+
export declare function dragIdentityImage(shapes: EditorShape[], d: ActiveDrag): Point;
|
|
46
51
|
/** 이동 드래그 시작 상태 — 드래그 가능한 대상만 추려 스냅샷과 합집합 박스를 만든다. */
|
|
47
52
|
export declare function makeMoveDrag(shapes: EditorShape[], ids: string[], start: Point): Extract<ActiveDrag, {
|
|
48
53
|
kind: "move";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EditorInteractionMode } from "../_model/cursors";
|
|
2
|
-
import type { BBox, EditorShape, Point } from "../_model/geometry";
|
|
3
|
-
import type {
|
|
2
|
+
import type { BBox, EditorShape, Point, ShapeStyle } from "../_model/geometry";
|
|
3
|
+
import type { RegionOverlayData } from "../_model/overlays";
|
|
4
4
|
import type { ScalarMaskRaster } from "../_model/scalarMask";
|
|
5
5
|
/**
|
|
6
6
|
* 렌더러 추상화 — Editor가 상호작용/문서/키보드를 소유하고, 그리기·히트테스트·
|
|
@@ -62,11 +62,11 @@ export interface EditorRenderer<TMeta = unknown> {
|
|
|
62
62
|
/** 이미지 스무딩. false면 확대 시 픽셀화(또렷). */
|
|
63
63
|
setImageSmoothing(smooth: boolean): void;
|
|
64
64
|
/**
|
|
65
|
-
* 이미지↔도형 사이 오버레이(가이드
|
|
66
|
-
*
|
|
67
|
-
*
|
|
65
|
+
* 이미지↔도형 사이 오버레이(가이드 마스크·영역 마스크)를 그린다. 딤(면)·윤곽은
|
|
66
|
+
* 벡터(RegionOverlayData)로 받아 윤곽을 화면고정(줌 무관) 스트로크로 그린다.
|
|
67
|
+
* null이면 해당 오버레이를 지운다. 도형은 이 위에 그려진다.
|
|
68
68
|
*/
|
|
69
|
-
setOverlays(maskCanvas: HTMLCanvasElement | null,
|
|
69
|
+
setOverlays(maskCanvas: HTMLCanvasElement | null, region: RegionOverlayData | null, dimmed: boolean): void;
|
|
70
70
|
setCursor(cursor: string): void;
|
|
71
71
|
setShapes(shapes: EditorShape<TMeta>[], selected: string[]): void;
|
|
72
72
|
setSelection(selected: string[]): void;
|
|
@@ -83,8 +83,8 @@ export interface EditorRenderer<TMeta = unknown> {
|
|
|
83
83
|
zoom100(): void;
|
|
84
84
|
zoomAt(cx: number, cy: number, factor: number): void;
|
|
85
85
|
beginMove(start: Point, ids: string[]): void;
|
|
86
|
-
previewBox(kind: PreviewKind, a: Point, b: Point,
|
|
87
|
-
previewPoly(points: Point[], cursor: Point | null,
|
|
86
|
+
previewBox(kind: PreviewKind, a: Point, b: Point, style: ShapeStyle): void;
|
|
87
|
+
previewPoly(points: Point[], cursor: Point | null, style: ShapeStyle, closed: boolean, selectedPointIndices?: number[], showVertices?: boolean): void;
|
|
88
88
|
previewScalarMask(raster: ScalarMaskRaster, color: string): void;
|
|
89
89
|
previewMarquee(a: Point, b: Point): void;
|
|
90
90
|
clearPreview(): void;
|
|
@@ -19,10 +19,11 @@ interface UseDrawSessionParams<TMeta> {
|
|
|
19
19
|
draftMeta: TMeta | undefined;
|
|
20
20
|
engineRef: RefObject<EditorRenderer | null>;
|
|
21
21
|
onDrawSessionChange?: (session: DrawSessionChange) => void;
|
|
22
|
+
onDraftShapeChange?: (shape: Pick<EditorShape<TMeta>, "type" | "points" | "meta"> | null) => void;
|
|
22
23
|
changeSelection: (ids: string[]) => void;
|
|
23
24
|
createShape: (type: EditorShape<TMeta>["type"], points: Point[]) => void;
|
|
24
25
|
}
|
|
25
|
-
export declare function useDrawSession<TMeta>({ toolRef, selRef, docRef, readOnlyRef, draftRef, brushSizeRef, simplifyEpsilonRef, draftMeta, engineRef, onDrawSessionChange, changeSelection, createShape, }: UseDrawSessionParams<TMeta>): {
|
|
26
|
+
export declare function useDrawSession<TMeta>({ toolRef, selRef, docRef, readOnlyRef, draftRef, brushSizeRef, simplifyEpsilonRef, draftMeta, engineRef, onDrawSessionChange, onDraftShapeChange, changeSelection, createShape, }: UseDrawSessionParams<TMeta>): {
|
|
26
27
|
reset: () => void;
|
|
27
28
|
undoSession: () => boolean;
|
|
28
29
|
redoSession: () => boolean;
|
|
@@ -5,6 +5,8 @@ export type EditorActionHandlers = Partial<Record<EditorAction, () => boolean |
|
|
|
5
5
|
interface EditorHotkeysCtx {
|
|
6
6
|
/** 호스트 재정의(문자열/배열=재매핑, null=비활성). 미지정 키는 기본값. */
|
|
7
7
|
keymap?: KeymapOverrides;
|
|
8
|
+
/** 에디터 루트 요소. 에디터를 포함하지 않는 모달 위에서는 액션을 무시하는 데 쓴다. */
|
|
9
|
+
hostRef: RefObject<HTMLElement | null>;
|
|
8
10
|
actions: EditorActionHandlers;
|
|
9
11
|
spaceRef: RefObject<boolean>;
|
|
10
12
|
shiftRef: RefObject<boolean>;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { type RefObject } from "react";
|
|
2
|
-
import type { Point } from "../_model/geometry";
|
|
3
|
-
import type {
|
|
2
|
+
import type { EditorShape, Point } from "../_model/geometry";
|
|
3
|
+
import type { RegionOverlayData } from "../_model/overlays";
|
|
4
4
|
import { type Tool } from "../_model/tools";
|
|
5
5
|
import type { ViewSettings } from "../_model/viewSettings";
|
|
6
6
|
import type { EditorRenderer, EditorRendererCallbacks } from "../_renderers/types";
|
|
7
|
-
import type { EditorDocument } from "./useEditorDocument";
|
|
8
7
|
export type EditorImageStatus = "loading" | "ready" | "error";
|
|
9
8
|
/**
|
|
10
9
|
* 렌더러 엔진 생명주기 — backend당 1회 생성/파괴, 이미지 전환(문서 전환 vs 화질 스왑),
|
|
@@ -14,7 +13,7 @@ export type EditorImageStatus = "loading" | "ready" | "error";
|
|
|
14
13
|
* 교체하므로 전환 중 이전 이미지가 유지됨). imageUrl마다 엔진을 파괴/재생성하면 캔버스가
|
|
15
14
|
* DOM에서 사라졌다 붙는 사이 배경이 번쩍인다.
|
|
16
15
|
*/
|
|
17
|
-
export declare function useEngineLifecycle<TMeta>({ backend, hostRef, engineRef, imageUrl, renderedImageUrl, makeCallbacks, viewRef, readOnlyRef, toolRef,
|
|
16
|
+
export declare function useEngineLifecycle<TMeta>({ backend, hostRef, engineRef, imageUrl, renderedImageUrl, makeCallbacks, viewRef, readOnlyRef, toolRef, renderShapesRef, selRef, maskCanvasRef, regionOverlayRef, dimmedRef, syncMinimap, setImage, setImageVisible, setReady, setImageStatus, onContextMenuRequest, }: {
|
|
18
17
|
backend: "konva" | "pixi";
|
|
19
18
|
hostRef: RefObject<HTMLDivElement | null>;
|
|
20
19
|
engineRef: RefObject<EditorRenderer | null>;
|
|
@@ -27,10 +26,11 @@ export declare function useEngineLifecycle<TMeta>({ backend, hostRef, engineRef,
|
|
|
27
26
|
viewRef: RefObject<ViewSettings>;
|
|
28
27
|
readOnlyRef: RefObject<boolean>;
|
|
29
28
|
toolRef: RefObject<Tool>;
|
|
30
|
-
|
|
29
|
+
/** 렌더 도형(문서 + 오버라이드 + 장식) — 이미지 전환 시 엔진 재시드용. */
|
|
30
|
+
renderShapesRef: RefObject<EditorShape<TMeta>[]>;
|
|
31
31
|
selRef: RefObject<string[]>;
|
|
32
32
|
maskCanvasRef: RefObject<HTMLCanvasElement | null>;
|
|
33
|
-
|
|
33
|
+
regionOverlayRef: RefObject<RegionOverlayData | null>;
|
|
34
34
|
dimmedRef: RefObject<boolean>;
|
|
35
35
|
syncMinimap: () => void;
|
|
36
36
|
setImage: (size: {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { generateId, SHAPE_TYPE, type ShapeType } from "./_model/geometry";
|
|
2
|
-
export type {
|
|
2
|
+
export type { ExcludedZone, RoiRect } from "./_model/overlays";
|
|
3
|
+
export type { AssistantPrompt, AssistantPromptPoint, BrushScalarMode, ContextMenuItem, DrawSessionChange, DrawSessionKind, EditorAction, EditorAssistant, EditorCanvasViewport, EditorExternalTool, EditorExternalToolContext, EditorOverlayMarker, EditorPointerEvent, EditorSelectionInfo, EditorShape, GuideMaskRaster, KeymapOverrides, MaskPalette, Point, PolygonArea, RectArea, RegionMask, RegionOutlineStyle, ShapeEditorHandle, ShapeEditorProps, ShapeStyle, Tool, Viewport, ViewSettings, } from "./_model/props";
|
|
3
4
|
export { DEFAULT_EDITOR_STRINGS, type EditorStrings, type EditorStringsOverride, } from "./_model/strings";
|
|
4
5
|
export { type BuiltInTool, TOOL } from "./_model/tools";
|
|
5
6
|
export { DEFAULT_VIEW_SETTINGS } from "./_model/viewSettings";
|
|
6
7
|
export { default, default as ShapeEditor } from "./ShapeEditor";
|
|
8
|
+
export { default as ShapeViewer, type ShapeViewerProps, } from "./ShapeViewer";
|