solanapolis 1.0.0

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 (202) hide show
  1. package/README.md +518 -0
  2. package/bin/solanapolis.js +197 -0
  3. package/convex/_generated/api.d.ts +175 -0
  4. package/convex/_generated/api.js +23 -0
  5. package/convex/_generated/dataModel.d.ts +60 -0
  6. package/convex/_generated/server.d.ts +143 -0
  7. package/convex/_generated/server.js +93 -0
  8. package/convex/agent/conversation.ts +352 -0
  9. package/convex/agent/embeddingsCache.ts +110 -0
  10. package/convex/agent/memory.ts +450 -0
  11. package/convex/agent/schema.ts +53 -0
  12. package/convex/aiChat.ts +54 -0
  13. package/convex/aiTown/agent.ts +382 -0
  14. package/convex/aiTown/agentDescription.ts +27 -0
  15. package/convex/aiTown/agentInputs.ts +155 -0
  16. package/convex/aiTown/agentOperations.ts +178 -0
  17. package/convex/aiTown/conversation.ts +395 -0
  18. package/convex/aiTown/conversationMembership.ts +38 -0
  19. package/convex/aiTown/game.ts +371 -0
  20. package/convex/aiTown/ids.ts +32 -0
  21. package/convex/aiTown/inputHandler.ts +9 -0
  22. package/convex/aiTown/inputs.ts +25 -0
  23. package/convex/aiTown/insertInput.ts +20 -0
  24. package/convex/aiTown/location.ts +32 -0
  25. package/convex/aiTown/main.ts +154 -0
  26. package/convex/aiTown/movement.ts +189 -0
  27. package/convex/aiTown/player.ts +310 -0
  28. package/convex/aiTown/playerDescription.ts +35 -0
  29. package/convex/aiTown/schema.ts +79 -0
  30. package/convex/aiTown/world.ts +65 -0
  31. package/convex/aiTown/worldMap.ts +74 -0
  32. package/convex/chat.ts +79 -0
  33. package/convex/constants.ts +78 -0
  34. package/convex/convex.config.ts +6 -0
  35. package/convex/crons.ts +89 -0
  36. package/convex/engine/abstractGame.ts +199 -0
  37. package/convex/engine/historicalObject.ts +355 -0
  38. package/convex/engine/schema.ts +56 -0
  39. package/convex/http.ts +36 -0
  40. package/convex/init.ts +110 -0
  41. package/convex/messages.ts +53 -0
  42. package/convex/npcCarAgents.ts +415 -0
  43. package/convex/schema.ts +61 -0
  44. package/convex/streaming.ts +23 -0
  45. package/convex/testing.ts +202 -0
  46. package/convex/tsconfig.json +18 -0
  47. package/convex/util/FastIntegerCompression.ts +221 -0
  48. package/convex/util/assertNever.ts +4 -0
  49. package/convex/util/asyncMap.ts +20 -0
  50. package/convex/util/compression.ts +71 -0
  51. package/convex/util/geometry.ts +132 -0
  52. package/convex/util/isSimpleObject.ts +11 -0
  53. package/convex/util/llm.ts +724 -0
  54. package/convex/util/minheap.ts +38 -0
  55. package/convex/util/object.ts +22 -0
  56. package/convex/util/sleep.ts +3 -0
  57. package/convex/util/types.ts +33 -0
  58. package/convex/util/xxhash.ts +228 -0
  59. package/convex/world.ts +257 -0
  60. package/data/animations/campfire.json +45 -0
  61. package/data/animations/gentlesparkle.json +37 -0
  62. package/data/animations/gentlesplash.json +61 -0
  63. package/data/animations/gentlewaterfall.json +61 -0
  64. package/data/animations/windmill.json +78 -0
  65. package/data/characters.ts +121 -0
  66. package/data/convertMap.js +74 -0
  67. package/data/gentle.js +330 -0
  68. package/data/spritesheets/f1.ts +75 -0
  69. package/data/spritesheets/f2.ts +75 -0
  70. package/data/spritesheets/f3.ts +75 -0
  71. package/data/spritesheets/f4.ts +75 -0
  72. package/data/spritesheets/f5.ts +75 -0
  73. package/data/spritesheets/f6.ts +75 -0
  74. package/data/spritesheets/f7.ts +75 -0
  75. package/data/spritesheets/f8.ts +75 -0
  76. package/data/spritesheets/p1.ts +59 -0
  77. package/data/spritesheets/p2.ts +59 -0
  78. package/data/spritesheets/p3.ts +59 -0
  79. package/data/spritesheets/player.ts +59 -0
  80. package/data/spritesheets/types.ts +26 -0
  81. package/eslint.config.mjs +37 -0
  82. package/next.config.ts +7 -0
  83. package/package.json +85 -0
  84. package/postcss.config.mjs +7 -0
  85. package/public/file.svg +1 -0
  86. package/public/globe.svg +1 -0
  87. package/public/helius-icon.svg +84 -0
  88. package/public/helius-logo.svg +85 -0
  89. package/public/next.svg +1 -0
  90. package/public/plane.glb +0 -0
  91. package/public/vercel.svg +1 -0
  92. package/public/window.svg +1 -0
  93. package/scripts/clear-city.ts +74 -0
  94. package/scripts/seed-wallets.ts +185 -0
  95. package/scripts/setup-webhook.ts +73 -0
  96. package/src/app/api/auth/callback/route.ts +6 -0
  97. package/src/app/api/auth/link-wallet/route.ts +6 -0
  98. package/src/app/api/auth/phantom/route.ts +6 -0
  99. package/src/app/api/broadcast-position/route.ts +59 -0
  100. package/src/app/api/leaderboard/route.ts +85 -0
  101. package/src/app/api/network-stats/route.ts +86 -0
  102. package/src/app/api/parcel-reward/route.ts +181 -0
  103. package/src/app/api/queue-status/route.ts +30 -0
  104. package/src/app/api/snapshots/route.ts +37 -0
  105. package/src/app/api/transactions/enhanced/route.ts +57 -0
  106. package/src/app/api/treasury/route.ts +83 -0
  107. package/src/app/api/wallet/[address]/balances/route.ts +124 -0
  108. package/src/app/api/wallet/[address]/identity/route.ts +32 -0
  109. package/src/app/api/wallet/[address]/route.ts +216 -0
  110. package/src/app/api/wallet/[address]/traded-tokens/route.ts +41 -0
  111. package/src/app/api/wallets/route.ts +68 -0
  112. package/src/app/api/webhooks/helius/route.ts +76 -0
  113. package/src/app/auth/callback/page.tsx +29 -0
  114. package/src/app/favicon.ico +0 -0
  115. package/src/app/globals.css +39 -0
  116. package/src/app/layout.tsx +43 -0
  117. package/src/app/page.tsx +16 -0
  118. package/src/components/AITownNPCs.tsx +206 -0
  119. package/src/components/ActivityFeed.tsx +189 -0
  120. package/src/components/AuthPanel.tsx +163 -0
  121. package/src/components/BeachScene.tsx +280 -0
  122. package/src/components/Building.tsx +138 -0
  123. package/src/components/CesiumFlight.tsx +1768 -0
  124. package/src/components/CesiumGlobe.tsx +616 -0
  125. package/src/components/CitizenCard.tsx +442 -0
  126. package/src/components/CitizenCardModal.tsx +153 -0
  127. package/src/components/CityGrid.tsx +313 -0
  128. package/src/components/CityLandmarks.tsx +427 -0
  129. package/src/components/CityScene.tsx +1289 -0
  130. package/src/components/CitySlotsBadge.tsx +68 -0
  131. package/src/components/CockpitHUD.tsx +460 -0
  132. package/src/components/ConvexWrapper.tsx +19 -0
  133. package/src/components/DubaiDistrict.tsx +630 -0
  134. package/src/components/FlightMiniMap.tsx +133 -0
  135. package/src/components/GameChat.tsx +383 -0
  136. package/src/components/GameHUD.tsx +393 -0
  137. package/src/components/Ground.tsx +14 -0
  138. package/src/components/HowItWorksModal.tsx +251 -0
  139. package/src/components/IngestionBanner.tsx +123 -0
  140. package/src/components/InstancedBuildings.tsx +316 -0
  141. package/src/components/InstancedCars.tsx +504 -0
  142. package/src/components/InstancedCityPlanes.tsx +259 -0
  143. package/src/components/InstancedHouses.tsx +246 -0
  144. package/src/components/InstancedLampPosts.tsx +201 -0
  145. package/src/components/InstancedResidentCars.tsx +357 -0
  146. package/src/components/InstancedRoadDashes.tsx +42 -0
  147. package/src/components/InstancedSkyscrapers.tsx +434 -0
  148. package/src/components/InstancedTrees.tsx +67 -0
  149. package/src/components/LeaderboardPanel.tsx +136 -0
  150. package/src/components/MultiplayerPlanes.tsx +128 -0
  151. package/src/components/NetworkStats.tsx +83 -0
  152. package/src/components/NewBuildingSpotlight.tsx +93 -0
  153. package/src/components/ParcelChallengeBanner.tsx +242 -0
  154. package/src/components/ParcelReward.tsx +191 -0
  155. package/src/components/Park.tsx +42 -0
  156. package/src/components/PhantomWrapper.tsx +22 -0
  157. package/src/components/PixelStreamViewer.tsx +335 -0
  158. package/src/components/PlaneMode.tsx +190 -0
  159. package/src/components/PlayerCar.tsx +211 -0
  160. package/src/components/PlayerPlane.tsx +255 -0
  161. package/src/components/ProjectileRenderer.tsx +249 -0
  162. package/src/components/QueueStatusBanner.tsx +86 -0
  163. package/src/components/RealPlayerTags.tsx +82 -0
  164. package/src/components/SceneLighting.tsx +382 -0
  165. package/src/components/SelectionBeam.tsx +59 -0
  166. package/src/components/SwapPanel.tsx +104 -0
  167. package/src/components/SwapParticles.tsx +237 -0
  168. package/src/components/TreasureGate.tsx +505 -0
  169. package/src/components/WalletPanel.tsx +421 -0
  170. package/src/components/WalletSearch.tsx +244 -0
  171. package/src/components/WelcomeOverlay.tsx +135 -0
  172. package/src/components/WindowTooltip.tsx +498 -0
  173. package/src/context/AuthContext.tsx +230 -0
  174. package/src/lib/bot-detection.ts +125 -0
  175. package/src/lib/building-math.ts +136 -0
  176. package/src/lib/building-shader.ts +253 -0
  177. package/src/lib/car-paths.ts +244 -0
  178. package/src/lib/car-system.ts +182 -0
  179. package/src/lib/city-constants.ts +29 -0
  180. package/src/lib/city-slots.ts +35 -0
  181. package/src/lib/city-zoning.ts +64 -0
  182. package/src/lib/collision-map.ts +147 -0
  183. package/src/lib/day-night.ts +252 -0
  184. package/src/lib/export-card.ts +28 -0
  185. package/src/lib/helius-webhook.ts +90 -0
  186. package/src/lib/helius.ts +74 -0
  187. package/src/lib/house-shader.ts +119 -0
  188. package/src/lib/mock-data.ts +56 -0
  189. package/src/lib/multiplayer-manager.ts +329 -0
  190. package/src/lib/plane-physics.ts +66 -0
  191. package/src/lib/player-car.ts +147 -0
  192. package/src/lib/player-plane.ts +200 -0
  193. package/src/lib/projectile-system.ts +272 -0
  194. package/src/lib/skyscraper-types.ts +52 -0
  195. package/src/lib/sound-engine.ts +464 -0
  196. package/src/lib/supabase-admin.ts +9 -0
  197. package/src/lib/supabase.ts +8 -0
  198. package/src/lib/swap-events.ts +70 -0
  199. package/src/middleware.ts +37 -0
  200. package/src/types/phantom.d.ts +16 -0
  201. package/src/types/wallet.ts +20 -0
  202. package/tsconfig.json +34 -0
@@ -0,0 +1,237 @@
1
+ "use client";
2
+
3
+ import { useEffect, useRef } from "react";
4
+ import { useFrame } from "@react-three/fiber";
5
+ import * as THREE from "three";
6
+
7
+ const MAX_BURSTS = 30;
8
+ const PARTICLES_PER_BURST = 12;
9
+ const TOTAL_PARTICLES = MAX_BURSTS * PARTICLES_PER_BURST;
10
+ const BURST_LIFETIME = 1.8; // seconds
11
+
12
+ interface Burst {
13
+ origin: THREE.Vector3;
14
+ born: number;
15
+ color: THREE.Color;
16
+ }
17
+
18
+ const vertexShader = /* glsl */ `
19
+ attribute float aSize;
20
+ attribute float aLife;
21
+ attribute vec3 aColor;
22
+ varying float vLife;
23
+ varying vec3 vColor;
24
+
25
+ void main() {
26
+ vLife = aLife;
27
+ vColor = aColor;
28
+ vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
29
+ gl_PointSize = aSize * (200.0 / -mvPosition.z);
30
+ gl_Position = projectionMatrix * mvPosition;
31
+ }
32
+ `;
33
+
34
+ const fragmentShader = /* glsl */ `
35
+ varying float vLife;
36
+ varying vec3 vColor;
37
+
38
+ void main() {
39
+ // Soft circle
40
+ vec2 center = gl_PointCoord - 0.5;
41
+ float dist = length(center) * 2.0;
42
+ if (dist > 1.0) discard;
43
+
44
+ float alpha = (1.0 - dist) * vLife;
45
+ alpha *= alpha; // quadratic falloff
46
+
47
+ // Glow effect
48
+ vec3 glow = vColor * (1.0 + vLife * 2.0);
49
+
50
+ gl_FragColor = vec4(glow, alpha * 0.8);
51
+ }
52
+ `;
53
+
54
+ interface SwapParticlesProps {
55
+ swapBurstRef: React.MutableRefObject<Array<{ x: number; y: number; z: number; color: string }>>;
56
+ }
57
+
58
+ /**
59
+ * GPU particle system for swap activity bursts.
60
+ * When a swap event fires, particles burst upward from the building.
61
+ */
62
+ export default function SwapParticles({ swapBurstRef }: SwapParticlesProps) {
63
+ const pointsRef = useRef<THREE.Points>(null);
64
+ const burstsRef = useRef<Burst[]>([]);
65
+ const particleDataRef = useRef<{
66
+ positions: Float32Array;
67
+ sizes: Float32Array;
68
+ baseSizes: Float32Array;
69
+ lives: Float32Array;
70
+ colors: Float32Array;
71
+ velocities: Float32Array;
72
+ material: THREE.ShaderMaterial;
73
+ } | null>(null);
74
+
75
+ if (!particleDataRef.current) {
76
+ const positions = new Float32Array(TOTAL_PARTICLES * 3);
77
+ const sizes = new Float32Array(TOTAL_PARTICLES);
78
+ const baseSizes = new Float32Array(TOTAL_PARTICLES);
79
+ const lives = new Float32Array(TOTAL_PARTICLES);
80
+ const colors = new Float32Array(TOTAL_PARTICLES * 3);
81
+ const velocities = new Float32Array(TOTAL_PARTICLES * 3);
82
+
83
+ // Initialize off-screen
84
+ for (let i = 0; i < TOTAL_PARTICLES; i++) {
85
+ positions[i * 3 + 1] = -1000; // below ground
86
+ }
87
+
88
+ const material = new THREE.ShaderMaterial({
89
+ vertexShader,
90
+ fragmentShader,
91
+ transparent: true,
92
+ depthWrite: false,
93
+ blending: THREE.AdditiveBlending,
94
+ });
95
+
96
+ particleDataRef.current = {
97
+ positions,
98
+ sizes,
99
+ baseSizes,
100
+ lives,
101
+ colors,
102
+ velocities,
103
+ material,
104
+ };
105
+ }
106
+
107
+ const { positions, sizes, baseSizes, lives, colors, velocities, material } = particleDataRef.current;
108
+
109
+ useEffect(() => {
110
+ return () => {
111
+ material.dispose();
112
+ };
113
+ }, [material]);
114
+
115
+ useFrame((state, delta) => {
116
+ const points = pointsRef.current;
117
+ if (!points) return;
118
+
119
+ const elapsed = state.clock.elapsedTime;
120
+ const dt = Math.min(delta, 0.05); // clamp to prevent explosion on tab-switch
121
+
122
+ // Consume pending bursts
123
+ const pending = swapBurstRef.current.splice(0);
124
+ for (const p of pending) {
125
+ if (burstsRef.current.length >= MAX_BURSTS) {
126
+ burstsRef.current.shift();
127
+ }
128
+ burstsRef.current.push({
129
+ origin: new THREE.Vector3(p.x, p.y, p.z),
130
+ born: elapsed,
131
+ color: new THREE.Color(p.color),
132
+ });
133
+ }
134
+
135
+ // Update all particles
136
+ const bursts = burstsRef.current;
137
+ let particleIdx = 0;
138
+
139
+ for (let b = 0; b < bursts.length; b++) {
140
+ const burst = bursts[b];
141
+ const age = elapsed - burst.born;
142
+
143
+ if (age > BURST_LIFETIME) {
144
+ bursts.splice(b, 1);
145
+ b--;
146
+ continue;
147
+ }
148
+
149
+ const life = 1.0 - age / BURST_LIFETIME;
150
+
151
+ for (let p = 0; p < PARTICLES_PER_BURST; p++) {
152
+ if (particleIdx >= TOTAL_PARTICLES) break;
153
+
154
+ const idx = particleIdx * 3;
155
+
156
+ if (age < 0.01) {
157
+ // Initialize particle velocity on first frame
158
+ const angle = (p / PARTICLES_PER_BURST) * Math.PI * 2 + Math.random() * 0.5;
159
+ const speed = 3 + Math.random() * 5;
160
+ const upSpeed = 4 + Math.random() * 6;
161
+
162
+ velocities[idx] = Math.cos(angle) * speed;
163
+ velocities[idx + 1] = upSpeed;
164
+ velocities[idx + 2] = Math.sin(angle) * speed;
165
+
166
+ positions[idx] = burst.origin.x;
167
+ positions[idx + 1] = burst.origin.y;
168
+ positions[idx + 2] = burst.origin.z;
169
+
170
+ // Store initial size seed in sizes array for consistent per-particle sizing
171
+ baseSizes[particleIdx] = 1.5 + Math.random() * 1.5;
172
+ }
173
+
174
+ // Physics update — use actual frame delta
175
+ positions[idx] += velocities[idx] * dt;
176
+ positions[idx + 1] += velocities[idx + 1] * dt;
177
+ positions[idx + 2] += velocities[idx + 2] * dt;
178
+
179
+ // Gravity
180
+ velocities[idx + 1] -= 9.8 * dt;
181
+
182
+ // Particle properties — use stored base size, scale by life
183
+ const baseSize = baseSizes[particleIdx] > 0.01 ? baseSizes[particleIdx] : 2.0;
184
+ sizes[particleIdx] = baseSize * life;
185
+ lives[particleIdx] = life;
186
+ colors[idx] = burst.color.r;
187
+ colors[idx + 1] = burst.color.g;
188
+ colors[idx + 2] = burst.color.b;
189
+
190
+ particleIdx++;
191
+ }
192
+ }
193
+
194
+ // Hide remaining particles
195
+ for (let i = particleIdx; i < TOTAL_PARTICLES; i++) {
196
+ positions[i * 3 + 1] = -1000;
197
+ sizes[i] = 0;
198
+ baseSizes[i] = 0;
199
+ lives[i] = 0;
200
+ }
201
+
202
+ // Update GPU buffers
203
+ const geom = points.geometry;
204
+ const posAttr = geom.getAttribute("position") as THREE.BufferAttribute;
205
+ const sizeAttr = geom.getAttribute("aSize") as THREE.BufferAttribute;
206
+ const lifeAttr = geom.getAttribute("aLife") as THREE.BufferAttribute;
207
+ const colorAttr = geom.getAttribute("aColor") as THREE.BufferAttribute;
208
+
209
+ posAttr.needsUpdate = true;
210
+ sizeAttr.needsUpdate = true;
211
+ lifeAttr.needsUpdate = true;
212
+ colorAttr.needsUpdate = true;
213
+ });
214
+
215
+ return (
216
+ <points ref={pointsRef} frustumCulled={false} material={material}>
217
+ <bufferGeometry>
218
+ <bufferAttribute
219
+ attach="attributes-position"
220
+ args={[positions, 3]}
221
+ />
222
+ <bufferAttribute
223
+ attach="attributes-aSize"
224
+ args={[sizes, 1]}
225
+ />
226
+ <bufferAttribute
227
+ attach="attributes-aLife"
228
+ args={[lives, 1]}
229
+ />
230
+ <bufferAttribute
231
+ attach="attributes-aColor"
232
+ args={[colors, 3]}
233
+ />
234
+ </bufferGeometry>
235
+ </points>
236
+ );
237
+ }