From 16fce9da7adc2bf2ca9e73be46c538bc4e58f5e4 Mon Sep 17 00:00:00 2001 From: taDuc Date: Tue, 12 May 2026 04:43:50 +0700 Subject: [PATCH] refactor: reorganize project structure by migrating engine and geometry utilities into a structured map directory --- src/app/editor/[id]/page.tsx | 14 +++++++------- src/app/page.tsx | 8 ++++---- src/app/user/role-upgrade/page.tsx | 2 +- src/components/calendar/Calendar.tsx | 2 +- src/uhm/api/geometries.ts | 2 +- src/uhm/components/Editor.tsx | 2 +- src/uhm/components/Map.tsx | 4 ++-- .../components/editor/BackgroundLayersPanel.tsx | 4 ++-- .../components/editor/SelectedGeometryPanel.tsx | 4 ++-- src/uhm/components/editor/UndoListPanel.tsx | 2 +- src/uhm/components/map/mapUtils.ts | 8 ++++---- src/uhm/components/map/useMapInteraction.ts | 16 ++++++++-------- src/uhm/components/map/useMapLayers.ts | 8 ++++---- src/uhm/components/map/useMapSync.ts | 6 +++--- src/uhm/components/ui/TimelineBar.tsx | 2 +- src/uhm/components/wiki/WikiSidebarPanel.tsx | 2 +- .../background/backgroundVisibilityStorage.ts | 2 +- src/uhm/lib/editor/entity/entityBinding.ts | 2 +- src/uhm/lib/editor/session/sessionTypes.ts | 2 +- .../editor/session/useBackgroundSessionState.ts | 2 +- src/uhm/lib/editor/session/useTimelineState.ts | 2 +- src/uhm/lib/editor/snapshot/editorSnapshot.ts | 4 ++-- .../{ => editor/state}/useEditorSessionState.ts | 0 src/uhm/lib/{ => editor/state}/useEditorState.ts | 0 .../lib/{engine => map/engines}/circleEngine.ts | 4 ++-- .../lib/{engine => map/engines}/drawingEngine.ts | 6 +++--- .../lib/{engine => map/engines}/editingEngine.ts | 2 +- .../lib/{engine => map/engines}/engineTypes.ts | 0 .../lib/{engine => map/engines}/lineEngine.ts | 4 ++-- .../lib/{engine => map/engines}/pathEngine.ts | 4 ++-- .../lib/{engine => map/engines}/pointEngine.ts | 4 ++-- .../{engine => map/engines}/selectingEngine.ts | 2 +- src/uhm/lib/{engine => map/engines}/snapUtils.ts | 0 src/uhm/lib/{ => map}/geo/constants.ts | 0 src/uhm/lib/{ => map/geo}/geoTypeMap.json | 0 src/uhm/lib/{ => map/geo}/geoTypeMap.ts | 2 +- src/uhm/lib/{ => map/styles}/backgroundLayers.ts | 0 src/uhm/lib/map/{ => styles}/style.ts | 0 src/uhm/lib/{ => utils}/entityTypeOptions.ts | 0 src/uhm/lib/{ => utils}/id.ts | 0 src/uhm/lib/{ => utils}/timeline.ts | 0 src/uhm/types/geo.ts | 2 +- 42 files changed, 65 insertions(+), 65 deletions(-) rename src/uhm/lib/{ => editor/state}/useEditorSessionState.ts (100%) rename src/uhm/lib/{ => editor/state}/useEditorState.ts (100%) rename src/uhm/lib/{engine => map/engines}/circleEngine.ts (98%) rename src/uhm/lib/{engine => map/engines}/drawingEngine.ts (95%) rename src/uhm/lib/{engine => map/engines}/editingEngine.ts (99%) rename src/uhm/lib/{engine => map/engines}/engineTypes.ts (100%) rename src/uhm/lib/{engine => map/engines}/lineEngine.ts (96%) rename src/uhm/lib/{engine => map/engines}/pathEngine.ts (96%) rename src/uhm/lib/{engine => map/engines}/pointEngine.ts (89%) rename src/uhm/lib/{engine => map/engines}/selectingEngine.ts (99%) rename src/uhm/lib/{engine => map/engines}/snapUtils.ts (100%) rename src/uhm/lib/{ => map}/geo/constants.ts (100%) rename src/uhm/lib/{ => map/geo}/geoTypeMap.json (100%) rename src/uhm/lib/{ => map/geo}/geoTypeMap.ts (96%) rename src/uhm/lib/{ => map/styles}/backgroundLayers.ts (100%) rename src/uhm/lib/map/{ => styles}/style.ts (100%) rename src/uhm/lib/{ => utils}/entityTypeOptions.ts (100%) rename src/uhm/lib/{ => utils}/id.ts (100%) rename src/uhm/lib/{ => utils}/timeline.ts (100%) diff --git a/src/app/editor/[id]/page.tsx b/src/app/editor/[id]/page.tsx index 25eb9e8..0da64c9 100644 --- a/src/app/editor/[id]/page.tsx +++ b/src/app/editor/[id]/page.tsx @@ -22,22 +22,22 @@ import { Feature, Geometry, useEditorState, -} from "@/uhm/lib/useEditorState"; -import { GEO_TYPE_KEYS, geoTypeCodeToTypeKey } from "@/uhm/lib/geoTypeMap"; +} from "@/uhm/lib/editor/state/useEditorState"; +import { GEO_TYPE_KEYS, geoTypeCodeToTypeKey } from "@/uhm/lib/map/geo/geoTypeMap"; import { BackgroundLayerId, BackgroundLayerVisibility, DEFAULT_BACKGROUND_LAYER_VISIBILITY, HIDDEN_BACKGROUND_LAYER_VISIBILITY, -} from "@/uhm/lib/backgroundLayers"; +} from "@/uhm/lib/map/styles/backgroundLayers"; import { ENTITY_TYPE_OPTIONS, -} from "@/uhm/lib/entityTypeOptions"; +} from "@/uhm/lib/utils/entityTypeOptions"; import { EntityFormState, GeometryMetaFormState, useEditorSessionState, -} from "@/uhm/lib/useEditorSessionState"; +} from "@/uhm/lib/editor/state/useEditorSessionState"; import { getDefaultTypeIdForFeature, normalizeFeatureBindingIds, @@ -58,8 +58,8 @@ import { persistBackgroundLayerVisibility, } from "@/uhm/lib/editor/background/backgroundVisibilityStorage"; import { useSectionCommands } from "@/uhm/lib/editor/section/useSectionCommands"; -import { EMPTY_FEATURE_COLLECTION } from "@/uhm/lib/geo/constants"; -import { FIXED_TIMELINE_RANGE, clampYearToFixedRange } from "@/uhm/lib/timeline"; +import { EMPTY_FEATURE_COLLECTION } from "@/uhm/lib/map/geo/constants"; +import { FIXED_TIMELINE_RANGE, clampYearToFixedRange } from "@/uhm/lib/utils/timeline"; import { useFeatureCommands } from "./featureCommands"; import { deleteSubmission } from "@/uhm/api/sections"; import type { WikiSnapshot } from "@/uhm/types/wiki"; diff --git a/src/app/page.tsx b/src/app/page.tsx index 4964cdd..17ee1a8 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -15,14 +15,14 @@ import { type BackgroundLayerVisibility, DEFAULT_BACKGROUND_LAYER_VISIBILITY, HIDDEN_BACKGROUND_LAYER_VISIBILITY, -} from "@/uhm/lib/backgroundLayers"; +} from "@/uhm/lib/map/styles/backgroundLayers"; import { loadBackgroundLayerVisibilityFromStorage, persistBackgroundLayerVisibility, } from "@/uhm/lib/editor/background/backgroundVisibilityStorage"; -import { EMPTY_FEATURE_COLLECTION, WORLD_BBOX } from "@/uhm/lib/geo/constants"; -import { GEO_TYPE_KEYS } from "@/uhm/lib/geoTypeMap"; -import { clampYearToFixedRange, TIMELINE_DEBOUNCE_MS } from "@/uhm/lib/timeline"; +import { EMPTY_FEATURE_COLLECTION, WORLD_BBOX } from "@/uhm/lib/map/geo/constants"; +import { GEO_TYPE_KEYS } from "@/uhm/lib/map/geo/geoTypeMap"; +import { clampYearToFixedRange, TIMELINE_DEBOUNCE_MS } from "@/uhm/lib/utils/timeline"; import type { FeatureCollection } from "@/uhm/types/geo"; const CURRENT_YEAR = new Date().getUTCFullYear(); diff --git a/src/app/user/role-upgrade/page.tsx b/src/app/user/role-upgrade/page.tsx index de0de40..bc589ce 100644 --- a/src/app/user/role-upgrade/page.tsx +++ b/src/app/user/role-upgrade/page.tsx @@ -16,7 +16,7 @@ import "yet-another-react-lightbox/styles.css"; import "yet-another-react-lightbox/plugins/captions.css"; import { createHistorianCV } from "@/service/historianService"; import { toast } from "sonner"; -import { newId } from "@/uhm/lib/id"; +import { newId } from "@/uhm/lib/utils/id"; import Swal from "sweetalert2"; import { PresignedUrlResponse } from "@/interface/media"; diff --git a/src/components/calendar/Calendar.tsx b/src/components/calendar/Calendar.tsx index 58b79dc..8c9e3f0 100644 --- a/src/components/calendar/Calendar.tsx +++ b/src/components/calendar/Calendar.tsx @@ -12,7 +12,7 @@ import { } from "@fullcalendar/core"; import { useModal } from "@/hooks/useModal"; import { Modal } from "@/components/ui/modal"; -import { newId } from "@/uhm/lib/id"; +import { newId } from "@/uhm/lib/utils/id"; interface CalendarEvent extends EventInput { extendedProps: { diff --git a/src/uhm/api/geometries.ts b/src/uhm/api/geometries.ts index f27e04e..0ba7621 100644 --- a/src/uhm/api/geometries.ts +++ b/src/uhm/api/geometries.ts @@ -2,7 +2,7 @@ import { API_ENDPOINTS } from "@/uhm/api/config"; import { requestJson } from "@/uhm/api/http"; import type { GeometriesBBoxQuery } from "@/uhm/types/api"; import type { Feature, FeatureCollection, FeatureProperties, Geometry } from "@/uhm/types/geo"; -import { geoTypeCodeToTypeKey } from "@/uhm/lib/geoTypeMap"; +import { geoTypeCodeToTypeKey } from "@/uhm/lib/map/geo/geoTypeMap"; export type { GeometriesBBoxQuery } from "@/uhm/types/api"; diff --git a/src/uhm/components/Editor.tsx b/src/uhm/components/Editor.tsx index 0f0d01c..e23a85d 100644 --- a/src/uhm/components/Editor.tsx +++ b/src/uhm/components/Editor.tsx @@ -1,7 +1,7 @@ "use client"; import { useState } from "react"; -import type { UndoAction } from "@/uhm/lib/useEditorState"; +import type { UndoAction } from "@/uhm/lib/editor/state/useEditorState"; import type { EditorMode } from "@/uhm/lib/editor/session/sessionTypes"; import { ProjectPanel } from "./editor/ProjectPanel"; diff --git a/src/uhm/components/Map.tsx b/src/uhm/components/Map.tsx index f52c75f..8bd3dda 100644 --- a/src/uhm/components/Map.tsx +++ b/src/uhm/components/Map.tsx @@ -3,8 +3,8 @@ import { type CSSProperties, useEffect, useRef } from "react"; import "maplibre-gl/dist/maplibre-gl.css"; -import { Feature, FeatureCollection, Geometry } from "@/uhm/lib/useEditorState"; -import { BackgroundLayerVisibility } from "@/uhm/lib/backgroundLayers"; +import { Feature, FeatureCollection, Geometry } from "@/uhm/lib/editor/state/useEditorState"; +import { BackgroundLayerVisibility } from "@/uhm/lib/map/styles/backgroundLayers"; import type { EditorMode } from "@/uhm/lib/editor/session/sessionTypes"; import { useMapInstance } from "./map/useMapInstance"; diff --git a/src/uhm/components/editor/BackgroundLayersPanel.tsx b/src/uhm/components/editor/BackgroundLayersPanel.tsx index 00e7215..7fa8470 100644 --- a/src/uhm/components/editor/BackgroundLayersPanel.tsx +++ b/src/uhm/components/editor/BackgroundLayersPanel.tsx @@ -5,8 +5,8 @@ import { BACKGROUND_LAYER_OPTIONS, BackgroundLayerId, BackgroundLayerVisibility, -} from "@/uhm/lib/backgroundLayers"; -import { GEO_TYPE_KEYS } from "@/uhm/lib/geoTypeMap"; +} from "@/uhm/lib/map/styles/backgroundLayers"; +import { GEO_TYPE_KEYS } from "@/uhm/lib/map/geo/geoTypeMap"; type Props = { visibility: BackgroundLayerVisibility; diff --git a/src/uhm/components/editor/SelectedGeometryPanel.tsx b/src/uhm/components/editor/SelectedGeometryPanel.tsx index 7e3b6ca..8de45d6 100644 --- a/src/uhm/components/editor/SelectedGeometryPanel.tsx +++ b/src/uhm/components/editor/SelectedGeometryPanel.tsx @@ -2,14 +2,14 @@ import { type CSSProperties, useMemo, useState } from "react"; import { Entity } from "@/uhm/api/entities"; -import { Feature } from "@/uhm/lib/useEditorState"; +import { Feature } from "@/uhm/lib/editor/state/useEditorState"; import { EntityGeometryPreset, EntityTypeGroupId, EntityTypeOption, findEntityTypeOption, groupEntityTypeOptions, -} from "@/uhm/lib/entityTypeOptions"; +} from "@/uhm/lib/utils/entityTypeOptions"; import type { GeometryMetaFormState } from "@/uhm/lib/editor/session/sessionTypes"; type Props = { diff --git a/src/uhm/components/editor/UndoListPanel.tsx b/src/uhm/components/editor/UndoListPanel.tsx index cb44a6c..6fc3580 100644 --- a/src/uhm/components/editor/UndoListPanel.tsx +++ b/src/uhm/components/editor/UndoListPanel.tsx @@ -1,4 +1,4 @@ -import type { UndoAction } from "@/uhm/lib/useEditorState"; +import type { UndoAction } from "@/uhm/lib/editor/state/useEditorState"; import { Panel } from "./Panel"; type UndoListPanelProps = { diff --git a/src/uhm/components/map/mapUtils.ts b/src/uhm/components/map/mapUtils.ts index 2837a62..6de7cc9 100644 --- a/src/uhm/components/map/mapUtils.ts +++ b/src/uhm/components/map/mapUtils.ts @@ -1,6 +1,6 @@ import maplibregl from "maplibre-gl"; -import { BACKGROUND_LAYER_OPTIONS, BackgroundLayerVisibility } from "@/uhm/lib/backgroundLayers"; -import { Feature, FeatureCollection, Geometry } from "@/uhm/lib/useEditorState"; +import { BACKGROUND_LAYER_OPTIONS, BackgroundLayerVisibility } from "@/uhm/lib/map/styles/backgroundLayers"; +import { Feature, FeatureCollection, Geometry } from "@/uhm/lib/editor/state/useEditorState"; import { DEFAULT_POINT_ICON_ID, FEATURE_STATE_SOURCE_IDS, @@ -10,9 +10,9 @@ import { RASTER_BASE_LAYER_ID, RASTER_BASE_SOURCE_ID, } from "@/uhm/lib/map/constants"; -import { PATH_RENDER_BY_TYPE } from "@/uhm/lib/map/style"; +import { PATH_RENDER_BY_TYPE } from "@/uhm/lib/map/styles/style"; import { getRasterTileTemplateUrl } from "@/uhm/api/tiles"; -import { newId } from "@/uhm/lib/id"; +import { newId } from "@/uhm/lib/utils/id"; export function applyBackgroundLayerVisibility( map: maplibregl.Map, diff --git a/src/uhm/components/map/useMapInteraction.ts b/src/uhm/components/map/useMapInteraction.ts index 6ab6f29..e9ff5c7 100644 --- a/src/uhm/components/map/useMapInteraction.ts +++ b/src/uhm/components/map/useMapInteraction.ts @@ -1,13 +1,13 @@ import { useEffect, useRef } from "react"; import maplibregl from "maplibre-gl"; -import { initDrawing } from "@/uhm/lib/engine/drawingEngine"; -import { initSelect } from "@/uhm/lib/engine/selectingEngine"; -import { initPoint } from "@/uhm/lib/engine/pointEngine"; -import { initLine } from "@/uhm/lib/engine/lineEngine"; -import { initPath } from "@/uhm/lib/engine/pathEngine"; -import { initCircle } from "@/uhm/lib/engine/circleEngine"; -import { createEditingEngine } from "@/uhm/lib/engine/editingEngine"; -import { Feature, FeatureCollection, Geometry } from "@/uhm/lib/useEditorState"; +import { initDrawing } from "@/uhm/lib/map/engines/drawingEngine"; +import { initSelect } from "@/uhm/lib/map/engines/selectingEngine"; +import { initPoint } from "@/uhm/lib/map/engines/pointEngine"; +import { initLine } from "@/uhm/lib/map/engines/lineEngine"; +import { initPath } from "@/uhm/lib/map/engines/pathEngine"; +import { initCircle } from "@/uhm/lib/map/engines/circleEngine"; +import { createEditingEngine } from "@/uhm/lib/map/engines/editingEngine"; +import { Feature, FeatureCollection, Geometry } from "@/uhm/lib/editor/state/useEditorState"; import { EditorMode } from "@/uhm/lib/editor/session/sessionTypes"; import { buildClientFeatureId, getSelectableLayers } from "./mapUtils"; import { MapHoverPayload } from "../Map"; diff --git a/src/uhm/components/map/useMapLayers.ts b/src/uhm/components/map/useMapLayers.ts index ef0ffd4..0ca6e58 100644 --- a/src/uhm/components/map/useMapLayers.ts +++ b/src/uhm/components/map/useMapLayers.ts @@ -8,8 +8,8 @@ import { POLYGON_FILL_BY_TYPE, POLYGON_OPACITY_BY_TYPE, POLYGON_STROKE_BY_TYPE, -} from "@/uhm/lib/map/style"; -import { EMPTY_FEATURE_COLLECTION } from "@/uhm/lib/geo/constants"; +} from "@/uhm/lib/map/styles/style"; +import { EMPTY_FEATURE_COLLECTION } from "@/uhm/lib/map/geo/constants"; import { PATH_ARROW_ICON_ID, PATH_ARROW_SOURCE_ID } from "@/uhm/lib/map/constants"; import { addPointSymbolLayer, @@ -17,8 +17,8 @@ import { buildTypeMatchExpression, ensurePathArrowIcon, } from "./mapUtils"; -import { BackgroundLayerVisibility } from "@/uhm/lib/backgroundLayers"; -import { FeatureCollection } from "@/uhm/lib/useEditorState"; +import { BackgroundLayerVisibility } from "@/uhm/lib/map/styles/backgroundLayers"; +import { FeatureCollection } from "@/uhm/lib/editor/state/useEditorState"; export function getBaseMapStyle(): maplibregl.StyleSpecification { return { diff --git a/src/uhm/components/map/useMapSync.ts b/src/uhm/components/map/useMapSync.ts index 407e340..2eebc6a 100644 --- a/src/uhm/components/map/useMapSync.ts +++ b/src/uhm/components/map/useMapSync.ts @@ -1,8 +1,8 @@ import { useCallback, useEffect, useRef } from "react"; import maplibregl from "maplibre-gl"; -import { FeatureCollection } from "@/uhm/lib/useEditorState"; -import { BackgroundLayerVisibility } from "@/uhm/lib/backgroundLayers"; -import { EMPTY_FEATURE_COLLECTION } from "@/uhm/lib/geo/constants"; +import { FeatureCollection } from "@/uhm/lib/editor/state/useEditorState"; +import { BackgroundLayerVisibility } from "@/uhm/lib/map/styles/backgroundLayers"; +import { EMPTY_FEATURE_COLLECTION } from "@/uhm/lib/map/geo/constants"; import { FEATURE_STATE_SOURCE_IDS, PATH_ARROW_SOURCE_ID } from "@/uhm/lib/map/constants"; import { applyBackgroundLayerVisibility, diff --git a/src/uhm/components/ui/TimelineBar.tsx b/src/uhm/components/ui/TimelineBar.tsx index 6e7ea58..2396544 100644 --- a/src/uhm/components/ui/TimelineBar.tsx +++ b/src/uhm/components/ui/TimelineBar.tsx @@ -1,6 +1,6 @@ "use client"; -import { FIXED_TIMELINE_END_YEAR, FIXED_TIMELINE_START_YEAR, clampYearValue } from "@/uhm/lib/timeline"; +import { FIXED_TIMELINE_END_YEAR, FIXED_TIMELINE_START_YEAR, clampYearValue } from "@/uhm/lib/utils/timeline"; type Props = { year: number; diff --git a/src/uhm/components/wiki/WikiSidebarPanel.tsx b/src/uhm/components/wiki/WikiSidebarPanel.tsx index 05b22cd..d6f59f0 100644 --- a/src/uhm/components/wiki/WikiSidebarPanel.tsx +++ b/src/uhm/components/wiki/WikiSidebarPanel.tsx @@ -9,7 +9,7 @@ import Button from "@/components/ui/button/Button"; import Label from "@/components/form/Label"; import type { WikiSnapshot } from "@/uhm/types/wiki"; -import { newId } from "@/uhm/lib/id"; +import { newId } from "@/uhm/lib/utils/id"; import type ReactQuill from "react-quill-new"; import { checkWikiSlugExists, fetchWikiBySlug, searchWikisByTitle, type Wiki } from "@/uhm/api/wikis"; diff --git a/src/uhm/lib/editor/background/backgroundVisibilityStorage.ts b/src/uhm/lib/editor/background/backgroundVisibilityStorage.ts index 07c45e5..26204bf 100644 --- a/src/uhm/lib/editor/background/backgroundVisibilityStorage.ts +++ b/src/uhm/lib/editor/background/backgroundVisibilityStorage.ts @@ -2,7 +2,7 @@ import { BACKGROUND_LAYER_OPTIONS, BackgroundLayerVisibility, DEFAULT_BACKGROUND_LAYER_VISIBILITY, -} from "@/uhm/lib/backgroundLayers"; +} from "@/uhm/lib/map/styles/backgroundLayers"; const BACKGROUND_LAYER_VISIBILITY_STORAGE_KEY = "uhm.backgroundLayerVisibility.v1"; diff --git a/src/uhm/lib/editor/entity/entityBinding.ts b/src/uhm/lib/editor/entity/entityBinding.ts index c0ed90d..5ca5c82 100644 --- a/src/uhm/lib/editor/entity/entityBinding.ts +++ b/src/uhm/lib/editor/entity/entityBinding.ts @@ -1,7 +1,7 @@ import type { Entity } from "@/uhm/types/entities"; import type { Feature, FeatureProperties } from "@/uhm/types/geo"; import { normalizeFeatureEntityIds } from "@/uhm/lib/editor/snapshot/editorSnapshot"; -import { newId } from "@/uhm/lib/id"; +import { newId } from "@/uhm/lib/utils/id"; export function mergeEntitySearchResults( remoteRows: Entity[], diff --git a/src/uhm/lib/editor/session/sessionTypes.ts b/src/uhm/lib/editor/session/sessionTypes.ts index b1687eb..d8f71d9 100644 --- a/src/uhm/lib/editor/session/sessionTypes.ts +++ b/src/uhm/lib/editor/session/sessionTypes.ts @@ -1,4 +1,4 @@ -import type { EntityGeometryPreset } from "@/uhm/lib/entityTypeOptions"; +import type { EntityGeometryPreset } from "@/uhm/lib/utils/entityTypeOptions"; export type EditorMode = | "idle" diff --git a/src/uhm/lib/editor/session/useBackgroundSessionState.ts b/src/uhm/lib/editor/session/useBackgroundSessionState.ts index 6c9f350..378ed44 100644 --- a/src/uhm/lib/editor/session/useBackgroundSessionState.ts +++ b/src/uhm/lib/editor/session/useBackgroundSessionState.ts @@ -2,7 +2,7 @@ import { useState } from "react"; import { BackgroundLayerVisibility, HIDDEN_BACKGROUND_LAYER_VISIBILITY, -} from "@/uhm/lib/backgroundLayers"; +} from "@/uhm/lib/map/styles/backgroundLayers"; export function useBackgroundSessionState() { // Trạng thái bật/tắt layer nền (khởi tạo default hidden; sẽ load từ storage ở page). diff --git a/src/uhm/lib/editor/session/useTimelineState.ts b/src/uhm/lib/editor/session/useTimelineState.ts index 56fad4f..13a001f 100644 --- a/src/uhm/lib/editor/session/useTimelineState.ts +++ b/src/uhm/lib/editor/session/useTimelineState.ts @@ -1,6 +1,6 @@ import { useState } from "react"; import type { TimelineRange } from "@/uhm/lib/editor/session/sessionTypes"; -import { clampYearValue } from "@/uhm/lib/timeline"; +import { clampYearValue } from "@/uhm/lib/utils/timeline"; type Options = { currentYear: number; diff --git a/src/uhm/lib/editor/snapshot/editorSnapshot.ts b/src/uhm/lib/editor/snapshot/editorSnapshot.ts index e78cd8a..79eb505 100644 --- a/src/uhm/lib/editor/snapshot/editorSnapshot.ts +++ b/src/uhm/lib/editor/snapshot/editorSnapshot.ts @@ -1,5 +1,5 @@ -import { DEFAULT_ENTITY_TYPE_ID } from "@/uhm/lib/entityTypeOptions"; -import { geoTypeCodeToTypeKey, typeKeyToGeoTypeCode } from "@/uhm/lib/geoTypeMap"; +import { DEFAULT_ENTITY_TYPE_ID } from "@/uhm/lib/utils/entityTypeOptions"; +import { geoTypeCodeToTypeKey, typeKeyToGeoTypeCode } from "@/uhm/lib/map/geo/geoTypeMap"; import type { Change } from "@/uhm/lib/editor/draft/editorTypes"; import type { EntitySnapshot } from "@/uhm/types/entities"; import type { EntitySnapshotOperation } from "@/uhm/types/entities"; diff --git a/src/uhm/lib/useEditorSessionState.ts b/src/uhm/lib/editor/state/useEditorSessionState.ts similarity index 100% rename from src/uhm/lib/useEditorSessionState.ts rename to src/uhm/lib/editor/state/useEditorSessionState.ts diff --git a/src/uhm/lib/useEditorState.ts b/src/uhm/lib/editor/state/useEditorState.ts similarity index 100% rename from src/uhm/lib/useEditorState.ts rename to src/uhm/lib/editor/state/useEditorState.ts diff --git a/src/uhm/lib/engine/circleEngine.ts b/src/uhm/lib/map/engines/circleEngine.ts similarity index 98% rename from src/uhm/lib/engine/circleEngine.ts rename to src/uhm/lib/map/engines/circleEngine.ts index b08eceb..673b9e5 100644 --- a/src/uhm/lib/engine/circleEngine.ts +++ b/src/uhm/lib/map/engines/circleEngine.ts @@ -1,6 +1,6 @@ import maplibregl from "maplibre-gl"; -import { Geometry } from "@/uhm/lib/useEditorState"; -import type { ModeGetter } from "@/uhm/lib/engine/engineTypes"; +import { Geometry } from "@/uhm/lib/editor/state/useEditorState"; +import type { ModeGetter } from "@/uhm/lib/map/engines/engineTypes"; const EARTH_RADIUS_METERS = 6371008.8; const CIRCLE_SEGMENTS = 72; diff --git a/src/uhm/lib/engine/drawingEngine.ts b/src/uhm/lib/map/engines/drawingEngine.ts similarity index 95% rename from src/uhm/lib/engine/drawingEngine.ts rename to src/uhm/lib/map/engines/drawingEngine.ts index 733b8b3..ed5c6ef 100644 --- a/src/uhm/lib/engine/drawingEngine.ts +++ b/src/uhm/lib/map/engines/drawingEngine.ts @@ -1,7 +1,7 @@ import maplibregl from "maplibre-gl"; -import { Geometry } from "@/uhm/lib/useEditorState"; -import type { ModeGetter } from "@/uhm/lib/engine/engineTypes"; -import { snapToNearestGeometry } from "@/uhm/lib/engine/snapUtils"; +import { Geometry } from "@/uhm/lib/editor/state/useEditorState"; +import type { ModeGetter } from "@/uhm/lib/map/engines/engineTypes"; +import { snapToNearestGeometry } from "@/uhm/lib/map/engines/snapUtils"; // Khởi tạo engine vẽ polygon tự do theo chuỗi click. export function initDrawing( diff --git a/src/uhm/lib/engine/editingEngine.ts b/src/uhm/lib/map/engines/editingEngine.ts similarity index 99% rename from src/uhm/lib/engine/editingEngine.ts rename to src/uhm/lib/map/engines/editingEngine.ts index 7d64fef..64d38c1 100644 --- a/src/uhm/lib/engine/editingEngine.ts +++ b/src/uhm/lib/map/engines/editingEngine.ts @@ -1,5 +1,5 @@ import maplibregl from "maplibre-gl"; -import { Geometry } from "@/uhm/lib/useEditorState"; +import { Geometry } from "@/uhm/lib/editor/state/useEditorState"; export type EditingHandle = { id: string | number; diff --git a/src/uhm/lib/engine/engineTypes.ts b/src/uhm/lib/map/engines/engineTypes.ts similarity index 100% rename from src/uhm/lib/engine/engineTypes.ts rename to src/uhm/lib/map/engines/engineTypes.ts diff --git a/src/uhm/lib/engine/lineEngine.ts b/src/uhm/lib/map/engines/lineEngine.ts similarity index 96% rename from src/uhm/lib/engine/lineEngine.ts rename to src/uhm/lib/map/engines/lineEngine.ts index 7401d03..7993b9b 100644 --- a/src/uhm/lib/engine/lineEngine.ts +++ b/src/uhm/lib/map/engines/lineEngine.ts @@ -1,6 +1,6 @@ import maplibregl from "maplibre-gl"; -import { Geometry } from "@/uhm/lib/useEditorState"; -import type { ModeGetter } from "@/uhm/lib/engine/engineTypes"; +import { Geometry } from "@/uhm/lib/editor/state/useEditorState"; +import type { ModeGetter } from "@/uhm/lib/map/engines/engineTypes"; const EMPTY_PREVIEW: GeoJSON.FeatureCollection = { type: "FeatureCollection", diff --git a/src/uhm/lib/engine/pathEngine.ts b/src/uhm/lib/map/engines/pathEngine.ts similarity index 96% rename from src/uhm/lib/engine/pathEngine.ts rename to src/uhm/lib/map/engines/pathEngine.ts index 5e71f63..7a125dd 100644 --- a/src/uhm/lib/engine/pathEngine.ts +++ b/src/uhm/lib/map/engines/pathEngine.ts @@ -1,6 +1,6 @@ import maplibregl from "maplibre-gl"; -import { Geometry } from "@/uhm/lib/useEditorState"; -import type { ModeGetter } from "@/uhm/lib/engine/engineTypes"; +import { Geometry } from "@/uhm/lib/editor/state/useEditorState"; +import type { ModeGetter } from "@/uhm/lib/map/engines/engineTypes"; const EMPTY_PREVIEW: GeoJSON.FeatureCollection = { type: "FeatureCollection", diff --git a/src/uhm/lib/engine/pointEngine.ts b/src/uhm/lib/map/engines/pointEngine.ts similarity index 89% rename from src/uhm/lib/engine/pointEngine.ts rename to src/uhm/lib/map/engines/pointEngine.ts index 74dfe6b..304eb41 100644 --- a/src/uhm/lib/engine/pointEngine.ts +++ b/src/uhm/lib/map/engines/pointEngine.ts @@ -1,6 +1,6 @@ import maplibregl from "maplibre-gl"; -import { Geometry } from "@/uhm/lib/useEditorState"; -import type { ModeGetter } from "@/uhm/lib/engine/engineTypes"; +import { Geometry } from "@/uhm/lib/editor/state/useEditorState"; +import type { ModeGetter } from "@/uhm/lib/map/engines/engineTypes"; // Khởi tạo engine thêm point bằng click đơn. export function initPoint( diff --git a/src/uhm/lib/engine/selectingEngine.ts b/src/uhm/lib/map/engines/selectingEngine.ts similarity index 99% rename from src/uhm/lib/engine/selectingEngine.ts rename to src/uhm/lib/map/engines/selectingEngine.ts index 78dc1d6..6375f43 100644 --- a/src/uhm/lib/engine/selectingEngine.ts +++ b/src/uhm/lib/map/engines/selectingEngine.ts @@ -1,5 +1,5 @@ import maplibregl from "maplibre-gl"; -import type { ModeGetter } from "@/uhm/lib/engine/engineTypes"; +import type { ModeGetter } from "@/uhm/lib/map/engines/engineTypes"; // Khởi tạo engine chọn feature và context menu edit/delete. export function initSelect( diff --git a/src/uhm/lib/engine/snapUtils.ts b/src/uhm/lib/map/engines/snapUtils.ts similarity index 100% rename from src/uhm/lib/engine/snapUtils.ts rename to src/uhm/lib/map/engines/snapUtils.ts diff --git a/src/uhm/lib/geo/constants.ts b/src/uhm/lib/map/geo/constants.ts similarity index 100% rename from src/uhm/lib/geo/constants.ts rename to src/uhm/lib/map/geo/constants.ts diff --git a/src/uhm/lib/geoTypeMap.json b/src/uhm/lib/map/geo/geoTypeMap.json similarity index 100% rename from src/uhm/lib/geoTypeMap.json rename to src/uhm/lib/map/geo/geoTypeMap.json diff --git a/src/uhm/lib/geoTypeMap.ts b/src/uhm/lib/map/geo/geoTypeMap.ts similarity index 96% rename from src/uhm/lib/geoTypeMap.ts rename to src/uhm/lib/map/geo/geoTypeMap.ts index b9123ce..e6f2c42 100644 --- a/src/uhm/lib/geoTypeMap.ts +++ b/src/uhm/lib/map/geo/geoTypeMap.ts @@ -1,4 +1,4 @@ -import rows from "@/uhm/lib/geoTypeMap.json"; +import rows from "@/uhm/lib/map/geo/geoTypeMap.json"; export type GeoTypeMapRow = { type_key: string; diff --git a/src/uhm/lib/backgroundLayers.ts b/src/uhm/lib/map/styles/backgroundLayers.ts similarity index 100% rename from src/uhm/lib/backgroundLayers.ts rename to src/uhm/lib/map/styles/backgroundLayers.ts diff --git a/src/uhm/lib/map/style.ts b/src/uhm/lib/map/styles/style.ts similarity index 100% rename from src/uhm/lib/map/style.ts rename to src/uhm/lib/map/styles/style.ts diff --git a/src/uhm/lib/entityTypeOptions.ts b/src/uhm/lib/utils/entityTypeOptions.ts similarity index 100% rename from src/uhm/lib/entityTypeOptions.ts rename to src/uhm/lib/utils/entityTypeOptions.ts diff --git a/src/uhm/lib/id.ts b/src/uhm/lib/utils/id.ts similarity index 100% rename from src/uhm/lib/id.ts rename to src/uhm/lib/utils/id.ts diff --git a/src/uhm/lib/timeline.ts b/src/uhm/lib/utils/timeline.ts similarity index 100% rename from src/uhm/lib/timeline.ts rename to src/uhm/lib/utils/timeline.ts diff --git a/src/uhm/types/geo.ts b/src/uhm/types/geo.ts index 34bf0b3..74cb541 100644 --- a/src/uhm/types/geo.ts +++ b/src/uhm/types/geo.ts @@ -1,4 +1,4 @@ -import type { EntityGeometryPreset } from "@/uhm/lib/entityTypeOptions"; +import type { EntityGeometryPreset } from "@/uhm/lib/utils/entityTypeOptions"; export type Geometry = | { type: "Point"; coordinates: [number, number] }