Editor Alignment - Modules Are Structure

Updated editor-web-lib to align with "Modules Are Structure" architecture

⚡ Editor Alignment: Modules Are Structure

Date: November 24, 2025
Session: 11.25.1.1
Status: ✅ Complete


🎯 Objective

Align editor-web-lib with the "Modules Are Structure" architecture as documented in BREAKTHROUGH-MODULES-ARE-STRUCTURE.md.


📚 Key Architecture Principles

What Changed

Old Architecture (5 structural layers):

Space → Universe → Galaxy → World → Page
Each layer is a separate concept with its own API

New Architecture (2 layers - modules with types):

Space → Universe → Modules (with type property)
Everything is a module - type determines behavior

Module Types

type ModuleType =
  | 'galaxy'      // Route collection (cosmic term preserved!)
  | 'world'       // Page container (cosmic term preserved!)
  | 'page'        // Content page
  | 'navigation'  // Nav components
  | 'feature'     // Features (Cart, Auth, etc.)
  | 'widget'      // UI components
  | 'layout'      // Layout wrappers
  | 'data'        // Data providers
  | 'flow'        // Logic flows
  | 'custom';     // Anything!

Key Insight: Galaxy and World are just module types, not separate structural layers!


🔧 Changes Made

1. Removed worldId Signal

Before:

readonly worldId = signal<string | null>(null);

After:

// Removed - worldId concept is deprecated
// Everything is now a module with a type property

Why: worldId and galaxyId are deprecated concepts. Worlds and Galaxies are now just modules with type: 'world' or type: 'galaxy'.


2. Simplified Context Detection

Before:

readonly context = computed(() => {
  const moduleIdValue = this.moduleId();
  const componentIdValue = this.componentId();
  const pageIdValue = this.pageId();
  const universeIdValue = this.universeId();
  const worldIdValue = this.worldId();  // ❌ Deprecated

  if (moduleIdValue) return 'module-builder';
  if (componentIdValue) return 'component-builder';
  if (pageIdValue && universeIdValue) return 'edit-universe-page';  // ❌ Unnecessary distinction
  if (pageIdValue && worldIdValue) return 'edit-world-page';  // ❌ Deprecated
  if (pageIdValue) return 'edit-page';
  return 'blank-canvas';
});

After:

readonly context = computed(() => {
  const moduleIdValue = this.moduleId();
  const componentIdValue = this.componentId();
  const pageIdValue = this.pageId();

  if (moduleIdValue) return 'module-builder';  // Building content for any module type
  if (componentIdValue) return 'component-builder';  // Building reusable component
  if (pageIdValue) return 'edit-page';  // Editing a page module (no world/universe distinction)
  return 'blank-canvas';  // Empty editor
});

Why: No more distinction between edit-universe-page and edit-world-page. A page is just a module with type: 'page'.


3. Updated Comments and Documentation

Added Architecture Comments:

// Route parameters - Aligned with "Modules Are Structure" architecture
// Everything is a module - pages, galaxies, worlds are just module types
readonly pageId = signal<string | null>(null);  // Actually a module ID with type: 'page'
readonly universeId = signal<string | null>(null);  // Universe contains modules
readonly moduleId = signal<string | null>(null);  // Generic module being edited
readonly componentId = signal<string | null>(null);  // Component builder mode
readonly loadedPage = signal<World | null>(null);  // Page data (World is legacy name for Page module)

Module Tree Comment:

// Module Tree: Convert pages to UniversalModule format
// ⚡ Aligned with "Modules Are Structure" architecture
// Pages are modules with type: 'page' - no separate worldId or galaxyId
readonly moduleTree = computed<ModuleTreeNode[]>(() => {
  const pages = this.pageService.pages();
  const modules: UniversalModule[] = pages.map(page => ({
    id: page.id,
    type: 'page',  // ✅ Module type: 'page' (could also be 'galaxy', 'world', etc.)
    // ...
  }));
});

4. Deprecated Legacy Routes

Updated Routes Comment:

/**
 * Universal Editor Routes
 *
 * ⚡ ALIGNED WITH "MODULES ARE STRUCTURE" ARCHITECTURE
 *
 * Key concepts:
 * - Everything is a module (galaxies, worlds, pages are just module types)
 * - pageId is actually a module ID with type: 'page'
 * - No more worldId or galaxyId as separate structural layers
 */

Marked World Route as Deprecated:

// ⚠️ DEPRECATED: World-scoped routes (legacy support only)
// Note: worldId/galaxyId concepts are deprecated - everything is now a module
// This route is kept for backward compatibility but should not be used in new code
// Use 'page/:pageId' instead (pageId is a module ID with type: 'page')
{
  path: 'world/:worldId/page/:pageId',
  loadComponent: () => import('./components/editor-workspace/editor-workspace.component'),
  title: 'Edit Page (Legacy World Route)',
  data: {
    mode: 'edit-page',  // Simplified - no longer distinction between world-page and regular page
    deprecated: true,
    animation: 'slideLeft',
    tool: 'editor'
  }
},

5. Removed worldId Handling in ngOnInit

Before:

if (params['worldId']) {
  this.worldId.set(params['worldId']);
  console.log('🎨 Editor Workspace: World context:', params['worldId']);
}

After:

// Removed - worldId handling is deprecated

Console Log Updated:

console.log('🎨 Editor Workspace initialized:', {
  context: this.context(),
  universeId: this.universeId(),
  moduleId: this.moduleId(),
  componentId: this.componentId(),
  pageId: this.pageId(),
  note: 'worldId/galaxyId deprecated - everything is now a module'
});

📊 Impact Analysis

What Still Works ✅

  1. Editing pages: /editor/page/:pageId → Works perfectly
  2. Blank canvas: /editor → Shows empty editor
  3. Module builder: /editor/module/:moduleId → Generic module editing
  4. Component builder: /editor/component/:componentId → Component creation
  5. Universe context: /editor/universe/:universeId/page/:pageId → Optional context

What Changed ⚠️

  1. No more worldId: Legacy /world/:worldId/page/:pageId route is deprecated (still works for backward compatibility)
  2. Simplified context: No distinction between edit-universe-page and edit-world-page - just edit-page
  3. Module-centric: Everything is now understood as modules with types

What's Removed ❌

  1. worldId signal: Removed from component state
  2. World context detection: No longer checks for worldId parameter
  3. Separate world handling: No special logic for world vs page

🎯 Benefits

1. Alignment with Architecture

2. Simplified Codebase

3. Better Understanding

4. Future-Proof


🚀 Migration Guide

For Developers

If you were using worldId:

// ❌ Old way
navigate(['/space', slug, 'editor', 'world', worldId, 'page', pageId]);

// ✅ New way
navigate(['/space', slug, 'editor', 'page', pageId]);
// Note: pageId is a module ID with type: 'page'

If you were checking world context:

// ❌ Old way
if (context === 'edit-world-page') { /* ... */ }

// ✅ New way
if (context === 'edit-page') { /* ... */ }
// No distinction needed - pages are modules

For Users

No user-facing changes! All existing links and workflows continue to work through legacy route support.


📝 Related Documentation


✅ Verification Checklist


Status: ✅ Complete
Testing: Manual verification in browser (infinite loop fixed, editor loads correctly)
Next Steps:


Created: November 24, 2025 - 4:00 PM
Session: 11.25.1.1
Author: AI Agent (Claude)