/ src / mock / dreamnode-mock-data.ts
dreamnode-mock-data.ts
  1  import { DreamNode, MediaFile, CanvasFile } from '../types/dreamnode';
  2  import { calculateFibonacciSpherePositions } from '../dreamspace/FibonacciSphereLayout';
  3  
  4  /**
  5   * Mock DreamNode data for testing the 3D visualization
  6   * 
  7   * This provides sample data that follows the UDD structure
  8   * without requiring actual Git repositories or file parsing.
  9   */
 10  
 11  // Mock media files for testing
 12  const mockMediaFiles: MediaFile[] = [
 13    {
 14      path: 'symbols/fibonacci.png',
 15      absolutePath: '/mock/symbols/fibonacci.png',
 16      type: 'image/png',
 17      data: 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(`
 18        <svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
 19          <circle cx="50" cy="50" r="40" fill="#00a2ff" stroke="#ffffff" stroke-width="2"/>
 20          <text x="50" y="55" font-family="Arial" font-size="12" fill="white" text-anchor="middle">∞</text>
 21        </svg>
 22      `),
 23      size: 1024
 24    },
 25    {
 26      path: 'symbols/dreamer.png',
 27      absolutePath: '/mock/symbols/dreamer.png',
 28      type: 'image/png',
 29      data: 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(`
 30        <svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
 31          <circle cx="50" cy="50" r="40" fill="#FF644E" stroke="#ffffff" stroke-width="2"/>
 32          <text x="50" y="55" font-family="Arial" font-size="12" fill="white" text-anchor="middle">🧠</text>
 33        </svg>
 34      `),
 35      size: 1024
 36    },
 37    {
 38      path: 'symbols/geometry.png',
 39      absolutePath: '/mock/symbols/geometry.png',
 40      type: 'image/png',
 41      data: 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(`
 42        <svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
 43          <polygon points="50,10 85,75 15,75" fill="#00a2ff" stroke="#ffffff" stroke-width="2"/>
 44        </svg>
 45      `),
 46      size: 1024
 47    },
 48    {
 49      path: 'symbols/pattern.png',
 50      absolutePath: '/mock/symbols/pattern.png',
 51      type: 'image/png',
 52      data: 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(`
 53        <svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
 54          <rect x="25" y="25" width="50" height="50" fill="#00a2ff" stroke="#ffffff" stroke-width="2"/>
 55          <circle cx="50" cy="50" r="15" fill="#ffffff"/>
 56        </svg>
 57      `),
 58      size: 1024
 59    }
 60  ];
 61  
 62  // Mock canvas files (simplified for testing)
 63  const mockCanvasFiles: CanvasFile[] = [
 64    {
 65      path: 'canvas/overview.canvas',
 66      absolutePath: '/mock/canvas/overview.canvas',
 67      content: {
 68        nodes: [
 69          {
 70            id: 'node1',
 71            type: 'text',
 72            x: 0,
 73            y: 0,
 74            width: 200,
 75            height: 100,
 76            text: 'This is a DreamSong about sacred geometry...'
 77          }
 78        ],
 79        edges: []
 80      }
 81    }
 82  ];
 83  
 84  /**
 85   * Generate mock DreamNode data using Fibonacci sphere distribution
 86   * Now uses persistent relationships from store if available
 87   */
 88  export function generateMockDreamNodes(count: number = 12, relationshipData?: Map<string, string[]>): DreamNode[] {
 89    const spherePositions = calculateFibonacciSpherePositions({
 90      radius: 5000, // Updated to match night sky sphere radius
 91      nodeCount: count,
 92      center: [0, 0, 0]
 93    });
 94    
 95    const dreamNodes: DreamNode[] = [];
 96    
 97    for (let i = 0; i < count; i++) {
 98      const [x, y, z] = spherePositions[i].position;
 99      
100      // Alternate between dreams and dreamers
101      const isDream = i % 3 !== 0; // More dreams than dreamers
102      const type = isDream ? 'dream' : 'dreamer';
103      
104      // Select appropriate media
105      const mediaIndex = isDream ? i % 3 : 1; // Dreamers use index 1 (brain emoji)
106      const media = [mockMediaFiles[mediaIndex]];
107      
108      const nodeId = `mock-${type}-${i}`;
109      
110      // Use persistent relationships if available
111      // NEVER generate fallback relationships - this causes non-determinism!
112      const connections = relationshipData?.get(nodeId) || [];
113      
114      dreamNodes.push({
115        id: nodeId,
116        type,
117        name: isDream ? `Dream ${i + 1}` : `Dreamer ${Math.floor(i / 3) + 1}`,
118        position: [x, y, z],
119        dreamTalkMedia: media,
120        dreamSongContent: mockCanvasFiles,
121        liminalWebConnections: connections,
122        repoPath: `/mock/repos/${type}-${i}`,
123        hasUnsavedChanges: false
124      });
125    }
126    
127    return dreamNodes;
128  }
129  
130  
131  /**
132   * Mock data configuration types
133   */
134  export type MockDataConfig = 'single-node' | 'fibonacci-12' | 'fibonacci-50' | 'fibonacci-100';
135  
136  /**
137   * Get mock data based on configuration with optional relationship data
138   */
139  export function getMockDataForConfig(config: MockDataConfig, relationshipData?: Map<string, string[]>): DreamNode[] {
140    // If no relationship data provided, return nodes with empty connections
141    // This prevents non-deterministic generation
142    switch (config) {
143      case 'single-node':
144        return [getSingleTestNode()];
145      case 'fibonacci-12':
146        return generateMockDreamNodes(12, relationshipData);
147      case 'fibonacci-50':
148        return generateMockDreamNodes(50, relationshipData);
149      case 'fibonacci-100':
150        return generateMockDreamNodes(100, relationshipData);
151      default:
152        return [getSingleTestNode()];
153    }
154  }
155  
156  /**
157   * Get a single mock DreamNode on sphere surface for focused testing
158   */
159  export function getSingleTestNode(): DreamNode {
160    // Position on sphere surface - using sphere radius 5000
161    // Place at 90 degrees from intersection point for clear scaling test
162    return {
163      id: 'mock-test-dream',
164      type: 'dream',
165      name: 'Test Dream',
166      position: [5000, 0, 0], // On sphere surface, perpendicular to intersection point
167      dreamTalkMedia: [mockMediaFiles[0]],
168      dreamSongContent: mockCanvasFiles,
169      liminalWebConnections: [],
170      repoPath: '/mock/repos/test-dream',
171      hasUnsavedChanges: false
172    };
173  }
174  
175  /**
176   * Mock DreamNode with no media (test empty state)
177   */
178  export function getEmptyMockDreamNode(): DreamNode {
179    return {
180      id: 'mock-empty-dream',
181      type: 'dream',
182      name: 'Empty Dream',
183      position: [200, 0, 0],
184      dreamTalkMedia: [],
185      dreamSongContent: [],
186      liminalWebConnections: [],
187      repoPath: '/mock/repos/empty-dream',
188      hasUnsavedChanges: false
189    };
190  }