@aivex/ui 1.2.0-dev.24 → 1.2.0-dev.25

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.
@@ -1,5 +1,6 @@
1
1
  import type { CSSProperties, ReactNode } from "react";
2
2
  import { type EditorShape } from "./_model/geometry";
3
+ import { type EditorImageDiagnosis } from "./_model/imageDiagnosis";
3
4
  import { type GuideMaskRaster, type MaskPalette, type RegionMask } from "./_model/overlays";
4
5
  /**
5
6
  * ShapeViewer가 지원하는 EditorShape **표시 서브셋 계약**:
@@ -36,7 +37,8 @@ export interface ShapeViewerProps<TMeta = unknown> {
36
37
  lazy?: boolean;
37
38
  className?: string;
38
39
  style?: CSSProperties;
39
- renderImageState?: (status: "loading" | "error") => ReactNode;
40
+ /** error일 때 diagnosis에 원인 분류·기술 근거가 실린다(진단 전/실패 시 null). */
41
+ renderImageState?: (status: "loading" | "error", diagnosis?: EditorImageDiagnosis | null) => ReactNode;
40
42
  }
41
43
  /** 목록·카드 미리보기를 위한 상호작용 없는 Canvas2D 도형 뷰어. */
42
44
  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;
@@ -1,11 +1,15 @@
1
1
  import type { ReactNode } from "react";
2
+ import type { EditorImageDiagnosis, EditorImageErrorKind } from "../_model/imageDiagnosis";
2
3
  /**
3
4
  * 이미지 로딩/에러 상태 오버레이. 에디터 영역 전체를 덮는다.
4
5
  * 호스트가 renderImageState로 커스텀하지 않으면 기본 스피너/에러 메시지를 그린다.
6
+ * 에러에 진단(diagnosis)이 있으면 원인 안내문과 기술 근거를 함께 표시한다.
5
7
  */
6
- export declare function ImageStateOverlay({ status, render, loadingLabel, errorLabel, }: {
8
+ export declare function ImageStateOverlay({ status, error, render, loadingLabel, errorLabel, errorHints, }: {
7
9
  status: "loading" | "error";
8
- render?: (status: "loading" | "error") => ReactNode;
10
+ error?: EditorImageDiagnosis | null;
11
+ render?: (status: "loading" | "error", diagnosis?: EditorImageDiagnosis | null) => ReactNode;
9
12
  loadingLabel?: string;
10
13
  errorLabel?: string;
14
+ errorHints?: Record<EditorImageErrorKind, string>;
11
15
  }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,23 @@
1
+ export type EditorImageErrorKind = "mixed-content" | "cors" | "auth" | "forbidden" | "not-found" | "server-error" | "http" | "offline" | "network" | "unexpected-content" | "decode" | "csp-img" | "csp-eval" | "webgl" | "renderer-init" | "unknown";
2
+ /** 이미지 로드 실패 분류 + 기술 근거(에러 오버레이·문의 대응용). */
3
+ export type EditorImageDiagnosis = {
4
+ kind: EditorImageErrorKind;
5
+ /** 언어 중립 기술 근거(상태코드·오리진 등). 분류별 안내문은 EditorStrings 몫. */
6
+ detail: string;
7
+ };
8
+ /** 테스트 전용 — 전역 fetch/Image 스텁과 메모가 얽히지 않게 비운다. */
9
+ export declare function clearImageDiagnosisMemo(): void;
10
+ /**
11
+ * 이미지 로드가 최종 실패했을 때 원인을 프로브로 분류한다. 회색 캔버스만 보이는
12
+ * 현장에서 콘솔 없이 원인을 특정하기 위한 것. 프로브는 cache:"no-store"로 보내
13
+ * HTTP 캐시를 건드리지 않는다.
14
+ */
15
+ export declare function diagnoseImageLoadFailure(url: string): Promise<EditorImageDiagnosis>;
16
+ /** WebGL 컨텍스트 생성 가능 여부 — 하드웨어 가속 꺼짐·보안 모드·GPU 차단 판별. */
17
+ export declare function isWebglAvailable(): boolean;
18
+ /**
19
+ * 렌더러 엔진 초기화/렌더 중 예외 분류 — 네트워크 단계가 아니라 프로브 없이
20
+ * 에러 메시지와 WebGL 가용성으로 판정한다(pixi는 CSP unsafe-eval 차단 시
21
+ * 명시적 에러를 던진다).
22
+ */
23
+ export declare function diagnoseEngineInitFailure(error: unknown): EditorImageDiagnosis;
@@ -0,0 +1,13 @@
1
+ /** 소스 하나로 이미지 로드를 시도한다(실패 시 null — 호출부가 폴백/진단 결정). */
2
+ export declare function loadImageElement(src: string, options?: {
3
+ crossOrigin?: boolean;
4
+ }): Promise<HTMLImageElement | null>;
5
+ /**
6
+ * CORS-clean 이미지 로드 — `<img crossOrigin>` 직행이 기본이다. blob을 쓰지
7
+ * 않으므로 CSP img-src blob:·보안 확장의 blob 간섭 여지가 없다. 실패하면 앱
8
+ * 어딘가의 no-cors `<img>`가 채운 오염 캐시(CORS 헤더 없는 응답)일 수 있으므로,
9
+ * cache:"reload" fetch로 캐시 항목을 정상 CORS 응답으로 수리한 뒤 한 번 더
10
+ * 시도한다. 그래도 실패면 null — 호출부가 상태/진단(imageDiagnosis.ts)을 처리한다.
11
+ * Konva/Pixi 렌더러와 ShapeViewer가 공유한다.
12
+ */
13
+ export declare function loadCorsImage(url: string): Promise<HTMLImageElement | null>;
@@ -1,5 +1,6 @@
1
1
  import type { ReactNode, Ref } from "react";
2
2
  import type { EditorShape, Point, ShapeInteraction, ShapeStyle, Viewport } from "./geometry";
3
+ import type { EditorImageDiagnosis } from "./imageDiagnosis";
3
4
  import type { EditorAction, KeymapOverrides } from "./keymap";
4
5
  import type { GuideMaskRaster, MaskPalette, PolygonArea, RectArea, RegionMask, RegionOutlineStyle } from "./overlays";
5
6
  import type { EditorStringsOverride } from "./strings";
@@ -180,8 +181,9 @@ export interface ShapeEditorProps<TMeta = unknown, TMarkerMeta = unknown> {
180
181
  clipboardScope?: string;
181
182
  /**
182
183
  * 이미지 로딩/에러 상태 오버레이 커스텀. 미지정 시 기본 스피너/에러 메시지.
184
+ * error일 때 diagnosis에 원인 분류·기술 근거가 실린다(진단 실패 시 null).
183
185
  */
184
- renderImageState?: (status: "loading" | "error") => ReactNode;
186
+ renderImageState?: (status: "loading" | "error", diagnosis?: EditorImageDiagnosis | null) => ReactNode;
185
187
  /**
186
188
  * true면 이미지를 반투명 검정으로 덮는다(레이블은 위에 밝게). 도메인 무관 —
187
189
  * 호스트가 "라벨링 완료/잠금" 등 상태에서 켠다(기존 Editor의 isLabelingCompleted 딤).
@@ -1,3 +1,4 @@
1
+ import type { EditorImageErrorKind } from "./imageDiagnosis";
1
2
  /**
2
3
  * 에디터 UI 문자열(도메인 무관). 기본값은 한국어이며, 호스트가 `strings` prop으로
3
4
  * 부분 재정의해 i18n/제품별 문구를 주입한다. next-intl 등 프레임워크에 비종속 —
@@ -45,6 +46,8 @@ export interface EditorStrings {
45
46
  };
46
47
  imageLoading: string;
47
48
  imageLoadError: string;
49
+ /** 이미지 로드 실패 분류별 안내문(진단 오버레이). */
50
+ imageErrorHints: Record<EditorImageErrorKind, string>;
48
51
  }
49
52
  export declare const DEFAULT_EDITOR_STRINGS: EditorStrings;
50
53
  /** 그룹 단위 부분 재정의(그룹 안 키도 부분 지정 가능). */
@@ -72,7 +72,7 @@ export declare class KonvaRenderer implements EditorRenderer {
72
72
  }, imageSize?: {
73
73
  width: number;
74
74
  height: number;
75
- }): Promise<void>;
75
+ }): Promise<boolean>;
76
76
  clearImage(): void;
77
77
  setFilter(brightness: number, contrast: number): void;
78
78
  setRenderDefaults(defaults: Partial<ShapeRenderStyleDefaults>): void;
@@ -1,3 +1,4 @@
1
+ import "pixi.js/unsafe-eval";
1
2
  import { Application, ColorMatrixFilter, Container, type FederatedPointerEvent } from "pixi.js";
2
3
  import { type EditorShape, type Point, type ShapeStyle } from "../_model/geometry";
3
4
  import type { RegionOverlayData } from "../_model/overlays";
@@ -26,6 +27,7 @@ export declare class PixiRenderer {
26
27
  imageHeight: number;
27
28
  private imageTileTextures;
28
29
  private imageLoadToken;
30
+ private tileSize;
29
31
  private overlayTextures;
30
32
  private region;
31
33
  private regionDimMaskG;
@@ -85,7 +87,7 @@ export declare class PixiRenderer {
85
87
  }, imageSize?: {
86
88
  width: number;
87
89
  height: number;
88
- }): Promise<void>;
90
+ }): Promise<boolean>;
89
91
  setFilter(brightness: number, contrast: number): void;
90
92
  setRenderDefaults(defaults: Partial<ShapeRenderStyleDefaults>): void;
91
93
  /** 편집모드 정점 핸들 반지름 — 선두께에 비례(기본 두께 2에서 기존 크기 5 유지). */
@@ -66,6 +66,8 @@ export interface EditorRenderer<TMeta = unknown> {
66
66
  * 이미지를 늘려 그린다(썸네일 표시 + 원본 좌표 편집). 미지정 시 실제 픽셀 크기.
67
67
  * imageSize를 주면 이미지를 좌표공간 전체가 아니라 그 크기로(원점 기준) 그린다 —
68
68
  * 이미지가 좌표공간의 일부만 덮는 경우(다중 해상도 좌표계 등).
69
+ * 반환값은 텍스처 반영 여부 — false면 로드 실패(호출부가 상태/진단을 처리한다).
70
+ * 무효화된 로드(더 최신 요청·destroy)는 true — 결과는 호출부 취소 가드가 버린다.
69
71
  */
70
72
  setImage(url: string, coordinateSize?: {
71
73
  width: number;
@@ -73,7 +75,7 @@ export interface EditorRenderer<TMeta = unknown> {
73
75
  }, imageSize?: {
74
76
  width: number;
75
77
  height: number;
76
- }): Promise<void>;
78
+ }): Promise<boolean>;
77
79
  /** 이미지 타일 즉시 제거(문서 전환 시 이전 이미지 잔상 방지). 도형/오버레이는 별도. */
78
80
  clearImage(): void;
79
81
  setFilter(brightness: number, contrast: number): void;
@@ -1,5 +1,6 @@
1
1
  import { type RefObject } from "react";
2
2
  import type { EditorShape, Point } from "../_model/geometry";
3
+ import { type EditorImageDiagnosis } from "../_model/imageDiagnosis";
3
4
  import type { RegionOverlayData } from "../_model/overlays";
4
5
  import { type Tool } from "../_model/tools";
5
6
  import type { ViewSettings } from "../_model/viewSettings";
@@ -25,7 +26,12 @@ export declare function classifyImageTransition({ currentDocId, documentId, load
25
26
  }): ImageTransition;
26
27
  /**
27
28
  * 렌더러 엔진 생명주기 — backend당 1회 생성/파괴, 이미지 전환(문서 전환 vs 화질 스왑),
28
- * 휠 줌/팬·우클릭 메뉴 네이티브 리스너, 이미지 로딩 상태 프리로드를 소유한다.
29
+ * 휠 줌/팬·우클릭 메뉴 네이티브 리스너를 소유한다.
30
+ *
31
+ * 이미지 로딩/에러 상태는 별도 프리로드가 아니라 setImage 결과에서 파생한다 —
32
+ * 판정 경로가 캔버스와 다르면(no-cors <img> 등) CORS가 깨진 환경에서 캔버스만
33
+ * 실패하고 상태는 ready가 되는 어긋남이 생긴다. 실패 시 diagnoseImageLoadFailure로
34
+ * 원인을 분류해 함께 올린다.
29
35
  *
30
36
  * 이미지 변경은 엔진을 재사용해 setImage로 스왑한다. 문서 전환 중에는 이전 문서의
31
37
  * 이미지·도형을 비우지만 캔버스 DOM과 렌더러 인스턴스는 유지한다.
@@ -66,7 +72,8 @@ export declare function useEngineLifecycle<TMeta>({ backend, hostRef, engineRef,
66
72
  } | null) => void;
67
73
  setImageVisible: (visible: boolean) => void;
68
74
  setReady: (ready: boolean) => void;
69
- setImageStatus: (status: EditorImageStatus) => void;
75
+ /** error일 때만 diagnosis가 실린다(원인 분류 + 기술 근거). */
76
+ setImageStatus: (status: EditorImageStatus, diagnosis?: EditorImageDiagnosis) => void;
70
77
  onContextMenuRequest: (menu: {
71
78
  x: number;
72
79
  y: number;
@@ -1,4 +1,5 @@
1
1
  export { generateId, SHAPE_TYPE, type ShapeType } from "./_model/geometry";
2
+ export type { EditorImageDiagnosis, EditorImageErrorKind } from "./_model/imageDiagnosis";
2
3
  export type { ExcludedZone, RoiRect } from "./_model/overlays";
3
4
  export type { AssistantPrompt, AssistantPromptPoint, BrushScalarMode, ContextMenuItem, DrawSessionChange, DrawSessionKind, EditorAction, EditorAssistant, EditorCanvasViewport, EditorExternalTool, EditorExternalToolContext, EditorOverlayMarker, EditorPointerEvent, EditorSelectionInfo, EditorShape, GuideMaskRaster, KeymapOverrides, MaskPalette, MinimapPosition, Point, PolygonArea, RectArea, RegionMask, RegionOutlineStyle, ShapeEditorDocument, ShapeEditorHandle, ShapeEditorProps, ShapeStyle, Tool, Viewport, ViewSettings, } from "./_model/props";
4
5
  export { DEFAULT_EDITOR_STRINGS, type EditorStrings, type EditorStringsOverride, } from "./_model/strings";