@buley/hexgrid-3d 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/build_log.txt +500 -0
  2. package/build_src_log.txt +8 -0
  3. package/examples/basic-usage.tsx +19 -19
  4. package/package.json +1 -1
  5. package/public/hexgrid-worker.js +2350 -1638
  6. package/site/.eslintrc.json +3 -0
  7. package/site/DEPLOYMENT.md +196 -0
  8. package/site/INDEX.md +127 -0
  9. package/site/QUICK_START.md +86 -0
  10. package/site/README.md +85 -0
  11. package/site/SITE_SUMMARY.md +180 -0
  12. package/site/next.config.js +12 -0
  13. package/site/package.json +26 -0
  14. package/site/src/app/docs/page.tsx +148 -0
  15. package/site/src/app/examples/page.tsx +133 -0
  16. package/site/src/app/globals.css +160 -0
  17. package/site/src/app/layout.tsx +29 -0
  18. package/site/src/app/page.tsx +163 -0
  19. package/site/tsconfig.json +29 -0
  20. package/site/vercel.json +6 -0
  21. package/src/Snapshot.ts +790 -585
  22. package/src/adapters/DashAdapter.ts +57 -0
  23. package/src/adapters.ts +16 -18
  24. package/src/algorithms/AdvancedStatistics.ts +58 -24
  25. package/src/algorithms/BayesianStatistics.ts +43 -12
  26. package/src/algorithms/FlowField.ts +30 -6
  27. package/src/algorithms/FlowField3D.ts +573 -0
  28. package/src/algorithms/FluidSimulation.ts +19 -3
  29. package/src/algorithms/FluidSimulation3D.ts +664 -0
  30. package/src/algorithms/GraphAlgorithms.ts +19 -12
  31. package/src/algorithms/OutlierDetection.ts +72 -38
  32. package/src/algorithms/ParticleSystem.ts +12 -2
  33. package/src/algorithms/ParticleSystem3D.ts +567 -0
  34. package/src/algorithms/index.ts +14 -8
  35. package/src/compat.ts +10 -10
  36. package/src/components/HexGrid.tsx +10 -23
  37. package/src/components/NarrationOverlay.tsx +140 -52
  38. package/src/components/index.ts +2 -1
  39. package/src/features.ts +31 -31
  40. package/src/index.ts +11 -11
  41. package/src/lib/narration.ts +17 -0
  42. package/src/lib/stats-tracker.ts +25 -0
  43. package/src/lib/theme-colors.ts +12 -0
  44. package/src/math/HexCoordinates.ts +849 -4
  45. package/src/math/Matrix4.ts +2 -12
  46. package/src/math/Vector3.ts +49 -1
  47. package/src/math/index.ts +6 -6
  48. package/src/note-adapter.ts +50 -42
  49. package/src/ontology-adapter.ts +30 -23
  50. package/src/stores/uiStore.ts +34 -34
  51. package/src/types/shared-utils.d.ts +10 -0
  52. package/src/types.ts +110 -98
  53. package/src/utils/image-utils.ts +9 -6
  54. package/src/wasm/HexGridWasmWrapper.ts +436 -388
  55. package/src/wasm/index.ts +2 -2
  56. package/src/workers/hexgrid-math.ts +40 -35
  57. package/src/workers/hexgrid-worker.worker.ts +1992 -1018
  58. package/tsconfig.json +21 -14
package/src/types.ts CHANGED
@@ -2,68 +2,69 @@
2
2
  * Type definitions for HexGrid Visualization
3
3
  */
4
4
 
5
- import type { RefObject } from 'react'
6
- import type { HexGridFeatureFlags } from './features'
5
+ import type { RefObject } from 'react';
6
+ import type { HexGridFeatureFlags } from './features';
7
+ export type { HexGridFeatureFlags } from './features';
7
8
 
8
9
  /**
9
10
  * Photo type for HexGrid visualization
10
- *
11
+ *
11
12
  * This is the unified Photo type used throughout the hexgrid-3d package.
12
13
  * It includes all fields needed for display, media playback, and analytics.
13
14
  */
14
15
  export interface Photo {
15
- id: string
16
- title: string
17
-
16
+ id: string;
17
+ title: string;
18
+
18
19
  // Image URLs - imageUrl is primary, url is for backward compatibility
19
- imageUrl: string
20
- url?: string // Alias for imageUrl (backward compatibility)
21
- thumbnailUrl?: string
22
-
20
+ imageUrl: string;
21
+ url?: string; // Alias for imageUrl (backward compatibility)
22
+ thumbnailUrl?: string;
23
+
23
24
  // Display metadata
24
- alt: string
25
- category: string
26
- description?: string
27
-
25
+ alt: string;
26
+ category: string;
27
+ description?: string;
28
+
28
29
  // Source information
29
- source: string
30
- sourceUrl?: string
31
- createdAt?: string
32
-
30
+ source: string;
31
+ sourceUrl?: string;
32
+ createdAt?: string;
33
+
33
34
  // Shop integration
34
- shopUrl?: string
35
- location?: string
36
-
35
+ shopUrl?: string;
36
+ location?: string;
37
+
37
38
  // Media type flags
38
- isVideo?: boolean
39
- videoUrl?: string
40
- isTweet?: boolean
41
- tweetUrl?: string
42
- redditUrl?: string
43
- durationSeconds?: number
44
-
39
+ isVideo?: boolean;
40
+ videoUrl?: string;
41
+ isTweet?: boolean;
42
+ tweetUrl?: string;
43
+ redditUrl?: string;
44
+ durationSeconds?: number;
45
+
45
46
  // Competition/ranking system
46
- velocity?: number // Normalized velocity [0.1, 1.0] for meritocratic competition
47
-
47
+ velocity?: number; // Normalized velocity [0.1, 1.0] for meritocratic competition
48
+
48
49
  // User info
49
- userId?: string
50
- username?: string
51
- platform?: string
52
- author?: string
53
- authorUrl?: string
54
-
50
+ userId?: string;
51
+ username?: string;
52
+ platform?: string;
53
+ author?: string;
54
+ authorUrl?: string;
55
+
55
56
  // Metrics for analytics
56
- views?: number
57
- likes?: number
58
- comments?: number
59
- shares?: number
60
- upvotes?: number
61
- retweets?: number
62
- replies?: number
63
- age_in_hours?: number
64
-
57
+ views?: number;
58
+ likes?: number;
59
+ comments?: number;
60
+ shares?: number;
61
+ upvotes?: number;
62
+ retweets?: number;
63
+ replies?: number;
64
+ age_in_hours?: number;
65
+
65
66
  // Visual
66
- dominantColor?: string
67
+ dominantColor?: string;
67
68
  }
68
69
 
69
70
  /**
@@ -72,81 +73,92 @@ export interface Photo {
72
73
  */
73
74
  export interface GridItem<T = unknown> {
74
75
  // Core identification
75
- id: string
76
- type: string // 'photo' | 'note' | 'emotion' | 'ontology-entity' | 'custom'
76
+ id: string;
77
+ type: string; // 'photo' | 'note' | 'emotion' | 'ontology-entity' | 'custom'
77
78
 
78
79
  // Visual representation (optional - allows non-visual items)
79
- imageUrl?: string
80
- thumbnailUrl?: string
81
- videoUrl?: string
80
+ imageUrl?: string;
81
+ thumbnailUrl?: string;
82
+ videoUrl?: string;
82
83
 
83
84
  // Display metadata
84
- title?: string
85
- alt?: string
86
- description?: string
87
- category?: string
85
+ title?: string;
86
+ alt?: string;
87
+ description?: string;
88
+ category?: string;
88
89
 
89
90
  // Embedded data object (preserves original type)
90
- data?: T
91
+ data?: T;
91
92
 
92
93
  // Ontology metadata (optional, for ontology-aware items)
93
94
  ontologyMetadata?: {
94
- entityId?: string
95
- entityType?: string | string[]
96
- properties?: Record<string, unknown>
95
+ entityId?: string;
96
+ entityType?: string | string[];
97
+ properties?: Record<string, unknown>;
97
98
  provenance?: {
98
- source: string
99
- extractedAt: string
100
- confidence: number
101
- }
102
- }
99
+ source: string;
100
+ extractedAt: string;
101
+ confidence: number;
102
+ };
103
+ };
103
104
 
104
105
  // Grid behavior
105
- velocity?: number
106
- source?: string
107
- sourceUrl?: string
108
- createdAt?: string
106
+ velocity?: number;
107
+ source?: string;
108
+ sourceUrl?: string;
109
+ createdAt?: string;
109
110
 
110
111
  // Metrics (flexible for any data type)
111
- metrics?: Record<string, number>
112
+ metrics?: Record<string, number>;
112
113
 
113
114
  // Legacy Photo fields (for backward compatibility)
114
- url?: string // Maps to imageUrl
115
- userId?: string
116
- username?: string
117
- platform?: string
118
- author?: string
119
- authorUrl?: string
120
- likes?: number
121
- views?: number
122
- comments?: number
123
- dominantColor?: string
115
+ url?: string; // Maps to imageUrl
116
+ userId?: string;
117
+ username?: string;
118
+ platform?: string;
119
+ author?: string;
120
+ authorUrl?: string;
121
+ likes?: number;
122
+ views?: number;
123
+ comments?: number;
124
+ dominantColor?: string;
124
125
  }
125
126
 
126
127
  export interface HexGridProps {
127
- photos: Photo[]
128
- onHexClick?: (photo: Photo) => void
129
- spacing?: number
130
- canvasRef?: RefObject<HTMLCanvasElement>
131
- onLeaderboardUpdate?: (leaderboard: any) => void
132
- autoplayQueueLimit?: number
133
- onAutoplayQueueLimitChange?: (limit: number) => void
134
- modalOpen?: boolean
135
- userId?: string
136
- username?: string
137
- featureFlags?: HexGridFeatureFlags
128
+ photos: Photo[];
129
+ onHexClick?: (photo: Photo) => void;
130
+ spacing?: number;
131
+ canvasRef?: RefObject<HTMLCanvasElement>;
132
+ onLeaderboardUpdate?: (leaderboard: any) => void;
133
+ autoplayQueueLimit?: number;
134
+ onAutoplayQueueLimitChange?: (limit: number) => void;
135
+ modalOpen?: boolean;
136
+ userId?: string;
137
+ username?: string;
138
+ featureFlags?: HexGridFeatureFlags;
139
+ enableEnhanced?: boolean;
140
+ enhancedConfig?: {
141
+ useWasm?: boolean;
142
+ enableParticles?: boolean;
143
+ enableFlowField?: boolean;
144
+ };
145
+ onTerritoryEvent?: (event: {
146
+ type: 'conquest' | 'birth' | 'death';
147
+ toOwner: number;
148
+ fromOwner?: number;
149
+ }) => Promise<void>;
138
150
  }
139
151
 
140
152
  export interface UIState {
141
- debugOpen: boolean
142
- showStats: boolean
143
- cameraOpen: boolean
144
- showNarration: boolean
153
+ debugOpen: boolean;
154
+ showStats: boolean;
155
+ cameraOpen: boolean;
156
+ showNarration: boolean;
145
157
  }
146
158
 
147
159
  export interface WorkerDebug {
148
- curveUDeg: number
149
- curveVDeg: number
150
- batchPerFrame: number
151
- [key: string]: any
160
+ curveUDeg: number;
161
+ curveVDeg: number;
162
+ batchPerFrame: number;
163
+ [key: string]: any;
152
164
  }
@@ -12,14 +12,17 @@
12
12
  */
13
13
  export function getProxiedImageUrl(imageUrl: string): string {
14
14
  if (!imageUrl || typeof imageUrl !== 'string') {
15
- return imageUrl
15
+ return imageUrl;
16
16
  }
17
-
17
+
18
18
  // Only proxy preview.redd.it URLs (they have CORS issues)
19
19
  // external-preview.redd.it URLs work fine, so don't proxy them
20
- if (imageUrl.includes('preview.redd.it') && !imageUrl.includes('external-preview.redd.it')) {
21
- return `/api/proxy-image?url=${encodeURIComponent(imageUrl)}`
20
+ if (
21
+ imageUrl.includes('preview.redd.it') &&
22
+ !imageUrl.includes('external-preview.redd.it')
23
+ ) {
24
+ return `/api/proxy-image?url=${encodeURIComponent(imageUrl)}`;
22
25
  }
23
-
24
- return imageUrl
26
+
27
+ return imageUrl;
25
28
  }