@almadar/ui 2.5.2 → 2.6.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.
@@ -1,8 +1,8 @@
1
1
  import { apiClient } from './chunk-3HJHHULT.js';
2
- import { subscribe, getSnapshot, clearEntities, removeEntity, updateSingleton, updateEntity, spawnEntity, getSingleton, getAllEntities, getByType, getEntity } from './chunk-N7MVUW4R.js';
3
- import { SelectionContext, entityDataKeys, useEntityList } from './chunk-GOZKH7QW.js';
2
+ import { SelectionContext, entityDataKeys, useEntityList } from './chunk-WGJIL4YR.js';
4
3
  import { useEventBus } from './chunk-YXZM3WCF.js';
5
- import { useCallback, useState, useEffect, useMemo, useContext, useSyncExternalStore } from 'react';
4
+ import { subscribe, getSnapshot, clearEntities, removeEntity, updateSingleton, updateEntity, spawnEntity, getSingleton, getAllEntities, getByType, getEntity } from './chunk-N7MVUW4R.js';
5
+ import { useCallback, useState, useEffect, useMemo, useContext, useSyncExternalStore, useRef } from 'react';
6
6
  import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query';
7
7
 
8
8
  function useOrbitalHistory(options) {
@@ -1353,6 +1353,49 @@ function useAuthContext() {
1353
1353
  signOut: void 0
1354
1354
  };
1355
1355
  }
1356
+ function getDistance(touches) {
1357
+ const dx = touches[0].clientX - touches[1].clientX;
1358
+ const dy = touches[0].clientY - touches[1].clientY;
1359
+ return Math.sqrt(dx * dx + dy * dy);
1360
+ }
1361
+ function usePinchZoom(options = {}) {
1362
+ const { minScale = 0.5, maxScale = 4 } = options;
1363
+ const [scale, setScale] = useState(1);
1364
+ const [isPinching, setIsPinching] = useState(false);
1365
+ const initialDistance = useRef(0);
1366
+ const initialScale = useRef(1);
1367
+ const onTouchStart = useCallback((e) => {
1368
+ if (e.touches.length === 2) {
1369
+ initialDistance.current = getDistance(e.touches);
1370
+ initialScale.current = scale;
1371
+ setIsPinching(true);
1372
+ }
1373
+ }, [scale]);
1374
+ const onTouchMove = useCallback((e) => {
1375
+ if (e.touches.length !== 2 || !isPinching) return;
1376
+ e.preventDefault();
1377
+ const currentDistance = getDistance(e.touches);
1378
+ const ratio = currentDistance / initialDistance.current;
1379
+ const newScale = Math.min(maxScale, Math.max(minScale, initialScale.current * ratio));
1380
+ setScale(newScale);
1381
+ }, [isPinching, minScale, maxScale]);
1382
+ const onTouchEnd = useCallback(() => {
1383
+ setIsPinching(false);
1384
+ }, []);
1385
+ const resetZoom = useCallback(() => {
1386
+ setScale(1);
1387
+ }, []);
1388
+ return {
1389
+ scale,
1390
+ isPinching,
1391
+ gestureProps: {
1392
+ onTouchStart,
1393
+ onTouchMove,
1394
+ onTouchEnd
1395
+ },
1396
+ resetZoom
1397
+ };
1398
+ }
1356
1399
  var API_BASE = typeof process !== "undefined" && process.env?.VITE_API_URL ? process.env.VITE_API_URL : "http://localhost:3000";
1357
1400
  function getUserId() {
1358
1401
  return localStorage.getItem("userId") || "anonymous";
@@ -1429,4 +1472,4 @@ function useGitHubBranches(owner, repo, enabled = true) {
1429
1472
  });
1430
1473
  }
1431
1474
 
1432
- export { ENTITY_EVENTS, useAgentChat, useAuthContext, useCompile, useConnectGitHub, useCreateEntity, useDeepAgentGeneration, useDeleteEntity, useDisconnectGitHub, useEntities, useEntitiesByType, useEntity, useEntityMutations, useExtensions, useFileEditor, useFileSystem, useGitHubBranches, useGitHubRepo, useGitHubRepos, useGitHubStatus, useInput, useOrbitalHistory, useOrbitalMutations, usePhysics, usePlayer, usePreview, useResolvedEntity, useSelectedEntity, useSendOrbitalEvent, useSingletonEntity, useUIEvents, useUpdateEntity, useValidation };
1475
+ export { ENTITY_EVENTS, useAgentChat, useAuthContext, useCompile, useConnectGitHub, useCreateEntity, useDeepAgentGeneration, useDeleteEntity, useDisconnectGitHub, useEntities, useEntitiesByType, useEntity, useEntityMutations, useExtensions, useFileEditor, useFileSystem, useGitHubBranches, useGitHubRepo, useGitHubRepos, useGitHubStatus, useInput, useOrbitalHistory, useOrbitalMutations, usePhysics, usePinchZoom, usePlayer, usePreview, useResolvedEntity, useSelectedEntity, useSendOrbitalEvent, useSingletonEntity, useUIEvents, useUpdateEntity, useValidation };