@almadar/ui 5.42.0 → 5.44.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.
@@ -6,7 +6,7 @@ import { twMerge } from 'tailwind-merge';
6
6
  import { EventBusContext, useTraitScope, OrbitalProvider, TraitScopeProvider, VerificationProvider } from '@almadar/ui/providers';
7
7
  import { createLogger, isLogLevelEnabled } from '@almadar/logger';
8
8
  import * as LucideIcons2 from 'lucide-react';
9
- import { Loader2, X, Lightbulb, CheckCircle, List, Printer, ChevronRight, ChevronLeft, GitBranch, Pencil, Eye, Plus, ArrowRight, Trash, Code, FileText, WrapText, Check, Copy, RotateCcw, Play, Terminal, XCircle, AlertTriangle, Trash2, Link2, ZoomOut, ZoomIn, Download, Menu as Menu$1, Package, Calendar, MoreHorizontal, Image as Image$1, Upload, ArrowLeft, HelpCircle, PauseCircle, Search, Type, Heading1, Heading2, Heading3, ListOrdered, Quote, Minus, Eraser, TrendingUp, TrendingDown, AlertCircle, Circle, Clock, CheckCircle2, Pause, SkipForward, Bug, Send, ChevronUp, ChevronDown, Wrench, Tag, User, DollarSign, Zap, Sword, Move, Heart, Shield } from 'lucide-react';
9
+ import { Loader2, X, Lightbulb, CheckCircle, List, Printer, ChevronRight, ChevronLeft, GitBranch, Pencil, Eye, Plus, ArrowRight, Trash, Code, FileText, WrapText, Check, Copy, RotateCcw, Play, Terminal, XCircle, AlertTriangle, Trash2, Link2, ZoomOut, ZoomIn, Download, Menu as Menu$1, Package, Calendar, MoreHorizontal, Image as Image$1, Upload, ArrowLeft, HelpCircle, PauseCircle, Search, Type, Heading1, Heading2, Heading3, ListOrdered, Quote, Minus, Eraser, TrendingUp, TrendingDown, AlertCircle, Circle, Clock, CheckCircle2, Bug, Send, ChevronUp, ChevronDown, Wrench, Tag, User, DollarSign, Zap, Sword, Move, Heart, Shield } from 'lucide-react';
10
10
  import { createPortal } from 'react-dom';
11
11
  import { useTranslate, useEventBus as useEventBus$1 } from '@almadar/ui/hooks';
12
12
  import { evaluate, createMinimalContext } from '@almadar/evaluator';
@@ -28130,6 +28130,78 @@ var init_GameOverScreen = __esm({
28130
28130
  GameOverScreen.displayName = "GameOverScreen";
28131
28131
  }
28132
28132
  });
28133
+ function useRenderInterpolation(options = {}) {
28134
+ const tickIntervalMs = options.tickIntervalMs ?? 1e3 / 30;
28135
+ const prevRef = useRef(null);
28136
+ const currRef = useRef(null);
28137
+ const rafRef = useRef(null);
28138
+ const onSnapshot = useCallback((entities) => {
28139
+ prevRef.current = currRef.current;
28140
+ currRef.current = { entities, arrivedAt: performance.now() };
28141
+ }, []);
28142
+ const getInterpolated = useCallback((now2) => {
28143
+ const out = /* @__PURE__ */ new Map();
28144
+ const curr = currRef.current;
28145
+ if (!curr) return out;
28146
+ const prev = prevRef.current;
28147
+ if (!prev) {
28148
+ for (const e of curr.entities) out.set(e.id, { x: e.x, y: e.y });
28149
+ return out;
28150
+ }
28151
+ const rawAlpha = (now2 - curr.arrivedAt) / tickIntervalMs;
28152
+ const alpha = rawAlpha < 0 ? 0 : rawAlpha > 1 ? 1 : rawAlpha;
28153
+ const prevMap = /* @__PURE__ */ new Map();
28154
+ for (const e of prev.entities) prevMap.set(e.id, e);
28155
+ for (const c of curr.entities) {
28156
+ const p2 = prevMap.get(c.id);
28157
+ if (!p2) {
28158
+ out.set(c.id, { x: c.x, y: c.y });
28159
+ } else {
28160
+ out.set(c.id, {
28161
+ x: p2.x + (c.x - p2.x) * alpha,
28162
+ y: p2.y + (c.y - p2.y) * alpha
28163
+ });
28164
+ }
28165
+ }
28166
+ return out;
28167
+ }, [tickIntervalMs]);
28168
+ const startLoop = useCallback(
28169
+ (draw) => {
28170
+ let active = true;
28171
+ const loop = () => {
28172
+ if (!active) return;
28173
+ try {
28174
+ draw(getInterpolated(performance.now()));
28175
+ } catch {
28176
+ }
28177
+ rafRef.current = requestAnimationFrame(loop);
28178
+ };
28179
+ rafRef.current = requestAnimationFrame(loop);
28180
+ return () => {
28181
+ active = false;
28182
+ if (rafRef.current !== null) {
28183
+ cancelAnimationFrame(rafRef.current);
28184
+ rafRef.current = null;
28185
+ }
28186
+ };
28187
+ },
28188
+ [getInterpolated]
28189
+ );
28190
+ useEffect(() => {
28191
+ return () => {
28192
+ if (rafRef.current !== null) {
28193
+ cancelAnimationFrame(rafRef.current);
28194
+ rafRef.current = null;
28195
+ }
28196
+ };
28197
+ }, []);
28198
+ return { onSnapshot, getInterpolated, startLoop };
28199
+ }
28200
+ var init_useRenderInterpolation = __esm({
28201
+ "hooks/useRenderInterpolation.ts"() {
28202
+ "use client";
28203
+ }
28204
+ });
28133
28205
  function PlatformerCanvas({
28134
28206
  player,
28135
28207
  platforms = [
@@ -28198,8 +28270,43 @@ function PlatformerCanvas({
28198
28270
  y: 336,
28199
28271
  width: 32,
28200
28272
  height: 48,
28273
+ vx: 0,
28274
+ vy: 0,
28275
+ grounded: true,
28201
28276
  facingRight: true
28202
28277
  };
28278
+ const playerRef = useRef(resolvedPlayer);
28279
+ playerRef.current = resolvedPlayer;
28280
+ const interp = useRenderInterpolation();
28281
+ useEffect(() => {
28282
+ interp.onSnapshot([{ id: "player", x: resolvedPlayer.x, y: resolvedPlayer.y }]);
28283
+ }, [resolvedPlayer.x, resolvedPlayer.y]);
28284
+ const propsRef = useRef({
28285
+ platforms,
28286
+ worldWidth,
28287
+ worldHeight,
28288
+ canvasWidth,
28289
+ canvasHeight,
28290
+ followCamera,
28291
+ bgColor,
28292
+ playerSprite,
28293
+ tileSprites,
28294
+ backgroundImage,
28295
+ assetBaseUrl
28296
+ });
28297
+ propsRef.current = {
28298
+ platforms,
28299
+ worldWidth,
28300
+ worldHeight,
28301
+ canvasWidth,
28302
+ canvasHeight,
28303
+ followCamera,
28304
+ bgColor,
28305
+ playerSprite,
28306
+ tileSprites,
28307
+ backgroundImage,
28308
+ assetBaseUrl
28309
+ };
28203
28310
  const handleKeyDown = useCallback((e) => {
28204
28311
  if (keysRef.current.has(e.code)) return;
28205
28312
  keysRef.current.add(e.code);
@@ -28248,124 +28355,149 @@ function PlatformerCanvas({
28248
28355
  canvas.width = canvasWidth * dpr;
28249
28356
  canvas.height = canvasHeight * dpr;
28250
28357
  ctx.scale(dpr, dpr);
28251
- let camX = 0;
28252
- let camY = 0;
28253
- if (followCamera) {
28254
- camX = Math.max(0, Math.min(resolvedPlayer.x - canvasWidth / 2, worldWidth - canvasWidth));
28255
- camY = Math.max(0, Math.min(resolvedPlayer.y - canvasHeight / 2 - 50, worldHeight - canvasHeight));
28256
- }
28257
- const bgImg = backgroundImage ? loadImage(backgroundImage) : null;
28258
- if (bgImg) {
28259
- ctx.drawImage(bgImg, 0, 0, canvasWidth, canvasHeight);
28260
- } else if (bgColor) {
28261
- ctx.fillStyle = bgColor;
28262
- ctx.fillRect(0, 0, canvasWidth, canvasHeight);
28263
- } else {
28264
- const grad = ctx.createLinearGradient(0, 0, 0, canvasHeight);
28265
- grad.addColorStop(0, SKY_GRADIENT_TOP);
28266
- grad.addColorStop(1, SKY_GRADIENT_BOTTOM);
28267
- ctx.fillStyle = grad;
28268
- ctx.fillRect(0, 0, canvasWidth, canvasHeight);
28269
- }
28270
- ctx.strokeStyle = GRID_COLOR;
28271
- ctx.lineWidth = 1;
28272
- const gridSize = 32;
28273
- for (let gx = -camX % gridSize; gx < canvasWidth; gx += gridSize) {
28274
- ctx.beginPath();
28275
- ctx.moveTo(gx, 0);
28276
- ctx.lineTo(gx, canvasHeight);
28277
- ctx.stroke();
28278
- }
28279
- for (let gy = -camY % gridSize; gy < canvasHeight; gy += gridSize) {
28280
- ctx.beginPath();
28281
- ctx.moveTo(0, gy);
28282
- ctx.lineTo(canvasWidth, gy);
28283
- ctx.stroke();
28284
- }
28285
- for (const plat of platforms) {
28286
- const px = plat.x - camX;
28287
- const py = plat.y - camY;
28288
- const platType = plat.type ?? "ground";
28289
- const spriteUrl = tileSprites?.[platType];
28290
- const tileImg = spriteUrl ? loadImage(spriteUrl) : null;
28291
- if (tileImg) {
28292
- const tileW = tileImg.naturalWidth;
28293
- const tileH = tileImg.naturalHeight;
28294
- const scaleH = plat.height / tileH;
28295
- const scaledW = tileW * scaleH;
28296
- for (let tx = 0; tx < plat.width; tx += scaledW) {
28297
- const drawW = Math.min(scaledW, plat.width - tx);
28298
- const srcW = drawW / scaleH;
28299
- ctx.drawImage(tileImg, 0, 0, srcW, tileH, px + tx, py, drawW, plat.height);
28300
- }
28358
+ }, [canvasWidth, canvasHeight]);
28359
+ useEffect(() => {
28360
+ const drawFrame = (positions) => {
28361
+ const canvas = canvasRef.current;
28362
+ if (!canvas) return;
28363
+ const ctx = canvas.getContext("2d");
28364
+ if (!ctx) return;
28365
+ const {
28366
+ platforms: plats,
28367
+ worldWidth: ww,
28368
+ worldHeight: wh,
28369
+ canvasWidth: cw,
28370
+ canvasHeight: ch,
28371
+ followCamera: fc,
28372
+ bgColor: bg,
28373
+ playerSprite: pSprite,
28374
+ tileSprites: tSprites,
28375
+ backgroundImage: bgImg
28376
+ } = propsRef.current;
28377
+ const auth = playerRef.current;
28378
+ const interped = positions.get("player");
28379
+ const px = interped?.x ?? auth.x;
28380
+ const py = interped?.y ?? auth.y;
28381
+ let camX = 0;
28382
+ let camY = 0;
28383
+ if (fc) {
28384
+ camX = Math.max(0, Math.min(px - cw / 2, ww - cw));
28385
+ camY = Math.max(0, Math.min(py - ch / 2 - 50, wh - ch));
28386
+ }
28387
+ const bgImage = bgImg ? loadImage(bgImg) : null;
28388
+ if (bgImage) {
28389
+ ctx.drawImage(bgImage, 0, 0, cw, ch);
28390
+ } else if (bg) {
28391
+ ctx.fillStyle = bg;
28392
+ ctx.fillRect(0, 0, cw, ch);
28301
28393
  } else {
28302
- const color = PLATFORM_COLORS[platType] ?? PLATFORM_COLORS.ground;
28303
- ctx.fillStyle = color;
28304
- ctx.fillRect(px, py, plat.width, plat.height);
28305
- ctx.fillStyle = "rgba(255, 255, 255, 0.15)";
28306
- ctx.fillRect(px, py, plat.width, 3);
28307
- ctx.fillStyle = "rgba(0, 0, 0, 0.3)";
28308
- ctx.fillRect(px, py + plat.height - 2, plat.width, 2);
28309
- if (platType === "hazard") {
28310
- ctx.strokeStyle = "#e74c3c";
28311
- ctx.lineWidth = 2;
28312
- for (let sx = px; sx < px + plat.width; sx += 12) {
28394
+ const grad = ctx.createLinearGradient(0, 0, 0, ch);
28395
+ grad.addColorStop(0, SKY_GRADIENT_TOP);
28396
+ grad.addColorStop(1, SKY_GRADIENT_BOTTOM);
28397
+ ctx.fillStyle = grad;
28398
+ ctx.fillRect(0, 0, cw, ch);
28399
+ }
28400
+ ctx.strokeStyle = GRID_COLOR;
28401
+ ctx.lineWidth = 1;
28402
+ const gridSize = 32;
28403
+ for (let gx = -camX % gridSize; gx < cw; gx += gridSize) {
28404
+ ctx.beginPath();
28405
+ ctx.moveTo(gx, 0);
28406
+ ctx.lineTo(gx, ch);
28407
+ ctx.stroke();
28408
+ }
28409
+ for (let gy = -camY % gridSize; gy < ch; gy += gridSize) {
28410
+ ctx.beginPath();
28411
+ ctx.moveTo(0, gy);
28412
+ ctx.lineTo(cw, gy);
28413
+ ctx.stroke();
28414
+ }
28415
+ for (const plat of plats) {
28416
+ const platX = plat.x - camX;
28417
+ const platY = plat.y - camY;
28418
+ const platType = plat.type ?? "ground";
28419
+ const spriteUrl = tSprites?.[platType];
28420
+ const tileImg = spriteUrl ? loadImage(spriteUrl) : null;
28421
+ if (tileImg) {
28422
+ const tileW = tileImg.naturalWidth;
28423
+ const tileH = tileImg.naturalHeight;
28424
+ const scaleH = plat.height / tileH;
28425
+ const scaledW = tileW * scaleH;
28426
+ for (let tx = 0; tx < plat.width; tx += scaledW) {
28427
+ const drawW = Math.min(scaledW, plat.width - tx);
28428
+ const srcW = drawW / scaleH;
28429
+ ctx.drawImage(tileImg, 0, 0, srcW, tileH, platX + tx, platY, drawW, plat.height);
28430
+ }
28431
+ } else {
28432
+ const color = PLATFORM_COLORS[platType] ?? PLATFORM_COLORS.ground;
28433
+ ctx.fillStyle = color;
28434
+ ctx.fillRect(platX, platY, plat.width, plat.height);
28435
+ ctx.fillStyle = "rgba(255, 255, 255, 0.15)";
28436
+ ctx.fillRect(platX, platY, plat.width, 3);
28437
+ ctx.fillStyle = "rgba(0, 0, 0, 0.3)";
28438
+ ctx.fillRect(platX, platY + plat.height - 2, plat.width, 2);
28439
+ if (platType === "hazard") {
28440
+ ctx.strokeStyle = "#e74c3c";
28441
+ ctx.lineWidth = 2;
28442
+ for (let sx = platX; sx < platX + plat.width; sx += 12) {
28443
+ ctx.beginPath();
28444
+ ctx.moveTo(sx, platY);
28445
+ ctx.lineTo(sx + 6, platY + plat.height);
28446
+ ctx.stroke();
28447
+ }
28448
+ }
28449
+ if (platType === "goal") {
28450
+ ctx.fillStyle = "rgba(241, 196, 15, 0.5)";
28313
28451
  ctx.beginPath();
28314
- ctx.moveTo(sx, py);
28315
- ctx.lineTo(sx + 6, py + plat.height);
28316
- ctx.stroke();
28452
+ ctx.arc(platX + plat.width / 2, platY - 10, 8, 0, Math.PI * 2);
28453
+ ctx.fill();
28317
28454
  }
28318
28455
  }
28319
- if (platType === "goal") {
28320
- ctx.fillStyle = "rgba(241, 196, 15, 0.5)";
28321
- ctx.beginPath();
28322
- ctx.arc(px + plat.width / 2, py - 10, 8, 0, Math.PI * 2);
28323
- ctx.fill();
28324
- }
28325
28456
  }
28326
- }
28327
- const pw = resolvedPlayer.width ?? 24;
28328
- const ph = resolvedPlayer.height ?? 32;
28329
- const ppx = resolvedPlayer.x - camX;
28330
- const ppy = resolvedPlayer.y - camY;
28331
- const facingRight = resolvedPlayer.facingRight ?? true;
28332
- const playerImg = playerSprite ? loadImage(playerSprite) : null;
28333
- if (playerImg) {
28334
- ctx.save();
28335
- if (!facingRight) {
28336
- ctx.translate(ppx + pw, ppy);
28337
- ctx.scale(-1, 1);
28338
- ctx.drawImage(playerImg, 0, 0, pw, ph);
28457
+ const pw = auth.width ?? 24;
28458
+ const ph = auth.height ?? 32;
28459
+ const ppx = px - camX;
28460
+ const ppy = py - camY;
28461
+ const facingRight = auth.facingRight ?? true;
28462
+ const playerImg = pSprite ? loadImage(pSprite) : null;
28463
+ if (playerImg) {
28464
+ ctx.save();
28465
+ if (!facingRight) {
28466
+ ctx.translate(ppx + pw, ppy);
28467
+ ctx.scale(-1, 1);
28468
+ ctx.drawImage(playerImg, 0, 0, pw, ph);
28469
+ } else {
28470
+ ctx.drawImage(playerImg, ppx, ppy, pw, ph);
28471
+ }
28472
+ ctx.restore();
28339
28473
  } else {
28340
- ctx.drawImage(playerImg, ppx, ppy, pw, ph);
28474
+ ctx.fillStyle = PLAYER_COLOR;
28475
+ const radius = Math.min(pw, ph) * 0.25;
28476
+ ctx.beginPath();
28477
+ ctx.moveTo(ppx + radius, ppy);
28478
+ ctx.lineTo(ppx + pw - radius, ppy);
28479
+ ctx.quadraticCurveTo(ppx + pw, ppy, ppx + pw, ppy + radius);
28480
+ ctx.lineTo(ppx + pw, ppy + ph - radius);
28481
+ ctx.quadraticCurveTo(ppx + pw, ppy + ph, ppx + pw - radius, ppy + ph);
28482
+ ctx.lineTo(ppx + radius, ppy + ph);
28483
+ ctx.quadraticCurveTo(ppx, ppy + ph, ppx, ppy + ph - radius);
28484
+ ctx.lineTo(ppx, ppy + radius);
28485
+ ctx.quadraticCurveTo(ppx, ppy, ppx + radius, ppy);
28486
+ ctx.fill();
28487
+ const eyeY = ppy + ph * 0.3;
28488
+ const eyeSize = 3;
28489
+ const eyeOffsetX = facingRight ? pw * 0.55 : pw * 0.2;
28490
+ ctx.fillStyle = PLAYER_EYE_COLOR;
28491
+ ctx.beginPath();
28492
+ ctx.arc(ppx + eyeOffsetX, eyeY, eyeSize, 0, Math.PI * 2);
28493
+ ctx.fill();
28494
+ ctx.beginPath();
28495
+ ctx.arc(ppx + eyeOffsetX + 7, eyeY, eyeSize, 0, Math.PI * 2);
28496
+ ctx.fill();
28341
28497
  }
28342
- ctx.restore();
28343
- } else {
28344
- ctx.fillStyle = PLAYER_COLOR;
28345
- const radius = Math.min(pw, ph) * 0.25;
28346
- ctx.beginPath();
28347
- ctx.moveTo(ppx + radius, ppy);
28348
- ctx.lineTo(ppx + pw - radius, ppy);
28349
- ctx.quadraticCurveTo(ppx + pw, ppy, ppx + pw, ppy + radius);
28350
- ctx.lineTo(ppx + pw, ppy + ph - radius);
28351
- ctx.quadraticCurveTo(ppx + pw, ppy + ph, ppx + pw - radius, ppy + ph);
28352
- ctx.lineTo(ppx + radius, ppy + ph);
28353
- ctx.quadraticCurveTo(ppx, ppy + ph, ppx, ppy + ph - radius);
28354
- ctx.lineTo(ppx, ppy + radius);
28355
- ctx.quadraticCurveTo(ppx, ppy, ppx + radius, ppy);
28356
- ctx.fill();
28357
- const eyeY = ppy + ph * 0.3;
28358
- const eyeSize = 3;
28359
- const eyeOffsetX = facingRight ? pw * 0.55 : pw * 0.2;
28360
- ctx.fillStyle = PLAYER_EYE_COLOR;
28361
- ctx.beginPath();
28362
- ctx.arc(ppx + eyeOffsetX, eyeY, eyeSize, 0, Math.PI * 2);
28363
- ctx.fill();
28364
- ctx.beginPath();
28365
- ctx.arc(ppx + eyeOffsetX + 7, eyeY, eyeSize, 0, Math.PI * 2);
28366
- ctx.fill();
28367
- }
28368
- }, [player, platforms, worldWidth, worldHeight, canvasWidth, canvasHeight, followCamera, bgColor, playerSprite, tileSprites, backgroundImage, assetBaseUrl, loadedImages]);
28498
+ };
28499
+ return interp.startLoop(drawFrame);
28500
+ }, [interp.startLoop, loadImage]);
28369
28501
  return /* @__PURE__ */ jsx(
28370
28502
  "canvas",
28371
28503
  {
@@ -28383,6 +28515,7 @@ var init_PlatformerCanvas = __esm({
28383
28515
  init_cn();
28384
28516
  init_useEventBus();
28385
28517
  init_verificationRegistry();
28518
+ init_useRenderInterpolation();
28386
28519
  PLATFORM_COLORS = {
28387
28520
  ground: "#4a7c59",
28388
28521
  platform: "#7c6b4a",
@@ -28765,7 +28898,7 @@ var init_MapView = __esm({
28765
28898
  shadowSize: [41, 41]
28766
28899
  });
28767
28900
  L.Marker.prototype.options.icon = defaultIcon;
28768
- const { useEffect: useEffect74, useRef: useRef68, useCallback: useCallback111, useState: useState107 } = React82__default;
28901
+ const { useEffect: useEffect74, useRef: useRef68, useCallback: useCallback112, useState: useState107 } = React82__default;
28769
28902
  const { Typography: Typography2 } = await Promise.resolve().then(() => (init_Typography(), Typography_exports));
28770
28903
  const { useEventBus: useEventBus3 } = await Promise.resolve().then(() => (init_useEventBus(), useEventBus_exports));
28771
28904
  function MapUpdater({ centerLat, centerLng, zoom }) {
@@ -28811,7 +28944,7 @@ var init_MapView = __esm({
28811
28944
  }) {
28812
28945
  const eventBus = useEventBus3();
28813
28946
  const [clickedPosition, setClickedPosition] = useState107(null);
28814
- const handleMapClick = useCallback111((lat, lng) => {
28947
+ const handleMapClick = useCallback112((lat, lng) => {
28815
28948
  if (showClickedPin) {
28816
28949
  setClickedPosition({ lat, lng });
28817
28950
  }
@@ -28820,7 +28953,7 @@ var init_MapView = __esm({
28820
28953
  eventBus.emit(`UI:${mapClickEvent}`, { latitude: lat, longitude: lng });
28821
28954
  }
28822
28955
  }, [onMapClick, mapClickEvent, eventBus, showClickedPin]);
28823
- const handleMarkerClick = useCallback111((marker) => {
28956
+ const handleMarkerClick = useCallback112((marker) => {
28824
28957
  onMarkerClick?.(marker);
28825
28958
  if (markerClickEvent) {
28826
28959
  eventBus.emit(`UI:${markerClickEvent}`, { ...marker });
@@ -33819,7 +33952,7 @@ var init_RichBlockEditor = __esm({
33819
33952
  "border-b border-border bg-muted/30 px-2 py-2"
33820
33953
  ),
33821
33954
  children: TOOLBAR_ENTRIES.map((entry) => {
33822
- const Icon3 = entry.icon;
33955
+ const Icon2 = entry.icon;
33823
33956
  const entryLabel = t(entry.labelKey);
33824
33957
  return /* @__PURE__ */ jsxs(
33825
33958
  Button,
@@ -33831,7 +33964,7 @@ var init_RichBlockEditor = __esm({
33831
33964
  title: entryLabel,
33832
33965
  onClick: () => handleAppend(entry.type),
33833
33966
  children: [
33834
- /* @__PURE__ */ jsx(Icon3, { size: 14 }),
33967
+ /* @__PURE__ */ jsx(Icon2, { size: 14 }),
33835
33968
  /* @__PURE__ */ jsx(Typography, { as: "span", variant: "caption", className: "ml-1 hidden text-xs sm:inline", children: entryLabel })
33836
33969
  ]
33837
33970
  },
@@ -44692,11 +44825,13 @@ function SimulationCanvas({
44692
44825
  height = 400,
44693
44826
  running,
44694
44827
  speed = 1,
44828
+ bodies: externalBodies,
44695
44829
  className
44696
44830
  }) {
44697
44831
  const preset = useMemo(() => resolvePreset(presetProp), [presetProp]);
44698
44832
  const canvasRef = useRef(null);
44699
44833
  const bodiesRef = useRef(structuredClone(preset.bodies));
44834
+ const interp = useRenderInterpolation();
44700
44835
  useEffect(() => {
44701
44836
  bodiesRef.current = structuredClone(preset.bodies);
44702
44837
  }, [preset]);
@@ -44794,6 +44929,67 @@ function SimulationCanvas({
44794
44929
  }
44795
44930
  }, [width, height, preset]);
44796
44931
  useEffect(() => {
44932
+ if (!externalBodies) return;
44933
+ interp.onSnapshot(externalBodies.map((b) => ({ id: b.id, x: b.x, y: b.y })));
44934
+ }, [externalBodies]);
44935
+ const presetRef = useRef(preset);
44936
+ presetRef.current = preset;
44937
+ const widthRef = useRef(width);
44938
+ widthRef.current = width;
44939
+ const heightRef = useRef(height);
44940
+ heightRef.current = height;
44941
+ useEffect(() => {
44942
+ if (!externalBodies) return;
44943
+ const drawInterpolated = (positions) => {
44944
+ const canvas = canvasRef.current;
44945
+ if (!canvas) return;
44946
+ const ctx = canvas.getContext("2d");
44947
+ if (!ctx) return;
44948
+ const bodies = bodiesRef.current;
44949
+ const p2 = presetRef.current;
44950
+ const w = widthRef.current;
44951
+ const h = heightRef.current;
44952
+ ctx.clearRect(0, 0, w, h);
44953
+ ctx.fillStyle = p2.backgroundColor ?? "#1a1a2e";
44954
+ ctx.fillRect(0, 0, w, h);
44955
+ if (p2.constraints) {
44956
+ for (const c of p2.constraints) {
44957
+ const a = bodies[c.bodyA];
44958
+ const b = bodies[c.bodyB];
44959
+ if (a && b) {
44960
+ const aPos = positions.get(a.id) ?? a;
44961
+ const bPos = positions.get(b.id) ?? b;
44962
+ ctx.beginPath();
44963
+ ctx.moveTo(aPos.x, aPos.y);
44964
+ ctx.lineTo(bPos.x, bPos.y);
44965
+ ctx.strokeStyle = "#533483";
44966
+ ctx.lineWidth = 1;
44967
+ ctx.setLineDash([4, 4]);
44968
+ ctx.stroke();
44969
+ ctx.setLineDash([]);
44970
+ }
44971
+ }
44972
+ }
44973
+ for (const body of bodies) {
44974
+ const pos = positions.get(body.id) ?? body;
44975
+ ctx.beginPath();
44976
+ ctx.arc(pos.x, pos.y, body.radius, 0, Math.PI * 2);
44977
+ ctx.fillStyle = body.color ?? "#e94560";
44978
+ ctx.fill();
44979
+ if (p2.showVelocity) {
44980
+ ctx.beginPath();
44981
+ ctx.moveTo(pos.x, pos.y);
44982
+ ctx.lineTo(pos.x + body.vx * 0.1, pos.y + body.vy * 0.1);
44983
+ ctx.strokeStyle = "#16213e";
44984
+ ctx.lineWidth = 2;
44985
+ ctx.stroke();
44986
+ }
44987
+ }
44988
+ };
44989
+ return interp.startLoop(drawInterpolated);
44990
+ }, [externalBodies !== void 0, interp.startLoop]);
44991
+ useEffect(() => {
44992
+ if (externalBodies !== void 0) return;
44797
44993
  if (!running) return;
44798
44994
  let raf;
44799
44995
  const loop = () => {
@@ -44803,10 +44999,11 @@ function SimulationCanvas({
44803
44999
  };
44804
45000
  raf = requestAnimationFrame(loop);
44805
45001
  return () => cancelAnimationFrame(raf);
44806
- }, [running, step, draw]);
45002
+ }, [running, step, draw, externalBodies]);
44807
45003
  useEffect(() => {
45004
+ if (externalBodies !== void 0) return;
44808
45005
  draw();
44809
- }, [draw]);
45006
+ }, [draw, externalBodies]);
44810
45007
  useEffect(() => {
44811
45008
  if (typeof window === "undefined") return;
44812
45009
  const canvas = canvasRef.current;
@@ -44832,136 +45029,10 @@ var init_SimulationCanvas = __esm({
44832
45029
  init_atoms2();
44833
45030
  init_verificationRegistry();
44834
45031
  init_presets();
45032
+ init_useRenderInterpolation();
44835
45033
  SimulationCanvas.displayName = "SimulationCanvas";
44836
45034
  }
44837
45035
  });
44838
- function SimulationControls({
44839
- running,
44840
- speed,
44841
- parameters,
44842
- onPlay,
44843
- onPause,
44844
- onStep,
44845
- onReset,
44846
- onSpeedChange,
44847
- onParameterChange,
44848
- className
44849
- }) {
44850
- return /* @__PURE__ */ jsxs(VStack, { gap: "md", className, children: [
44851
- /* @__PURE__ */ jsxs(HStack, { gap: "sm", align: "center", children: [
44852
- running ? /* @__PURE__ */ jsx(Button, { size: "sm", variant: "secondary", onClick: onPause, icon: Pause, children: "Pause" }) : /* @__PURE__ */ jsx(Button, { size: "sm", variant: "primary", onClick: onPlay, icon: Play, children: "Play" }),
44853
- /* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", onClick: onStep, icon: SkipForward, disabled: running, children: "Step" }),
44854
- /* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", onClick: onReset, icon: RotateCcw, children: "Reset" })
44855
- ] }),
44856
- /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
44857
- /* @__PURE__ */ jsxs(Typography, { variant: "caption", color: "muted", children: [
44858
- "Speed: ",
44859
- speed.toFixed(1),
44860
- "x"
44861
- ] }),
44862
- /* @__PURE__ */ jsx(
44863
- "input",
44864
- {
44865
- type: "range",
44866
- min: 0.1,
44867
- max: 5,
44868
- step: 0.1,
44869
- value: speed,
44870
- onChange: (e) => onSpeedChange(parseFloat(e.target.value)),
44871
- className: "w-full"
44872
- }
44873
- )
44874
- ] }),
44875
- Object.entries(parameters).map(([name, param]) => /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
44876
- /* @__PURE__ */ jsxs(Typography, { variant: "caption", color: "muted", children: [
44877
- param.label,
44878
- ": ",
44879
- param.value.toFixed(2)
44880
- ] }),
44881
- /* @__PURE__ */ jsx(
44882
- "input",
44883
- {
44884
- type: "range",
44885
- min: param.min,
44886
- max: param.max,
44887
- step: param.step,
44888
- value: param.value,
44889
- onChange: (e) => onParameterChange(name, parseFloat(e.target.value)),
44890
- className: "w-full"
44891
- }
44892
- )
44893
- ] }, name))
44894
- ] });
44895
- }
44896
- var init_SimulationControls = __esm({
44897
- "components/game/organisms/physics-sim/SimulationControls.tsx"() {
44898
- init_atoms2();
44899
- SimulationControls.displayName = "SimulationControls";
44900
- }
44901
- });
44902
- function SimulationGraph({
44903
- label,
44904
- unit,
44905
- data,
44906
- maxPoints = 200,
44907
- width = 300,
44908
- height = 120,
44909
- color = "#e94560",
44910
- className
44911
- }) {
44912
- const canvasRef = useRef(null);
44913
- const visibleData = data.slice(-maxPoints);
44914
- useEffect(() => {
44915
- const canvas = canvasRef.current;
44916
- if (!canvas || visibleData.length < 2) return;
44917
- const ctx = canvas.getContext("2d");
44918
- if (!ctx) return;
44919
- ctx.clearRect(0, 0, width, height);
44920
- ctx.fillStyle = "#0f0f23";
44921
- ctx.fillRect(0, 0, width, height);
44922
- ctx.strokeStyle = "#1a1a3e";
44923
- ctx.lineWidth = 0.5;
44924
- for (let i = 0; i < 5; i++) {
44925
- const y = height / 5 * i;
44926
- ctx.beginPath();
44927
- ctx.moveTo(0, y);
44928
- ctx.lineTo(width, y);
44929
- ctx.stroke();
44930
- }
44931
- let minVal = Infinity;
44932
- let maxVal = -Infinity;
44933
- for (const pt of visibleData) {
44934
- if (pt.value < minVal) minVal = pt.value;
44935
- if (pt.value > maxVal) maxVal = pt.value;
44936
- }
44937
- const range = maxVal - minVal || 1;
44938
- const pad = height * 0.1;
44939
- ctx.beginPath();
44940
- ctx.strokeStyle = color;
44941
- ctx.lineWidth = 2;
44942
- for (let i = 0; i < visibleData.length; i++) {
44943
- const x = i / (maxPoints - 1) * width;
44944
- const y = pad + (maxVal - visibleData[i].value) / range * (height - 2 * pad);
44945
- if (i === 0) ctx.moveTo(x, y);
44946
- else ctx.lineTo(x, y);
44947
- }
44948
- ctx.stroke();
44949
- const last = visibleData[visibleData.length - 1];
44950
- ctx.fillStyle = color;
44951
- ctx.font = "12px monospace";
44952
- ctx.fillText(`${last.value.toFixed(2)} ${unit}`, width - 80, 16);
44953
- }, [visibleData, width, height, color, unit, maxPoints]);
44954
- return /* @__PURE__ */ jsx(Card, { padding: "sm", className, children: /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
44955
- /* @__PURE__ */ jsx(Typography, { variant: "caption", weight: "bold", children: label }),
44956
- /* @__PURE__ */ jsx("canvas", { ref: canvasRef, width, height, className: "rounded" })
44957
- ] }) });
44958
- }
44959
- var init_SimulationGraph = __esm({
44960
- "components/game/organisms/physics-sim/SimulationGraph.tsx"() {
44961
- init_atoms2();
44962
- SimulationGraph.displayName = "SimulationGraph";
44963
- }
44964
- });
44965
45036
  function SimulatorBoard({
44966
45037
  entity,
44967
45038
  completeEvent = "PUZZLE_COMPLETE",
@@ -45232,7 +45303,7 @@ var init_StatCard = __esm({
45232
45303
  isLoading: externalLoading,
45233
45304
  error: externalError
45234
45305
  }) => {
45235
- const Icon3 = typeof iconProp === "string" ? resolveIcon(iconProp) ?? void 0 : iconProp;
45306
+ const Icon2 = typeof iconProp === "string" ? resolveIcon(iconProp) ?? void 0 : iconProp;
45236
45307
  const labelToUse = propLabel ?? propTitle;
45237
45308
  const eventBus = useEventBus();
45238
45309
  const { t } = useTranslate();
@@ -45375,7 +45446,7 @@ var init_StatCard = __esm({
45375
45446
  subtitle && !calculatedTrend && /* @__PURE__ */ jsx(Typography, { variant: "small", color: "secondary", children: subtitle })
45376
45447
  ] }),
45377
45448
  /* @__PURE__ */ jsxs(VStack, { gap: "xs", align: "end", children: [
45378
- Icon3 && /* @__PURE__ */ jsx(Box, { className: cn("p-3", iconBg), children: /* @__PURE__ */ jsx(Icon3, { className: cn("h-6 w-6", iconColor) }) }),
45449
+ Icon2 && /* @__PURE__ */ jsx(Box, { className: cn("p-3", iconBg), children: /* @__PURE__ */ jsx(Icon2, { className: cn("h-6 w-6", iconColor) }) }),
45379
45450
  sparklineData && sparklineData.length > 1 && /* @__PURE__ */ jsx(Sparkline, { data: sparklineData, color: "auto" })
45380
45451
  ] })
45381
45452
  ] }),
@@ -47178,7 +47249,6 @@ var init_component_registry_generated = __esm({
47178
47249
  init_Navigation();
47179
47250
  init_NegotiatorBoard();
47180
47251
  init_NumberStepper();
47181
- init_ObjectRulePanel();
47182
47252
  init_OptionConstraintGroup();
47183
47253
  init_OrbitalVisualization();
47184
47254
  init_Overlay();
@@ -47209,7 +47279,6 @@ var init_component_registry_generated = __esm({
47209
47279
  init_ResourceBar();
47210
47280
  init_ResourceCounter();
47211
47281
  init_RichBlockEditor();
47212
- init_RuleEditor();
47213
47282
  init_RuntimeDebugger2();
47214
47283
  init_ScaledDiagram();
47215
47284
  init_ScoreBoard();
@@ -47229,8 +47298,6 @@ var init_component_registry_generated = __esm({
47229
47298
  init_SignaturePad();
47230
47299
  init_SimpleGrid();
47231
47300
  init_SimulationCanvas();
47232
- init_SimulationControls();
47233
- init_SimulationGraph();
47234
47301
  init_SimulatorBoard();
47235
47302
  init_Skeleton();
47236
47303
  init_SocialProof();
@@ -47248,7 +47315,6 @@ var init_component_registry_generated = __esm({
47248
47315
  init_StateArchitectBoard();
47249
47316
  init_StateIndicator();
47250
47317
  init_StateMachineView();
47251
- init_StateNode();
47252
47318
  init_StatsGrid();
47253
47319
  init_StatsOrganism();
47254
47320
  init_StatusDot();
@@ -47287,8 +47353,6 @@ var init_component_registry_generated = __esm({
47287
47353
  init_Tooltip();
47288
47354
  init_TraitFrame();
47289
47355
  init_TraitSlot();
47290
- init_TraitStateViewer();
47291
- init_TransitionArrow();
47292
47356
  init_TrendIndicator();
47293
47357
  init_TurnIndicator();
47294
47358
  init_TurnPanel();
@@ -47298,7 +47362,6 @@ var init_component_registry_generated = __esm({
47298
47362
  init_UncontrolledBattleBoard();
47299
47363
  init_UnitCommandBar();
47300
47364
  init_UploadDropZone();
47301
- init_VariablePanel();
47302
47365
  init_VersionDiff();
47303
47366
  init_ViolationAlert();
47304
47367
  init_VoteStack();
@@ -47508,7 +47571,6 @@ var init_component_registry_generated = __esm({
47508
47571
  "Navigation": Navigation,
47509
47572
  "NegotiatorBoard": NegotiatorBoard,
47510
47573
  "NumberStepper": NumberStepper,
47511
- "ObjectRulePanel": ObjectRulePanel,
47512
47574
  "OptionConstraintGroup": OptionConstraintGroup,
47513
47575
  "OrbitalVisualization": OrbitalVisualization,
47514
47576
  "Overlay": Overlay,
@@ -47539,7 +47601,6 @@ var init_component_registry_generated = __esm({
47539
47601
  "ResourceBar": ResourceBar,
47540
47602
  "ResourceCounter": ResourceCounter,
47541
47603
  "RichBlockEditor": RichBlockEditor,
47542
- "RuleEditor": RuleEditor,
47543
47604
  "RuntimeDebugger": RuntimeDebugger,
47544
47605
  "ScaledDiagram": ScaledDiagram,
47545
47606
  "ScoreBoard": ScoreBoard,
@@ -47559,8 +47620,6 @@ var init_component_registry_generated = __esm({
47559
47620
  "SignaturePad": SignaturePad,
47560
47621
  "SimpleGrid": SimpleGrid,
47561
47622
  "SimulationCanvas": SimulationCanvas,
47562
- "SimulationControls": SimulationControls,
47563
- "SimulationGraph": SimulationGraph,
47564
47623
  "SimulatorBoard": SimulatorBoard,
47565
47624
  "Skeleton": Skeleton,
47566
47625
  "SocialProof": SocialProof,
@@ -47581,7 +47640,6 @@ var init_component_registry_generated = __esm({
47581
47640
  "StateArchitectBoard": StateArchitectBoard,
47582
47641
  "StateIndicator": StateIndicator,
47583
47642
  "StateMachineView": StateMachineView,
47584
- "StateNode": StateNode2,
47585
47643
  "StatsGrid": StatsGrid,
47586
47644
  "StatsOrganism": StatsOrganism,
47587
47645
  "StatusDot": StatusDot,
@@ -47620,8 +47678,6 @@ var init_component_registry_generated = __esm({
47620
47678
  "Tooltip": Tooltip,
47621
47679
  "TraitFrame": TraitFrame,
47622
47680
  "TraitSlot": TraitSlot,
47623
- "TraitStateViewer": TraitStateViewer,
47624
- "TransitionArrow": TransitionArrow,
47625
47681
  "TrendIndicator": TrendIndicator,
47626
47682
  "TurnIndicator": TurnIndicator,
47627
47683
  "TurnPanel": TurnPanel,
@@ -47632,7 +47688,6 @@ var init_component_registry_generated = __esm({
47632
47688
  "UnitCommandBar": UnitCommandBar,
47633
47689
  "UploadDropZone": UploadDropZone,
47634
47690
  "VStack": VStack,
47635
- "VariablePanel": VariablePanel,
47636
47691
  "VersionDiff": VersionDiff,
47637
47692
  "ViolationAlert": ViolationAlert,
47638
47693
  "VoteStack": VoteStack,