@almadar/ui 1.0.10 → 1.0.12

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,30 +1,7 @@
1
1
  import { useUISlotManager } from './chunk-7NEWMNNU.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",
@@ -186,5 +163,28 @@ function useTheme() {
186
163
  return context;
187
164
  }
188
165
  var ThemeContext_default = ThemeContext;
166
+ var UISlotContext = createContext(null);
167
+ function UISlotProvider({ children }) {
168
+ const slotManager = useUISlotManager();
169
+ const contextValue = useMemo(() => slotManager, [slotManager]);
170
+ return /* @__PURE__ */ jsx(UISlotContext.Provider, { value: contextValue, children });
171
+ }
172
+ function useUISlots() {
173
+ const context = useContext(UISlotContext);
174
+ if (!context) {
175
+ throw new Error(
176
+ "useUISlots must be used within a UISlotProvider. Make sure your component tree is wrapped with <UISlotProvider>."
177
+ );
178
+ }
179
+ return context;
180
+ }
181
+ function useSlotContent(slot) {
182
+ const { getContent } = useUISlots();
183
+ return getContent(slot);
184
+ }
185
+ function useSlotHasContent(slot) {
186
+ const { hasContent } = useUISlots();
187
+ return hasContent(slot);
188
+ }
189
189
 
190
190
  export { BUILT_IN_THEMES, ThemeContext_default, ThemeProvider, UISlotContext, UISlotProvider, useSlotContent, useSlotHasContent, useTheme, useUISlots };
@@ -1,4 +1,4 @@
1
- import { ThemeProvider, useTheme } from './chunk-I5RSZIOE.js';
1
+ import { ThemeProvider, useTheme } from './chunk-DTKTZ3UR.js';
2
2
 
3
3
  // context/DesignThemeContext.tsx
4
4
  var DesignThemeProvider = ThemeProvider;
@@ -1,10 +1,10 @@
1
- import { useDesignTheme } from '../chunk-4FRUCUO5.js';
2
- import { useQuerySingleton, usePaginatedEntityList, useEntityList, useSelectedEntity, useEntityDetail, useEntities, useAuthContext } from '../chunk-BCERHHKU.js';
3
- export { ENTITY_EVENTS, entityDataKeys, parseQueryBinding, useAgentChat, useAuthContext, useCompile, useConnectGitHub, useCreateEntity, useDeepAgentGeneration, useDeleteEntity, useDisconnectGitHub, useEntities, useEntitiesByType, useEntity, useEntity2 as useEntityById, useEntityDetail, useEntityList, useEntityMutations, useExtensions, useFileEditor, useFileSystem, useGitHubBranches, useGitHubRepo, useGitHubRepos, useGitHubStatus, useInput, useOrbitalHistory, useOrbitalMutations, usePhysics, usePlayer, usePreview, useQuerySingleton, useSelectedEntity, useSendOrbitalEvent, useSingletonEntity, useUIEvents, useUpdateEntity, useValidation } from '../chunk-BCERHHKU.js';
1
+ import { useDesignTheme } from '../chunk-QFAKJLOK.js';
2
+ import { useQuerySingleton, usePaginatedEntityList, useEntityList, useSelectedEntity, useEntityDetail, useEntities, useAuthContext } from '../chunk-4AIGHVQK.js';
3
+ export { ENTITY_EVENTS, entityDataKeys, parseQueryBinding, useAgentChat, useAuthContext, useCompile, useConnectGitHub, useCreateEntity, useDeepAgentGeneration, useDeleteEntity, useDisconnectGitHub, useEntities, useEntitiesByType, useEntity, useEntity2 as useEntityById, useEntityDetail, useEntityList, useEntityMutations, useExtensions, useFileEditor, useFileSystem, useGitHubBranches, useGitHubRepo, useGitHubRepos, useGitHubStatus, useInput, useOrbitalHistory, useOrbitalMutations, usePhysics, usePlayer, usePreview, useQuerySingleton, useSelectedEntity, useSendOrbitalEvent, useSingletonEntity, useUIEvents, useUpdateEntity, useValidation } from '../chunk-4AIGHVQK.js';
4
4
  import { cn, debugGroup, debug, debugGroupEnd, getNestedValue, isDebugEnabled, debugInput, debugCollision } from '../chunk-KKCVDUK7.js';
5
5
  export { cn } from '../chunk-KKCVDUK7.js';
6
6
  import '../chunk-XSEDIUM6.js';
7
- import { useTheme, useUISlots } from '../chunk-I5RSZIOE.js';
7
+ import { useTheme, useUISlots } from '../chunk-DTKTZ3UR.js';
8
8
  import { useEventBus } from '../chunk-TTXKOHDO.js';
9
9
  export { useEmitEvent, useEventBus, useEventListener } from '../chunk-TTXKOHDO.js';
10
10
  export { DEFAULT_SLOTS, useUISlotManager } from '../chunk-7NEWMNNU.js';
@@ -1,5 +1,5 @@
1
- export { DesignThemeProvider, useDesignTheme } from '../chunk-4FRUCUO5.js';
2
- export { BUILT_IN_THEMES, ThemeContext_default as ThemeContext, ThemeProvider, UISlotContext, UISlotProvider, useSlotContent, useSlotHasContent, useTheme, useUISlots } from '../chunk-I5RSZIOE.js';
1
+ export { DesignThemeProvider, useDesignTheme } from '../chunk-QFAKJLOK.js';
2
+ export { BUILT_IN_THEMES, ThemeContext_default as ThemeContext, ThemeProvider, UISlotContext, UISlotProvider, useSlotContent, useSlotHasContent, useTheme, useUISlots } from '../chunk-DTKTZ3UR.js';
3
3
  import '../chunk-7NEWMNNU.js';
4
4
  import '../chunk-S7EYY36U.js';
5
5
  import { createContext, useCallback, useMemo, useContext } from 'react';
@@ -5,6 +5,133 @@ export { D as DEFAULT_SLOTS, R as RenderUIConfig, b as SlotAnimation, c as SlotC
5
5
  import * as _tanstack_react_query from '@tanstack/react-query';
6
6
  import { Entity, getEntity, getByType, getAllEntities, getSingleton, spawnEntity, updateEntity, updateSingleton, removeEntity, clearEntities } from '../stores/index.js';
7
7
 
8
+ /**
9
+ * useEntities Hook
10
+ *
11
+ * React hook to access the entity store.
12
+ * Uses useSyncExternalStore for efficient updates.
13
+ */
14
+
15
+ /**
16
+ * Hook to access all entities
17
+ */
18
+ declare function useEntities(): {
19
+ entities: Map<string, Entity>;
20
+ getEntity: typeof getEntity;
21
+ getByType: typeof getByType;
22
+ getAllEntities: typeof getAllEntities;
23
+ getSingleton: typeof getSingleton;
24
+ spawnEntity: typeof spawnEntity;
25
+ updateEntity: typeof updateEntity;
26
+ updateSingleton: typeof updateSingleton;
27
+ removeEntity: typeof removeEntity;
28
+ clearEntities: typeof clearEntities;
29
+ };
30
+ /**
31
+ * Hook to access a specific entity by ID
32
+ */
33
+ declare function useEntity$1(id: string): Entity | undefined;
34
+ /**
35
+ * Hook to access entities of a specific type
36
+ */
37
+ declare function useEntitiesByType(type: string): Entity[];
38
+ /**
39
+ * Hook to access a singleton entity by type
40
+ */
41
+ declare function useSingletonEntity<T extends Entity = Entity>(type: string): T | undefined;
42
+ /**
43
+ * Hook for Player entity (convenience)
44
+ */
45
+ declare function usePlayer(): {
46
+ player: Entity | undefined;
47
+ updatePlayer: (updates: Partial<Entity>) => void;
48
+ };
49
+ /**
50
+ * Hook for Physics entity (convenience)
51
+ */
52
+ declare function usePhysics(): {
53
+ physics: Entity | undefined;
54
+ updatePhysics: (updates: Partial<Entity>) => void;
55
+ };
56
+ /**
57
+ * Hook for Input entity (convenience)
58
+ */
59
+ declare function useInput(): {
60
+ input: Entity | undefined;
61
+ updateInput: (updates: Partial<Entity>) => void;
62
+ };
63
+
64
+ /**
65
+ * useEventBus Hook
66
+ *
67
+ * Provides event bus utilities for component communication.
68
+ * This connects to the EventBusProvider for real applications
69
+ * or provides a simple in-memory bus for design system / Storybook.
70
+ *
71
+ * @packageDocumentation
72
+ */
73
+
74
+ declare global {
75
+ interface Window {
76
+ __kflowEventBus?: EventBusContextType | null;
77
+ }
78
+ }
79
+ /**
80
+ * Hook for accessing the event bus.
81
+ *
82
+ * Uses EventBusProvider context if available, otherwise falls back to
83
+ * a simple in-memory event bus (for design system / Storybook).
84
+ *
85
+ * @returns Event bus instance with emit, on, once, and hasListeners methods
86
+ *
87
+ * @example
88
+ * ```tsx
89
+ * const eventBus = useEventBus();
90
+ *
91
+ * // Emit an event
92
+ * eventBus.emit('UI:CLICK', { id: '123' });
93
+ *
94
+ * // Subscribe to an event
95
+ * useEffect(() => {
96
+ * return eventBus.on('UI:CLICK', (event) => {
97
+ * console.log('Clicked:', event.payload);
98
+ * });
99
+ * }, []);
100
+ * ```
101
+ */
102
+ declare function useEventBus(): EventBusContextType;
103
+ /**
104
+ * Hook for subscribing to a specific event.
105
+ * Automatically cleans up subscription on unmount.
106
+ *
107
+ * @param event - Event name to subscribe to
108
+ * @param handler - Event handler function
109
+ *
110
+ * @example
111
+ * ```tsx
112
+ * useEventListener('UI:CLICK', (event) => {
113
+ * console.log('Clicked:', event.payload);
114
+ * });
115
+ * ```
116
+ */
117
+ declare function useEventListener(event: string, handler: EventListener): void;
118
+ /**
119
+ * Hook for emitting events.
120
+ * Returns a memoized emit function.
121
+ *
122
+ * @returns Function to emit events
123
+ *
124
+ * @example
125
+ * ```tsx
126
+ * const emit = useEmitEvent();
127
+ *
128
+ * const handleClick = () => {
129
+ * emit('UI:CLICK', { id: '123' });
130
+ * };
131
+ * ```
132
+ */
133
+ declare function useEmitEvent(): (type: string, payload?: Record<string, unknown>) => void;
134
+
8
135
  /**
9
136
  * useOrbitalHistory Hook
10
137
  *
@@ -478,77 +605,6 @@ interface UseValidationResult {
478
605
  }
479
606
  declare function useValidation(): UseValidationResult;
480
607
 
481
- /**
482
- * useEventBus Hook
483
- *
484
- * Provides event bus utilities for component communication.
485
- * This connects to the EventBusProvider for real applications
486
- * or provides a simple in-memory bus for design system / Storybook.
487
- *
488
- * @packageDocumentation
489
- */
490
-
491
- declare global {
492
- interface Window {
493
- __kflowEventBus?: EventBusContextType | null;
494
- }
495
- }
496
- /**
497
- * Hook for accessing the event bus.
498
- *
499
- * Uses EventBusProvider context if available, otherwise falls back to
500
- * a simple in-memory event bus (for design system / Storybook).
501
- *
502
- * @returns Event bus instance with emit, on, once, and hasListeners methods
503
- *
504
- * @example
505
- * ```tsx
506
- * const eventBus = useEventBus();
507
- *
508
- * // Emit an event
509
- * eventBus.emit('UI:CLICK', { id: '123' });
510
- *
511
- * // Subscribe to an event
512
- * useEffect(() => {
513
- * return eventBus.on('UI:CLICK', (event) => {
514
- * console.log('Clicked:', event.payload);
515
- * });
516
- * }, []);
517
- * ```
518
- */
519
- declare function useEventBus(): EventBusContextType;
520
- /**
521
- * Hook for subscribing to a specific event.
522
- * Automatically cleans up subscription on unmount.
523
- *
524
- * @param event - Event name to subscribe to
525
- * @param handler - Event handler function
526
- *
527
- * @example
528
- * ```tsx
529
- * useEventListener('UI:CLICK', (event) => {
530
- * console.log('Clicked:', event.payload);
531
- * });
532
- * ```
533
- */
534
- declare function useEventListener(event: string, handler: EventListener): void;
535
- /**
536
- * Hook for emitting events.
537
- * Returns a memoized emit function.
538
- *
539
- * @returns Function to emit events
540
- *
541
- * @example
542
- * ```tsx
543
- * const emit = useEmitEvent();
544
- *
545
- * const handleClick = () => {
546
- * emit('UI:CLICK', { id: '123' });
547
- * };
548
- * ```
549
- */
550
- declare function useEmitEvent(): (type: string, payload?: Record<string, unknown>) => void;
551
-
552
608
  /**
553
609
  * useUIEvents - UI Event to State Machine Bridge
554
610
  *
@@ -652,7 +708,7 @@ declare function useEntityList<T = Record<string, unknown>>(entity: string | und
652
708
  * @param id - Entity ID
653
709
  * @returns Single entity data and loading states
654
710
  */
655
- declare function useEntity$1<T = Record<string, unknown>>(entity: string | undefined, id: string | undefined): {
711
+ declare function useEntity<T = Record<string, unknown>>(entity: string | undefined, id: string | undefined): {
656
712
  data: T | null;
657
713
  isLoading: boolean;
658
714
  error: Error | null;
@@ -926,62 +982,6 @@ declare function useEntityMutations(entityName: string, options?: UseEntityMutat
926
982
  deleteError: Error | null;
927
983
  };
928
984
 
929
- /**
930
- * useEntities Hook
931
- *
932
- * React hook to access the entity store.
933
- * Uses useSyncExternalStore for efficient updates.
934
- */
935
-
936
- /**
937
- * Hook to access all entities
938
- */
939
- declare function useEntities(): {
940
- entities: Map<string, Entity>;
941
- getEntity: typeof getEntity;
942
- getByType: typeof getByType;
943
- getAllEntities: typeof getAllEntities;
944
- getSingleton: typeof getSingleton;
945
- spawnEntity: typeof spawnEntity;
946
- updateEntity: typeof updateEntity;
947
- updateSingleton: typeof updateSingleton;
948
- removeEntity: typeof removeEntity;
949
- clearEntities: typeof clearEntities;
950
- };
951
- /**
952
- * Hook to access a specific entity by ID
953
- */
954
- declare function useEntity(id: string): Entity | undefined;
955
- /**
956
- * Hook to access entities of a specific type
957
- */
958
- declare function useEntitiesByType(type: string): Entity[];
959
- /**
960
- * Hook to access a singleton entity by type
961
- */
962
- declare function useSingletonEntity<T extends Entity = Entity>(type: string): T | undefined;
963
- /**
964
- * Hook for Player entity (convenience)
965
- */
966
- declare function usePlayer(): {
967
- player: Entity | undefined;
968
- updatePlayer: (updates: Partial<Entity>) => void;
969
- };
970
- /**
971
- * Hook for Physics entity (convenience)
972
- */
973
- declare function usePhysics(): {
974
- physics: Entity | undefined;
975
- updatePhysics: (updates: Partial<Entity>) => void;
976
- };
977
- /**
978
- * Hook for Input entity (convenience)
979
- */
980
- declare function useInput(): {
981
- input: Entity | undefined;
982
- updateInput: (updates: Partial<Entity>) => void;
983
- };
984
-
985
985
  /**
986
986
  * Auth Context Hook Stub
987
987
  *
@@ -1072,4 +1072,4 @@ declare function useGitHubBranches(owner: string, repo: string, enabled?: boolea
1072
1072
  branches: string[];
1073
1073
  }, Error>;
1074
1074
 
1075
- export { type AuthContextValue, type AuthUser, type ChangeSummary, type CompileResult, type CompileStage, ENTITY_EVENTS, Entity, type EntityDataRecord, type EntityMutationResult, EventBusContextType, EventListener, type Extension, type ExtensionManifest, type FileSystemFile, type FileSystemStatus, type GitHubRepo, type GitHubStatus, type HistoryTimelineItem, type OpenFile, type OrbitalEventPayload, type OrbitalEventResponse, type QuerySingletonEntity, type QuerySingletonResult, type QuerySingletonState, type QueryState, type RevertResult, type SelectedFile, type UseCompileResult, type UseEntityDetailResult, type UseEntityListOptions, type UseEntityListResult, type UseEntityMutationsOptions, type UseExtensionsOptions, type UseExtensionsResult, type UseFileEditorOptions, type UseFileEditorResult, type UseFileSystemResult, type UseOrbitalHistoryOptions, type UseOrbitalHistoryResult, clearEntities, entityDataKeys, getAllEntities, getByType, getEntity, getSingleton, parseQueryBinding, removeEntity, spawnEntity, updateEntity, updateSingleton, useAgentChat, useAuthContext, useCompile, useConnectGitHub, useCreateEntity, useDeepAgentGeneration, useDeleteEntity, useDisconnectGitHub, useEmitEvent, useEntities, useEntitiesByType, useEntity$1 as useEntity, useEntity as useEntityById, useEntityDetail, useEntityList, useEntityMutations, useEventBus, useEventListener, useExtensions, useFileEditor, useFileSystem, useGitHubBranches, useGitHubRepo, useGitHubRepos, useGitHubStatus, useInput, useOrbitalHistory, useOrbitalMutations, usePhysics, usePlayer, usePreview, useQuerySingleton, useSelectedEntity, useSendOrbitalEvent, useSingletonEntity, useUIEvents, useUpdateEntity, useValidation };
1075
+ export { type AuthContextValue, type AuthUser, type ChangeSummary, type CompileResult, type CompileStage, ENTITY_EVENTS, Entity, type EntityDataRecord, type EntityMutationResult, EventBusContextType, EventListener, type Extension, type ExtensionManifest, type FileSystemFile, type FileSystemStatus, type GitHubRepo, type GitHubStatus, type HistoryTimelineItem, type OpenFile, type OrbitalEventPayload, type OrbitalEventResponse, type QuerySingletonEntity, type QuerySingletonResult, type QuerySingletonState, type QueryState, type RevertResult, type SelectedFile, type UseCompileResult, type UseEntityDetailResult, type UseEntityListOptions, type UseEntityListResult, type UseEntityMutationsOptions, type UseExtensionsOptions, type UseExtensionsResult, type UseFileEditorOptions, type UseFileEditorResult, type UseFileSystemResult, type UseOrbitalHistoryOptions, type UseOrbitalHistoryResult, clearEntities, entityDataKeys, getAllEntities, getByType, getEntity, getSingleton, parseQueryBinding, removeEntity, spawnEntity, updateEntity, updateSingleton, useAgentChat, useAuthContext, useCompile, useConnectGitHub, useCreateEntity, useDeepAgentGeneration, useDeleteEntity, useDisconnectGitHub, useEmitEvent, useEntities, useEntitiesByType, useEntity, useEntity$1 as useEntityById, useEntityDetail, useEntityList, useEntityMutations, useEventBus, useEventListener, useExtensions, useFileEditor, useFileSystem, useGitHubBranches, useGitHubRepo, useGitHubRepos, useGitHubStatus, useInput, useOrbitalHistory, useOrbitalMutations, usePhysics, usePlayer, usePreview, useQuerySingleton, useSelectedEntity, useSendOrbitalEvent, useSingletonEntity, useUIEvents, useUpdateEntity, useValidation };
@@ -1,4 +1,4 @@
1
- export { ENTITY_EVENTS, entityDataKeys, parseQueryBinding, useAgentChat, useAuthContext, useCompile, useConnectGitHub, useCreateEntity, useDeepAgentGeneration, useDeleteEntity, useDisconnectGitHub, useEntities, useEntitiesByType, useEntity, useEntity2 as useEntityById, useEntityDetail, useEntityList, useEntityMutations, useExtensions, useFileEditor, useFileSystem, useGitHubBranches, useGitHubRepo, useGitHubRepos, useGitHubStatus, useInput, useOrbitalHistory, useOrbitalMutations, usePhysics, usePlayer, usePreview, useQuerySingleton, useSelectedEntity, useSendOrbitalEvent, useSingletonEntity, useUIEvents, useUpdateEntity, useValidation } from '../chunk-BCERHHKU.js';
1
+ export { ENTITY_EVENTS, entityDataKeys, parseQueryBinding, useAgentChat, useAuthContext, useCompile, useConnectGitHub, useCreateEntity, useDeepAgentGeneration, useDeleteEntity, useDisconnectGitHub, useEntities, useEntitiesByType, useEntity, useEntity2 as useEntityById, useEntityDetail, useEntityList, useEntityMutations, useExtensions, useFileEditor, useFileSystem, useGitHubBranches, useGitHubRepo, useGitHubRepos, useGitHubStatus, useInput, useOrbitalHistory, useOrbitalMutations, usePhysics, usePlayer, usePreview, useQuerySingleton, useSelectedEntity, useSendOrbitalEvent, useSingletonEntity, useUIEvents, useUpdateEntity, useValidation } from '../chunk-4AIGHVQK.js';
2
2
  import '../chunk-XSEDIUM6.js';
3
3
  export { useEmitEvent, useEventBus, useEventListener } from '../chunk-TTXKOHDO.js';
4
4
  export { DEFAULT_SLOTS, useUISlotManager } from '../chunk-7NEWMNNU.js';
@@ -1,4 +1,4 @@
1
- import { ThemeProvider, UISlotProvider } from '../chunk-I5RSZIOE.js';
1
+ import { ThemeProvider, UISlotProvider } from '../chunk-DTKTZ3UR.js';
2
2
  import { EventBusProvider, SelectionProvider } from '../chunk-TTXKOHDO.js';
3
3
  export { EventBusContext, EventBusProvider, SelectionContext, SelectionProvider, useSelection, useSelectionOptional } from '../chunk-TTXKOHDO.js';
4
4
  import '../chunk-7NEWMNNU.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "main": "./dist/components/index.js",
@@ -60,9 +60,9 @@
60
60
  "remark-gfm": "^4.0.1",
61
61
  "remark-math": "^6.0.0",
62
62
  "react-force-graph-2d": "^1.28.0",
63
- "@almadar/evaluator": "1.0.10",
64
- "@almadar/core": "1.0.10",
65
- "@almadar/patterns": "1.0.10"
63
+ "@almadar/core": "1.0.12",
64
+ "@almadar/evaluator": "1.0.12",
65
+ "@almadar/patterns": "1.0.12"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "react": "^18.0.0",
File without changes