WORLD VS PAGE CLARIFICATION

Ecosistema completo para organización y gestión de contenido con interfaces espaciales

🌍 World vs Page Clarification

Date: November 5, 2025
Status: ✅ Clarified and Documented
Purpose: Resolve confusion between World and Page concepts in EditorService


🚨 The Problem

There was critical confusion in EditorService and throughout the codebase:

This confusion made it impossible to:


✅ The Solution

1. Type Alias for Clarity

Created a Page type alias in page.types.ts:

/**
 * Type alias for clarity: Page = World
 * 
 * Use this type in EditorService and other page-focused code to make it clear
 * that we're working with Pages, not WorldContainers.
 * 
 * WorldContainer (the true "World") contains multiple Pages via pageIds.
 */
export type Page = World;

2. Updated EditorService

EditorService now uses Page type for clarity:

// Before (confusing)
readonly editorState = autoFlashState('editor-state', {
  page: null as World | null, // World? But it's actually a Page!
  // ...
});

// After (clear)
readonly editorState = autoFlashState('editor-state', {
  page: null as Page | null, // ✅ Clear: We're working with a Page
  // ...
});

3. Added Documentation


🏗️ Correct Hierarchy

Universe
  └─ Galaxy
      └─ WorldContainer (the TRUE "World")
          └─ Page (currently named "World" in page.types.ts)
              └─ Widget[]

Key Differences

Concept Purpose Contains Has Layout? Has Widgets?
WorldContainer Group related Pages pageIds: string[] ❌ No ❌ No
Page (current "World") Individual content page widgets: Widget[] ✅ Yes ✅ Yes

📝 Usage Guidelines

In EditorService (and page-focused code):

// ✅ GOOD - Use Page type for clarity
import { Page } from '@libs-foundational/core-models';

setPage(page: Page | null) {
  // Clear: We're setting a Page, not a WorldContainer
}

// ❌ AVOID - Using World directly is confusing
setPage(page: World | null) {
  // Unclear: Is this a Page or a WorldContainer?
}

For WorldContainer operations:

// ✅ Use WorldContainer type from structure-management
import { WorldContainer } from '@structure-management';

const world: WorldContainer = {
  id: 'world-1',
  name: 'Breakfast Menu',
  pageIds: ['page-1', 'page-2', 'page-3'], // References to Pages
  // ...
};

🔄 Migration Path

Phase 1: Type Alias (✅ COMPLETE)

Phase 2: Gradual Migration (Future)

Phase 3: Full Separation (Future)


📚 File Locations


🎯 Summary

  1. World interface = Actually a Page (has widgets, layout)
  2. Page type alias = Clarity (use in EditorService)
  3. WorldContainer = True World (holds multiple Pages)

When editing pages: Use Page type
When managing Worlds: Use WorldContainer type
For backward compatibility: World still works everywhere


✅ Benefits


The confusion is resolved! Use Page type in EditorService and page-focused code for clarity. 🎉