@almadar/ui 2.5.0 → 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 { SelectionContext, entityDataKeys, useEntityList } from './chunk-GOZKH7QW.js';
2
+ import { SelectionContext, entityDataKeys, useEntityList } from './chunk-WGJIL4YR.js';
3
3
  import { useEventBus } from './chunk-YXZM3WCF.js';
4
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 } from 'react';
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 };
@@ -1,30 +1,7 @@
1
1
  import { useUISlotManager } from './chunk-3JGAROCW.js';
2
- import { createContext, useMemo, useContext, useState, useEffect, useCallback } from 'react';
2
+ import { createContext, useMemo, useState, useEffect, useCallback, useContext } from 'react';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
 
5
- var UISlotContext = createContext(null);
6
- function UISlotProvider({ children }) {
7
- const slotManager = useUISlotManager();
8
- const contextValue = useMemo(() => slotManager, [slotManager]);
9
- return /* @__PURE__ */ jsx(UISlotContext.Provider, { value: contextValue, children });
10
- }
11
- function useUISlots() {
12
- const context = useContext(UISlotContext);
13
- if (!context) {
14
- throw new Error(
15
- "useUISlots must be used within a UISlotProvider. Make sure your component tree is wrapped with <UISlotProvider>."
16
- );
17
- }
18
- return context;
19
- }
20
- function useSlotContent(slot) {
21
- const { getContent } = useUISlots();
22
- return getContent(slot);
23
- }
24
- function useSlotHasContent(slot) {
25
- const { hasContent } = useUISlots();
26
- return hasContent(slot);
27
- }
28
5
  var BUILT_IN_THEMES = [
29
6
  {
30
7
  name: "wireframe",
@@ -275,5 +252,28 @@ function useTheme() {
275
252
  return context;
276
253
  }
277
254
  var ThemeContext_default = ThemeContext;
255
+ var UISlotContext = createContext(null);
256
+ function UISlotProvider({ children }) {
257
+ const slotManager = useUISlotManager();
258
+ const contextValue = useMemo(() => slotManager, [slotManager]);
259
+ return /* @__PURE__ */ jsx(UISlotContext.Provider, { value: contextValue, children });
260
+ }
261
+ function useUISlots() {
262
+ const context = useContext(UISlotContext);
263
+ if (!context) {
264
+ throw new Error(
265
+ "useUISlots must be used within a UISlotProvider. Make sure your component tree is wrapped with <UISlotProvider>."
266
+ );
267
+ }
268
+ return context;
269
+ }
270
+ function useSlotContent(slot) {
271
+ const { getContent } = useUISlots();
272
+ return getContent(slot);
273
+ }
274
+ function useSlotHasContent(slot) {
275
+ const { hasContent } = useUISlots();
276
+ return hasContent(slot);
277
+ }
278
278
 
279
279
  export { BUILT_IN_THEMES, ThemeContext_default, ThemeProvider, UISlotContext, UISlotProvider, useSlotContent, useSlotHasContent, useTheme, useUISlots };