Skip to content

Conversation

@bnimit
Copy link

@bnimit bnimit commented Nov 12, 2025

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

  • ❌ Infobox
  • ❌ InfoboxProperty
  • ❌ InfoboxBlock

  • ❌ PropertyItem
  • ❌ DefaultInfobox
  • ❌ NaiveInfobox
  • ❌ NaiveBlock

Changed Types

LayerCommon - Removed infobox field:
export type LayerCommon = {
id: string;
title?: string;
visible?: boolean;

  • infobox?: Infobox;
    tags?: Tag[];
    creator?: string;
    };

LayerSelectionReason & FeatureSelectionReason - Removed defaultInfobox field:
export type LayerSelectionReason = {
reason?: string;

  • defaultInfobox?: DefaultInfobox;
    };

LegacyLayer - Removed infobox field and IBP generic parameter:

  • export type LegacyLayer<P = any, IBP = any> = {
  • export type LegacyLayer<P = any> = {
    id: string;
    property?: P;
  • infobox?: Infobox;
    };

Deleted Files

  • 🗑️ src/reearthTypes.ts (entire file removed - contained only Visualizer-specific types)

Changes Made

  1. Core Layer Types (src/mantle/types/index.ts)
  • Removed infobox from LayerCommon, NaiveLayerSimple, and NaiveLayerGroup
  • Removed NaiveInfobox and NaiveBlock type definitions
  • Removed imports of Infobox and InfoboxBlock
  1. Selection Callbacks (src/Map/Layers/hooks.ts)
  • Removed DefaultInfobox type definition
  • Removed defaultInfobox field from LayerSelectionReason and FeatureSelectionReason
  • Removed ID generation logic for infobox blocks
  1. Cesium Engine (src/engines/Cesium/)
  • Removed defaultInfobox generation from 5 locations in hooks.ts:
    • Cesium3DTileFeature selection
    • Entity selection with description
    • 3D tile feature click
    • 3D tile point feature click
    • Imagery layer feature click
  • Removed helper functions in utils/utils.ts:
    • getEntityContent() - converted entity properties to infobox content
    • propertiesToTableContent() - internal helper
  • Removed tileProperties() function from hooks.ts
  • Removed unused imports: JulianDate, ImageryLayerFeatureInfo
  1. Legacy Compatibility Layer (src/mantle/compat/)
  • Removed infobox from forward conversion (forward.ts)
  • Removed infobox from backward conversion (backward.ts)
  • Updated LegacyLayer type in types.ts
  1. Type Migration

Moved general-purpose utility types to appropriate locations:

  • Args, Args2, Args3 → src/utils/util.ts (partial function application helpers)
  • GQLValueType enum → src/utils/value.ts (GraphQL value type conversions)
  1. Tests
  • Updated backward.test.ts - removed infobox from test cases
  • Updated forward.test.ts - removed infobox from test cases
  • Updated hooks.test.ts - removed infobox generation tests
  1. Exports
  • Removed DefaultInfobox export from src/Map/Layers/index.tsx
  • Removed DefaultInfobox export from src/Map/index.tsx
  • Removed infobox from layer keys in src/Map/Layers/keys.ts
  1. Version Bump
  • 0.0.7-beta.0 → 0.1.0-beta.0 (breaking change)
  1. Dependencies
  • Upgraded resium from 1.17.4 → 1.18.4

Migration Guide

📝 Migration documentation provided in:

  1. MIGRATION_INFOBOX_REMOVAL.md - Complete guide with code examples
  2. TYPES_TO_MOVE_TO_VISUALIZER.ts - All type definitions to copy to Visualizer

Quick Migration Steps

For Visualizer Package:

  1. Copy types from TYPES_TO_MOVE_TO_VISUALIZER.ts to your Visualizer package
  2. Create Visualizer layer type:
    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

  • ✅ Build: Successful
  • ✅ Tests: All 135 tests passing
  • ✅ TypeScript: No type errors
  • ✅ Resium 1.18.4: Compatible

Architecture Improvement

This change improves the separation of concerns:

  • Core: Pure map engine abstraction (Cesium, data sources, rendering)
  • Visualizer: UI presentation layer (infobox, widgets, UI state)

Core no longer generates UI data structures or contains UI-specific types, making it a cleaner and more focused library.

bnimit and others added 3 commits November 12, 2025 14:00
   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.
@bnimit bnimit changed the title chore:remove crust related types refactor:remove crust related types Nov 12, 2025
@bnimit bnimit changed the title refactor:remove crust related types refactor: remove crust related types from the codebase Nov 12, 2025
@bnimit bnimit changed the base branch from beta to alpha November 13, 2025 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants