@mint-ui/map 1.2.0-test.70 → 1.2.0-test.72

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.
@@ -30,13 +30,12 @@ var CanvasMarkerLayer = function (props) {
30
30
  var data = props.data,
31
31
  _a = props.cullingMargin,
32
32
  cullingMargin = _a === void 0 ? performance.DEFAULT_CULLING_MARGIN : _a,
33
- _b = props.maxCacheSize,
34
- maxCacheSize = _b === void 0 ? performance.DEFAULT_MAX_CACHE_SIZE : _b,
33
+ onOptimizationDataUpdate = props.onOptimizationDataUpdate,
35
34
  renderBase = props.renderBase,
36
- options = tslib.__rest(props, ["data", "cullingMargin", "maxCacheSize", "renderBase"]); // renderEvent가 있는 경우에만 인터랙션 관련 props 추출
35
+ options = tslib.__rest(props, ["data", "cullingMargin", "onOptimizationDataUpdate", "renderBase"]); // renderEvent가 있는 경우에만 인터랙션 관련 props 추출
37
36
 
38
37
 
39
- var _c = hasRenderEvent && 'renderEvent' in props ? props : {
38
+ var _b = hasRenderEvent && 'renderEvent' in props ? props : {
40
39
  disableInteraction: false,
41
40
  onClick: undefined,
42
41
  onMouseOut: undefined,
@@ -46,15 +45,15 @@ var CanvasMarkerLayer = function (props) {
46
45
  selectedItems: undefined,
47
46
  topStageZIndex: undefined
48
47
  },
49
- _d = _c.disableInteraction,
50
- disableInteraction = _d === void 0 ? false : _d,
51
- onClick = _c.onClick,
52
- onMouseOut = _c.onMouseOut,
53
- onMouseOver = _c.onMouseOver,
54
- renderEvent = _c.renderEvent,
55
- externalSelectedItem = _c.selectedItem,
56
- externalSelectedItems = _c.selectedItems,
57
- rawTopStageZIndex = _c.topStageZIndex; // topStageZIndex가 있으면 hover 최상단 표시 활성화, 없으면 비활성화 (성능 우선)
48
+ _c = _b.disableInteraction,
49
+ disableInteraction = _c === void 0 ? false : _c,
50
+ onClick = _b.onClick,
51
+ onMouseOut = _b.onMouseOut,
52
+ onMouseOver = _b.onMouseOver,
53
+ renderEvent = _b.renderEvent,
54
+ externalSelectedItem = _b.selectedItem,
55
+ externalSelectedItems = _b.selectedItems,
56
+ rawTopStageZIndex = _b.topStageZIndex; // topStageZIndex가 있으면 hover 최상단 표시 활성화, 없으면 비활성화 (성능 우선)
58
57
 
59
58
 
60
59
  var topStageZIndex = rawTopStageZIndex;
@@ -92,24 +91,30 @@ var CanvasMarkerLayer = function (props) {
92
91
  y: 0
93
92
  }); // 드래그 시작 시점의 hover 상태 저장 (드래그 중 hover 고정용)
94
93
 
95
- var dragStartHoveredItemRef = React.useRef(null); // 성능 최적화 Refs
94
+ var dragStartHoveredItemRef = React.useRef(null); // 공유 캐시 사용 (모든 마커 레이어가 공유)
95
+
96
+ var sharedMarkerCache = context$1 === null || context$1 === void 0 ? void 0 : context$1.sharedMarkerCache;
97
+
98
+ if (!sharedMarkerCache) {
99
+ throw new Error('CanvasMarkerLayer must be used within CanvasProvider');
100
+ } // 성능 최적화 Refs
101
+
96
102
 
97
- var offsetCacheRef = React.useRef(new performance.QueueCache(maxCacheSize));
98
103
  var spatialIndexRef = React.useRef(new performance.SpatialHashGrid(performance.SPATIAL_GRID_CELL_SIZE));
99
104
  var boundingBoxCacheRef = React.useRef(new Map());
100
105
  var viewportRef = React.useRef(null); // 뷰포트 영역 계산 (Viewport Culling용)
101
106
 
102
107
  var updateViewport = function () {
103
108
  viewport.updateViewport(stageRef.current, cullingMargin, viewportRef);
104
- }; // 마커 좌표 변환 (위경도 → 화면 좌표, Queue 캐시 사용)
109
+ }; // 마커 좌표 변환 (위경도 → 화면 좌표, 공유 캐시 사용)
105
110
 
106
111
 
107
112
  var getOrComputeMarkerOffset = function (markerData) {
108
- var cached = offsetCacheRef.current.get(markerData.id);
109
- if (cached && !Array.isArray(cached)) return cached;
113
+ var cached = sharedMarkerCache.get(markerData.id);
114
+ if (cached) return cached;
110
115
  var result = utils.computeMarkerOffset(markerData, controller);
111
116
  if (!result) return null;
112
- offsetCacheRef.current.set(markerData.id, result);
117
+ sharedMarkerCache.set(markerData.id, result);
113
118
  return result;
114
119
  }; // 마커 바운딩 박스 계산 (Viewport Culling 및 Hit Test용, 오프셋 지원)
115
120
 
@@ -306,6 +311,24 @@ var CanvasMarkerLayer = function (props) {
306
311
  }
307
312
  });
308
313
  layer.batchDraw();
314
+ }; // 최적화 데이터 업데이트 콜백 호출
315
+
316
+
317
+ var notifyOptimizationData = function () {
318
+ if (!onOptimizationDataUpdate) return; // 공유 캐시에서 마커 타입 항목만 필터링 (Offset 타입만)
319
+
320
+ var allCacheEntries = sharedMarkerCache.getAllEntries();
321
+ var cacheEntries = allCacheEntries.map(function (_a) {
322
+ var key = _a[0],
323
+ value = _a[1];
324
+ return [key, value];
325
+ });
326
+ var spatialGridCells = spatialIndexRef.current.getAllCells();
327
+ onOptimizationDataUpdate({
328
+ cacheEntries: cacheEntries,
329
+ cacheSize: sharedMarkerCache.size(),
330
+ spatialGridCells: spatialGridCells
331
+ });
309
332
  }; // 전체 즉시 렌더링
310
333
 
311
334
 
@@ -321,27 +344,32 @@ var CanvasMarkerLayer = function (props) {
321
344
 
322
345
  if (topStageZIndex !== undefined) {
323
346
  doRenderTop();
324
- }
347
+ } // 최적화 데이터 업데이트 콜백 호출
348
+
349
+
350
+ notifyOptimizationData();
325
351
  }; // 지도 이벤트 핸들러 생성
326
352
 
327
353
 
328
- var _e = hooks.createMapEventHandlers({
354
+ var _d = hooks.createMapEventHandlers({
329
355
  accumTranslateRef: accumTranslateRef,
330
356
  boundingBoxCacheRef: boundingBoxCacheRef,
357
+ clearCache: function () {
358
+ return sharedMarkerCache.clear();
359
+ },
331
360
  containerRef: containerRef,
332
361
  controller: controller,
333
362
  markerRef: markerRef,
334
- offsetCacheRef: offsetCacheRef,
335
363
  options: options,
336
364
  prevCenterOffsetRef: prevCenterOffsetRef,
337
365
  renderAllImmediate: renderAllImmediate
338
366
  }),
339
- handleIdleShared = _e.handleIdle,
340
- handleZoomStart = _e.handleZoomStart,
341
- handleZoomEnd = _e.handleZoomEnd,
342
- handleCenterChangedShared = _e.handleCenterChanged,
343
- handleDragStartShared = _e.handleDragStart,
344
- handleDragEndShared = _e.handleDragEnd; // handleIdle 래핑: topStage transform 제거 추가
367
+ handleIdleShared = _d.handleIdle,
368
+ handleZoomStart = _d.handleZoomStart,
369
+ handleZoomEnd = _d.handleZoomEnd,
370
+ handleCenterChangedShared = _d.handleCenterChanged,
371
+ handleDragStartShared = _d.handleDragStart,
372
+ handleDragEndShared = _d.handleDragEnd; // handleIdle 래핑: topStage transform 제거 추가
345
373
 
346
374
 
347
375
  var handleIdle = function () {
@@ -606,7 +634,7 @@ var CanvasMarkerLayer = function (props) {
606
634
  resizeRafId = requestAnimationFrame(function () {
607
635
  stage.width(mapDiv.offsetWidth);
608
636
  stage.height(mapDiv.offsetHeight);
609
- offsetCacheRef.current.clear();
637
+ sharedMarkerCache.clear();
610
638
  boundingBoxCacheRef.current.clear();
611
639
  updateViewport();
612
640
  renderAllImmediate();
@@ -681,8 +709,8 @@ var CanvasMarkerLayer = function (props) {
681
709
 
682
710
  baseLayer.destroyChildren();
683
711
  eventLayer.destroyChildren();
684
- stage.destroy();
685
- offsetCacheRef.current.clear();
712
+ stage.destroy(); // 공유 캐시는 cleanup 시 clear하지 않음 (다른 레이어가 사용 중일 수 있음)
713
+
686
714
  boundingBoxCacheRef.current.clear();
687
715
  spatialIndexRef.current.clear();
688
716
  };
@@ -898,7 +926,7 @@ var CanvasMarkerLayer = function (props) {
898
926
  x: 0,
899
927
  y: 0
900
928
  };
901
- offsetCacheRef.current.clear();
929
+ sharedMarkerCache.clear();
902
930
  boundingBoxCacheRef.current.clear();
903
931
  selectedItemsMapRef.current = hooks.syncSelectedItems(data, selectedIdsRef.current, selectedItemsMapRef.current);
904
932
  renderAllImmediate();
@@ -1,4 +1,4 @@
1
- import type { MarkerOptions } from '../../../types';
1
+ import type { MarkerOptions, Offset } from '../../../types';
2
2
  import type { CanvasData, CustomRenderBase, CustomRenderEvent } from '../shared';
3
3
  /**
4
4
  * CanvasMarkerLayer Props (renderEvent가 없는 경우 - 인터랙션 불가)
@@ -25,6 +25,12 @@ export interface CanvasMarkerLayerPropsWithoutEvent<T> extends Pick<MarkerOption
25
25
  selectedItem?: never;
26
26
  disableInteraction?: never;
27
27
  topStageZIndex?: never;
28
+ /** 최적화 데이터 콜백 (디버깅/모니터링용) */
29
+ onOptimizationDataUpdate?: (data: {
30
+ cacheSize: number;
31
+ cacheEntries: Array<[string, number[][][][] | Offset]>;
32
+ spatialGridCells: Map<string, CanvasData<T>[]>;
33
+ }) => void;
28
34
  }
29
35
  /**
30
36
  * CanvasMarkerLayer Props (renderEvent가 있는 경우 - 인터랙션 가능)
@@ -57,6 +63,12 @@ export interface CanvasMarkerLayerPropsWithEventWithSelectedItem<T> extends Pick
57
63
  renderEvent: CustomRenderEvent<T>;
58
64
  /** Top Layer의 zIndex (hover된 항목을 최상단에 렌더링하기 위한 레이어) */
59
65
  topStageZIndex?: never;
66
+ /** 최적화 데이터 콜백 (디버깅/모니터링용) */
67
+ onOptimizationDataUpdate?: (data: {
68
+ cacheSize: number;
69
+ cacheEntries: Array<[string, number[][][][] | Offset]>;
70
+ spatialGridCells: Map<string, CanvasData<T>[]>;
71
+ }) => void;
60
72
  }
61
73
  /**
62
74
  * CanvasMarkerLayer Props (renderEvent가 있는 경우 - 인터랙션 가능)
@@ -89,6 +101,12 @@ export interface CanvasMarkerLayerPropsWithEventWithSelectedItems<T> extends Pic
89
101
  renderEvent: CustomRenderEvent<T>;
90
102
  /** Top Layer의 zIndex (hover된 항목을 최상단에 렌더링하기 위한 레이어) */
91
103
  topStageZIndex?: never;
104
+ /** 최적화 데이터 콜백 (디버깅/모니터링용) */
105
+ onOptimizationDataUpdate?: (data: {
106
+ cacheSize: number;
107
+ cacheEntries: Array<[string, number[][][][] | Offset]>;
108
+ spatialGridCells: Map<string, CanvasData<T>[]>;
109
+ }) => void;
92
110
  }
93
111
  /**
94
112
  * CanvasMarkerLayer Props (renderEvent가 있는 경우 - 인터랙션 가능)
@@ -121,6 +139,12 @@ export interface CanvasMarkerLayerPropsWithEventWithoutSelection<T> extends Pick
121
139
  renderEvent: CustomRenderEvent<T>;
122
140
  /** Top Layer의 zIndex (hover된 항목을 최상단에 렌더링하기 위한 레이어) */
123
141
  topStageZIndex?: never;
142
+ /** 최적화 데이터 콜백 (디버깅/모니터링용) */
143
+ onOptimizationDataUpdate?: (data: {
144
+ cacheSize: number;
145
+ cacheEntries: Array<[string, number[][][][] | Offset]>;
146
+ spatialGridCells: Map<string, CanvasData<T>[]>;
147
+ }) => void;
124
148
  }
125
149
  /**
126
150
  * CanvasMarkerLayer Props (renderEvent가 있는 경우 - 인터랙션 가능)
@@ -154,6 +178,12 @@ export interface CanvasMarkerLayerPropsWithEventWithTopStageWithSelectedItem<T>
154
178
  renderEvent: CustomRenderEvent<T>;
155
179
  /** Top Layer의 zIndex (hover된 항목을 최상단에 렌더링하기 위한 레이어) */
156
180
  topStageZIndex: number;
181
+ /** 최적화 데이터 콜백 (디버깅/모니터링용) */
182
+ onOptimizationDataUpdate?: (data: {
183
+ cacheSize: number;
184
+ cacheEntries: Array<[string, number[][][][] | Offset]>;
185
+ spatialGridCells: Map<string, CanvasData<T>[]>;
186
+ }) => void;
157
187
  }
158
188
  /**
159
189
  * CanvasMarkerLayer Props (renderEvent가 있는 경우 - 인터랙션 가능)
@@ -187,6 +217,12 @@ export interface CanvasMarkerLayerPropsWithEventWithTopStageWithSelectedItems<T>
187
217
  renderEvent: CustomRenderEvent<T>;
188
218
  /** Top Layer의 zIndex (hover된 항목을 최상단에 렌더링하기 위한 레이어) */
189
219
  topStageZIndex: number;
220
+ /** 최적화 데이터 콜백 (디버깅/모니터링용) */
221
+ onOptimizationDataUpdate?: (data: {
222
+ cacheSize: number;
223
+ cacheEntries: Array<[string, number[][][][] | Offset]>;
224
+ spatialGridCells: Map<string, CanvasData<T>[]>;
225
+ }) => void;
190
226
  }
191
227
  /**
192
228
  * CanvasMarkerLayer Props (renderEvent가 있는 경우 - 인터랙션 가능)
@@ -220,6 +256,12 @@ export interface CanvasMarkerLayerPropsWithEventWithTopStageWithoutSelection<T>
220
256
  renderEvent: CustomRenderEvent<T>;
221
257
  /** Top Layer의 zIndex (hover된 항목을 최상단에 렌더링하기 위한 레이어) */
222
258
  topStageZIndex: number;
259
+ /** 최적화 데이터 콜백 (디버깅/모니터링용) */
260
+ onOptimizationDataUpdate?: (data: {
261
+ cacheSize: number;
262
+ cacheEntries: Array<[string, number[][][][] | Offset]>;
263
+ spatialGridCells: Map<string, CanvasData<T>[]>;
264
+ }) => void;
223
265
  }
224
266
  /**
225
267
  * CanvasMarkerLayer Props (renderEvent가 있는 경우 - 인터랙션 가능)
@@ -26,18 +26,17 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
26
26
 
27
27
  var CanvasPolygonLayer = function (props) {
28
28
  var data = props.data,
29
- onClick = props.onClick,
30
29
  _a = props.enableMultiSelect,
31
30
  enableMultiSelect = _a === void 0 ? false : _a,
32
31
  _b = props.cullingMargin,
33
32
  cullingMargin = _b === void 0 ? performance.DEFAULT_CULLING_MARGIN : _b,
34
- _c = props.maxCacheSize,
35
- maxCacheSize = _c === void 0 ? performance.DEFAULT_MAX_CACHE_SIZE : _c,
33
+ onClick = props.onClick,
34
+ onOptimizationDataUpdate = props.onOptimizationDataUpdate,
36
35
  externalSelectedItems = props.selectedItems,
37
36
  externalSelectedItem = props.selectedItem,
38
- _d = props.disableInteraction,
39
- disableInteraction = _d === void 0 ? false : _d,
40
- options = tslib.__rest(props, ["data", "onClick", "enableMultiSelect", "cullingMargin", "maxCacheSize", "selectedItems", "selectedItem", "disableInteraction"]); // customStyle은 다른 방식과 함께 사용 가능
37
+ _c = props.disableInteraction,
38
+ disableInteraction = _c === void 0 ? false : _c,
39
+ options = tslib.__rest(props, ["data", "enableMultiSelect", "cullingMargin", "onClick", "onOptimizationDataUpdate", "selectedItems", "selectedItem", "disableInteraction"]); // customStyle은 다른 방식과 함께 사용 가능
41
40
 
42
41
 
43
42
  var hasCustomStyle = 'customStyle' in props && props.customStyle !== undefined;
@@ -80,19 +79,25 @@ var CanvasPolygonLayer = function (props) {
80
79
  y: 0
81
80
  }); // 드래그 시작 시점의 hover 상태 저장 (드래그 중 hover 고정용)
82
81
 
83
- var dragStartHoveredItemRef = React.useRef(null); // 성능 최적화 Refs
82
+ var dragStartHoveredItemRef = React.useRef(null); // 공유 캐시 사용 (모든 폴리곤 레이어가 공유)
83
+
84
+ var sharedPolygonCache = context$1 === null || context$1 === void 0 ? void 0 : context$1.sharedPolygonCache;
85
+
86
+ if (!sharedPolygonCache) {
87
+ throw new Error('CanvasPolygonLayer must be used within CanvasProvider');
88
+ } // 성능 최적화 Refs
89
+
84
90
 
85
- var offsetCacheRef = React.useRef(new performance.QueueCache(maxCacheSize));
86
91
  var spatialIndexRef = React.useRef(new performance.SpatialHashGrid(performance.SPATIAL_GRID_CELL_SIZE));
87
92
  var boundingBoxCacheRef = React.useRef(new Map());
88
- var viewportRef = React.useRef(null); // 폴리곤 좌표 변환 (위경도 → 화면 좌표, Queue 캐시 사용)
93
+ var viewportRef = React.useRef(null); // 폴리곤 좌표 변환 (위경도 → 화면 좌표, 공유 캐시 사용)
89
94
 
90
95
  var getOrComputePolygonOffsets = function (polygonData) {
91
- var cached = offsetCacheRef.current.get(polygonData.id);
92
- if (cached && Array.isArray(cached)) return cached;
96
+ var cached = sharedPolygonCache.get(polygonData.id);
97
+ if (cached) return cached;
93
98
  var result = utils.computePolygonOffsets(polygonData, controller);
94
99
  if (!result) return null;
95
- offsetCacheRef.current.set(polygonData.id, result);
100
+ sharedPolygonCache.set(polygonData.id, result);
96
101
  return result;
97
102
  }; // 폴리곤 바운딩 박스 계산 (Viewport Culling 및 Hit Test용)
98
103
 
@@ -251,6 +256,24 @@ var CanvasPolygonLayer = function (props) {
251
256
  }
252
257
 
253
258
  layer.batchDraw();
259
+ }; // 최적화 데이터 업데이트 콜백 호출
260
+
261
+
262
+ var notifyOptimizationData = function () {
263
+ if (!onOptimizationDataUpdate) return; // 공유 캐시에서 폴리곤 타입 항목만 필터링 (number[][][][] 타입만)
264
+
265
+ var allCacheEntries = sharedPolygonCache.getAllEntries();
266
+ var cacheEntries = allCacheEntries.map(function (_a) {
267
+ var key = _a[0],
268
+ value = _a[1];
269
+ return [key, value];
270
+ });
271
+ var spatialGridCells = spatialIndexRef.current.getAllCells();
272
+ onOptimizationDataUpdate({
273
+ cacheEntries: cacheEntries,
274
+ cacheSize: sharedPolygonCache.size(),
275
+ spatialGridCells: spatialGridCells
276
+ });
254
277
  }; // 전체 즉시 렌더링
255
278
 
256
279
 
@@ -258,27 +281,31 @@ var CanvasPolygonLayer = function (props) {
258
281
  updateViewport();
259
282
  buildSpatialIndex();
260
283
  doRenderBase();
261
- doRenderEvent();
284
+ doRenderEvent(); // 최적화 데이터 업데이트 콜백 호출
285
+
286
+ notifyOptimizationData();
262
287
  }; // 지도 이벤트 핸들러 생성
263
288
 
264
289
 
265
- var _e = hooks.createMapEventHandlers({
290
+ var _d = hooks.createMapEventHandlers({
266
291
  accumTranslateRef: accumTranslateRef,
267
292
  boundingBoxCacheRef: boundingBoxCacheRef,
293
+ clearCache: function () {
294
+ return sharedPolygonCache.clear();
295
+ },
268
296
  containerRef: containerRef,
269
297
  controller: controller,
270
298
  markerRef: markerRef,
271
- offsetCacheRef: offsetCacheRef,
272
299
  options: options,
273
300
  prevCenterOffsetRef: prevCenterOffsetRef,
274
301
  renderAllImmediate: renderAllImmediate
275
302
  }),
276
- handleIdle = _e.handleIdle,
277
- handleZoomStart = _e.handleZoomStart,
278
- handleZoomEnd = _e.handleZoomEnd,
279
- handleCenterChanged = _e.handleCenterChanged,
280
- handleDragStartShared = _e.handleDragStart,
281
- handleDragEndShared = _e.handleDragEnd;
303
+ handleIdle = _d.handleIdle,
304
+ handleZoomStart = _d.handleZoomStart,
305
+ handleZoomEnd = _d.handleZoomEnd,
306
+ handleCenterChanged = _d.handleCenterChanged,
307
+ handleDragStartShared = _d.handleDragStart,
308
+ handleDragEndShared = _d.handleDragEnd;
282
309
 
283
310
  var handleDragStart = function () {
284
311
  handleDragStartShared(); // 드래그 시작 시점의 hover 상태 저장
@@ -462,7 +489,7 @@ var CanvasPolygonLayer = function (props) {
462
489
  resizeRafId = requestAnimationFrame(function () {
463
490
  stage.width(mapDiv.offsetWidth);
464
491
  stage.height(mapDiv.offsetHeight);
465
- offsetCacheRef.current.clear();
492
+ sharedPolygonCache.clear();
466
493
  boundingBoxCacheRef.current.clear();
467
494
  updateViewport();
468
495
  renderAllImmediate();
@@ -525,8 +552,8 @@ var CanvasPolygonLayer = function (props) {
525
552
 
526
553
  baseLayer.destroyChildren();
527
554
  eventLayer.destroyChildren();
528
- stage.destroy();
529
- offsetCacheRef.current.clear();
555
+ stage.destroy(); // 공유 캐시는 cleanup 시 clear하지 않음 (다른 레이어가 사용 중일 수 있음)
556
+
530
557
  boundingBoxCacheRef.current.clear();
531
558
  spatialIndexRef.current.clear();
532
559
  };
@@ -562,7 +589,7 @@ var CanvasPolygonLayer = function (props) {
562
589
  x: 0,
563
590
  y: 0
564
591
  };
565
- offsetCacheRef.current.clear();
592
+ sharedPolygonCache.clear();
566
593
  boundingBoxCacheRef.current.clear();
567
594
  selectedItemsMapRef.current = hooks.syncSelectedItems(data, selectedIdsRef.current, selectedItemsMapRef.current);
568
595
  renderAllImmediate();