refactor: remove crust related types from the codebase#103
Open
bnimit wants to merge 42 commits into
Open
Conversation
BREAKING CHANGE: Remove all Visualizer/UI-specific types from Core library - Remove infobox field from LayerCommon, NaiveLayer, and LegacyLayer types - Remove DefaultInfobox type and defaultInfobox from selection callbacks - Remove Infobox generation logic from Cesium engine (5 locations) - Delete src/reearthTypes.ts (contained only Visualizer-specific types) - Move utility types (Args, GQLValueType) to appropriate utils files - Update all related tests and remove infobox references - Update version from 0.0.7-beta.0 to 0.1.0-beta.0 Core is now focused solely on map functionality. All Infobox types and related UI logic should be implemented in the Visualizer package. Migration documentation provided in MIGRATION_INFOBOX_REMOVAL.md and TYPES_TO_MOVE_TO_VISUALIZER.ts for consumers to update their code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove Infobox and Crust-related types from Core
Summary
This PR removes all Visualizer/UI-specific types from the Core library, making it focused solely on map functionality. Infobox configuration and UI presentation logic should now be handled by the Visualizer package.
Breaking Changes
Removed Types
Changed Types
LayerCommon - Removed infobox field:
export type LayerCommon = {
id: string;
title?: string;
visible?: boolean;
tags?: Tag[];
creator?: string;
};
LayerSelectionReason & FeatureSelectionReason - Removed defaultInfobox field:
export type LayerSelectionReason = {
reason?: string;
};
LegacyLayer - Removed infobox field and IBP generic parameter:
id: string;
property?: P;
};
Deleted Files
Changes Made
Moved general-purpose utility types to appropriate locations:
Migration Guide
📝 Migration documentation provided in:
Quick Migration Steps
For Visualizer Package:
import { Layer } from "@reearth/core";
import { Infobox } from "./types/infobox";
export type VisualizerLayer = Layer & {
infobox?: Infobox;
};
3. Generate defaultInfobox in Visualizer:
// Before: Core provided defaultInfobox
onLayerSelect={(layerId, featureId, reason) => {
const infobox = reason.defaultInfobox; // ❌ No longer exists
}}
// After: Generate in Visualizer
onLayerSelect={(layerId, featureId, reason, info) => {
const infobox = generateDefaultInfobox(info.feature); // ✅
}}
4. Store infobox separately:
// Option A: Separate map
const [infoboxMap, setInfoboxMap] = useState<Map<string, Infobox>>();
// Option B: Wrapper type
const [visualizerLayers, setVisualizerLayers] = useState<VisualizerLayer[]>();
Testing
Architecture Improvement
This change improves the separation of concerns:
Core no longer generates UI data structures or contains UI-specific types, making it a cleaner and more focused library.