@almadar/ui 2.13.1 → 2.13.3

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,215 +1,3 @@
1
- // lib/debugUtils.ts
2
- var DEBUG_STORAGE_KEY = "orbital-debug";
3
- var listeners = /* @__PURE__ */ new Set();
4
- function isDebugEnabled() {
5
- if (typeof window === "undefined") return false;
6
- return localStorage.getItem(DEBUG_STORAGE_KEY) === "true";
7
- }
8
- function setDebugEnabled(enabled) {
9
- if (typeof window === "undefined") return;
10
- localStorage.setItem(DEBUG_STORAGE_KEY, String(enabled));
11
- listeners.forEach((listener) => listener(enabled));
12
- }
13
- function toggleDebug() {
14
- const newValue = !isDebugEnabled();
15
- setDebugEnabled(newValue);
16
- return newValue;
17
- }
18
- function onDebugToggle(listener) {
19
- listeners.add(listener);
20
- return () => listeners.delete(listener);
21
- }
22
- function initDebugShortcut() {
23
- if (typeof window === "undefined") return () => {
24
- };
25
- const handleKeyDown = (e) => {
26
- if (e.ctrlKey && e.shiftKey && e.key === "D") {
27
- e.preventDefault();
28
- toggleDebug();
29
- }
30
- };
31
- window.addEventListener("keydown", handleKeyDown);
32
- return () => window.removeEventListener("keydown", handleKeyDown);
33
- }
34
-
35
- // lib/entityDebug.ts
36
- var entityProvider = null;
37
- function setEntityProvider(provider) {
38
- entityProvider = provider;
39
- }
40
- function clearEntityProvider() {
41
- entityProvider = null;
42
- }
43
- function getEntitySnapshot() {
44
- if (!entityProvider) {
45
- return null;
46
- }
47
- const entities = entityProvider();
48
- return {
49
- entities,
50
- timestamp: Date.now(),
51
- totalCount: entities.length,
52
- singletons: {},
53
- runtime: entities.map((e) => ({ id: e.id, type: e.type, data: e.fields })),
54
- persistent: {}
55
- };
56
- }
57
- function getEntityById(id) {
58
- if (!entityProvider) {
59
- return void 0;
60
- }
61
- return entityProvider().find((e) => e.id === id);
62
- }
63
- function getEntitiesByType(type) {
64
- if (!entityProvider) {
65
- return [];
66
- }
67
- return entityProvider().filter((e) => e.type === type);
68
- }
69
-
70
- // lib/debugRegistry.ts
71
- var events = [];
72
- var listeners2 = /* @__PURE__ */ new Set();
73
- var MAX_EVENTS = 500;
74
- function notifyListeners() {
75
- listeners2.forEach((listener) => listener());
76
- }
77
- function logDebugEvent(type, source, message, data) {
78
- const event = {
79
- id: `event-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
80
- type,
81
- source,
82
- message,
83
- data,
84
- timestamp: Date.now()
85
- };
86
- events.unshift(event);
87
- if (events.length > MAX_EVENTS) {
88
- events.pop();
89
- }
90
- notifyListeners();
91
- }
92
- function logStateChange(source, from, to, event) {
93
- logDebugEvent("state-change", source, `${from} \u2192 ${to}`, { from, to, event });
94
- }
95
- function logEventFired(source, eventName, payload) {
96
- logDebugEvent("event-fired", source, eventName, { eventName, payload });
97
- }
98
- function logEffectExecuted(source, effectType, details) {
99
- logDebugEvent("effect-executed", source, effectType, { effectType, details });
100
- }
101
- function logError(source, message, error) {
102
- logDebugEvent("error", source, message, { error });
103
- }
104
- function logWarning(source, message, data) {
105
- logDebugEvent("warning", source, message, data);
106
- }
107
- function logInfo(source, message, data) {
108
- logDebugEvent("info", source, message, data);
109
- }
110
- function getDebugEvents() {
111
- return [...events];
112
- }
113
- function getRecentEvents(count) {
114
- return events.slice(0, count);
115
- }
116
- function getEventsByType(type) {
117
- return events.filter((e) => e.type === type);
118
- }
119
- function getEventsBySource(source) {
120
- return events.filter((e) => e.source === source);
121
- }
122
- function subscribeToDebugEvents(listener) {
123
- listeners2.add(listener);
124
- return () => listeners2.delete(listener);
125
- }
126
- function clearDebugEvents() {
127
- events.length = 0;
128
- notifyListeners();
129
- }
130
-
131
- // lib/guardRegistry.ts
132
- var guardHistory = [];
133
- var listeners3 = /* @__PURE__ */ new Set();
134
- var MAX_HISTORY = 100;
135
- function notifyListeners2() {
136
- listeners3.forEach((listener) => listener());
137
- }
138
- function recordGuardEvaluation(evaluation) {
139
- const entry = {
140
- ...evaluation,
141
- id: `guard-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
142
- timestamp: Date.now()
143
- };
144
- guardHistory.unshift(entry);
145
- if (guardHistory.length > MAX_HISTORY) {
146
- guardHistory.pop();
147
- }
148
- notifyListeners2();
149
- }
150
- function getGuardHistory() {
151
- return [...guardHistory];
152
- }
153
- function getRecentGuardEvaluations(count) {
154
- return guardHistory.slice(0, count);
155
- }
156
- function getGuardEvaluationsForTrait(traitName) {
157
- return guardHistory.filter((g) => g.traitName === traitName);
158
- }
159
- function subscribeToGuardChanges(listener) {
160
- listeners3.add(listener);
161
- return () => listeners3.delete(listener);
162
- }
163
- function clearGuardHistory() {
164
- guardHistory.length = 0;
165
- notifyListeners2();
166
- }
167
-
168
- // lib/tickRegistry.ts
169
- var ticks = /* @__PURE__ */ new Map();
170
- var listeners4 = /* @__PURE__ */ new Set();
171
- function notifyListeners3() {
172
- listeners4.forEach((listener) => listener());
173
- }
174
- function registerTick(tick) {
175
- ticks.set(tick.id, tick);
176
- notifyListeners3();
177
- }
178
- function updateTickExecution(id, timestamp) {
179
- const tick = ticks.get(id);
180
- if (tick) {
181
- tick.lastExecuted = timestamp;
182
- tick.nextExecution = timestamp + tick.interval;
183
- tick.executionCount++;
184
- notifyListeners3();
185
- }
186
- }
187
- function setTickActive(id, isActive) {
188
- const tick = ticks.get(id);
189
- if (tick) {
190
- tick.isActive = isActive;
191
- notifyListeners3();
192
- }
193
- }
194
- function unregisterTick(id) {
195
- ticks.delete(id);
196
- notifyListeners3();
197
- }
198
- function getAllTicks() {
199
- return Array.from(ticks.values());
200
- }
201
- function getTick(id) {
202
- return ticks.get(id);
203
- }
204
- function subscribeToTickChanges(listener) {
205
- listeners4.add(listener);
206
- return () => listeners4.delete(listener);
207
- }
208
- function clearTicks() {
209
- ticks.clear();
210
- notifyListeners3();
211
- }
212
-
213
1
  // lib/visualizer/index.ts
214
2
  function formatSExprGuardToDomain(guard, _entityName) {
215
3
  if (Array.isArray(guard)) {
@@ -956,4 +744,216 @@ function parseContentSegments(content) {
956
744
  return segments;
957
745
  }
958
746
 
747
+ // lib/tickRegistry.ts
748
+ var ticks = /* @__PURE__ */ new Map();
749
+ var listeners = /* @__PURE__ */ new Set();
750
+ function notifyListeners() {
751
+ listeners.forEach((listener) => listener());
752
+ }
753
+ function registerTick(tick) {
754
+ ticks.set(tick.id, tick);
755
+ notifyListeners();
756
+ }
757
+ function updateTickExecution(id, timestamp) {
758
+ const tick = ticks.get(id);
759
+ if (tick) {
760
+ tick.lastExecuted = timestamp;
761
+ tick.nextExecution = timestamp + tick.interval;
762
+ tick.executionCount++;
763
+ notifyListeners();
764
+ }
765
+ }
766
+ function setTickActive(id, isActive) {
767
+ const tick = ticks.get(id);
768
+ if (tick) {
769
+ tick.isActive = isActive;
770
+ notifyListeners();
771
+ }
772
+ }
773
+ function unregisterTick(id) {
774
+ ticks.delete(id);
775
+ notifyListeners();
776
+ }
777
+ function getAllTicks() {
778
+ return Array.from(ticks.values());
779
+ }
780
+ function getTick(id) {
781
+ return ticks.get(id);
782
+ }
783
+ function subscribeToTickChanges(listener) {
784
+ listeners.add(listener);
785
+ return () => listeners.delete(listener);
786
+ }
787
+ function clearTicks() {
788
+ ticks.clear();
789
+ notifyListeners();
790
+ }
791
+
792
+ // lib/guardRegistry.ts
793
+ var guardHistory = [];
794
+ var listeners2 = /* @__PURE__ */ new Set();
795
+ var MAX_HISTORY = 100;
796
+ function notifyListeners2() {
797
+ listeners2.forEach((listener) => listener());
798
+ }
799
+ function recordGuardEvaluation(evaluation) {
800
+ const entry = {
801
+ ...evaluation,
802
+ id: `guard-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
803
+ timestamp: Date.now()
804
+ };
805
+ guardHistory.unshift(entry);
806
+ if (guardHistory.length > MAX_HISTORY) {
807
+ guardHistory.pop();
808
+ }
809
+ notifyListeners2();
810
+ }
811
+ function getGuardHistory() {
812
+ return [...guardHistory];
813
+ }
814
+ function getRecentGuardEvaluations(count) {
815
+ return guardHistory.slice(0, count);
816
+ }
817
+ function getGuardEvaluationsForTrait(traitName) {
818
+ return guardHistory.filter((g) => g.traitName === traitName);
819
+ }
820
+ function subscribeToGuardChanges(listener) {
821
+ listeners2.add(listener);
822
+ return () => listeners2.delete(listener);
823
+ }
824
+ function clearGuardHistory() {
825
+ guardHistory.length = 0;
826
+ notifyListeners2();
827
+ }
828
+
829
+ // lib/entityDebug.ts
830
+ var entityProvider = null;
831
+ function setEntityProvider(provider) {
832
+ entityProvider = provider;
833
+ }
834
+ function clearEntityProvider() {
835
+ entityProvider = null;
836
+ }
837
+ function getEntitySnapshot() {
838
+ if (!entityProvider) {
839
+ return null;
840
+ }
841
+ const entities = entityProvider();
842
+ return {
843
+ entities,
844
+ timestamp: Date.now(),
845
+ totalCount: entities.length,
846
+ singletons: {},
847
+ runtime: entities.map((e) => ({ id: e.id, type: e.type, data: e.fields })),
848
+ persistent: {}
849
+ };
850
+ }
851
+ function getEntityById(id) {
852
+ if (!entityProvider) {
853
+ return void 0;
854
+ }
855
+ return entityProvider().find((e) => e.id === id);
856
+ }
857
+ function getEntitiesByType(type) {
858
+ if (!entityProvider) {
859
+ return [];
860
+ }
861
+ return entityProvider().filter((e) => e.type === type);
862
+ }
863
+
864
+ // lib/debugRegistry.ts
865
+ var events = [];
866
+ var listeners3 = /* @__PURE__ */ new Set();
867
+ var MAX_EVENTS = 500;
868
+ function notifyListeners3() {
869
+ listeners3.forEach((listener) => listener());
870
+ }
871
+ function logDebugEvent(type, source, message, data) {
872
+ const event = {
873
+ id: `event-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
874
+ type,
875
+ source,
876
+ message,
877
+ data,
878
+ timestamp: Date.now()
879
+ };
880
+ events.unshift(event);
881
+ if (events.length > MAX_EVENTS) {
882
+ events.pop();
883
+ }
884
+ notifyListeners3();
885
+ }
886
+ function logStateChange(source, from, to, event) {
887
+ logDebugEvent("state-change", source, `${from} \u2192 ${to}`, { from, to, event });
888
+ }
889
+ function logEventFired(source, eventName, payload) {
890
+ logDebugEvent("event-fired", source, eventName, { eventName, payload });
891
+ }
892
+ function logEffectExecuted(source, effectType, details) {
893
+ logDebugEvent("effect-executed", source, effectType, { effectType, details });
894
+ }
895
+ function logError(source, message, error) {
896
+ logDebugEvent("error", source, message, { error });
897
+ }
898
+ function logWarning(source, message, data) {
899
+ logDebugEvent("warning", source, message, data);
900
+ }
901
+ function logInfo(source, message, data) {
902
+ logDebugEvent("info", source, message, data);
903
+ }
904
+ function getDebugEvents() {
905
+ return [...events];
906
+ }
907
+ function getRecentEvents(count) {
908
+ return events.slice(0, count);
909
+ }
910
+ function getEventsByType(type) {
911
+ return events.filter((e) => e.type === type);
912
+ }
913
+ function getEventsBySource(source) {
914
+ return events.filter((e) => e.source === source);
915
+ }
916
+ function subscribeToDebugEvents(listener) {
917
+ listeners3.add(listener);
918
+ return () => listeners3.delete(listener);
919
+ }
920
+ function clearDebugEvents() {
921
+ events.length = 0;
922
+ notifyListeners3();
923
+ }
924
+
925
+ // lib/debugUtils.ts
926
+ var DEBUG_STORAGE_KEY = "orbital-debug";
927
+ var listeners4 = /* @__PURE__ */ new Set();
928
+ function isDebugEnabled() {
929
+ if (typeof window === "undefined") return false;
930
+ return localStorage.getItem(DEBUG_STORAGE_KEY) === "true";
931
+ }
932
+ function setDebugEnabled(enabled) {
933
+ if (typeof window === "undefined") return;
934
+ localStorage.setItem(DEBUG_STORAGE_KEY, String(enabled));
935
+ listeners4.forEach((listener) => listener(enabled));
936
+ }
937
+ function toggleDebug() {
938
+ const newValue = !isDebugEnabled();
939
+ setDebugEnabled(newValue);
940
+ return newValue;
941
+ }
942
+ function onDebugToggle(listener) {
943
+ listeners4.add(listener);
944
+ return () => listeners4.delete(listener);
945
+ }
946
+ function initDebugShortcut() {
947
+ if (typeof window === "undefined") return () => {
948
+ };
949
+ const handleKeyDown = (e) => {
950
+ if (e.ctrlKey && e.shiftKey && e.key === "D") {
951
+ e.preventDefault();
952
+ toggleDebug();
953
+ }
954
+ };
955
+ window.addEventListener("keydown", handleKeyDown);
956
+ return () => window.removeEventListener("keydown", handleKeyDown);
957
+ }
958
+
959
959
  export { DEFAULT_CONFIG, clearDebugEvents, clearEntityProvider, clearGuardHistory, clearTicks, extractOutputsFromTransitions, extractStateMachine, formatGuard, getAllTicks, getDebugEvents, getEffectSummary, getEntitiesByType, getEntityById, getEntitySnapshot, getEventsBySource, getEventsByType, getGuardEvaluationsForTrait, getGuardHistory, getRecentEvents, getRecentGuardEvaluations, getTick, initDebugShortcut, isDebugEnabled, logDebugEvent, logEffectExecuted, logError, logEventFired, logInfo, logStateChange, logWarning, onDebugToggle, parseContentSegments, parseMarkdownWithCodeBlocks, recordGuardEvaluation, registerTick, renderStateMachineToDomData, renderStateMachineToSvg, setDebugEnabled, setEntityProvider, setTickActive, subscribeToDebugEvents, subscribeToGuardChanges, subscribeToTickChanges, toggleDebug, unregisterTick, updateTickExecution };
@@ -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 };
@@ -1,5 +1,5 @@
1
- import { useTheme, useUISlots } from './chunk-YLKXEXBP.js';
2
- import { useTranslate, useInfiniteScroll, useQuerySingleton, useLongPress, useSwipeGesture, useDragReorder, usePullToRefresh } from './chunk-3CP74CBL.js';
1
+ import { useTheme, useUISlots } from './chunk-DKQN5FVU.js';
2
+ import { useTranslate, useInfiniteScroll, useQuerySingleton, useLongPress, useSwipeGesture, useDragReorder, usePullToRefresh } from './chunk-Y7IHEYYE.js';
3
3
  import { useEventBus } from './chunk-YXZM3WCF.js';
4
4
  import { cn, debugGroup, debug, debugGroupEnd, updateAssetStatus, bindCanvasCapture, getNestedValue, isDebugEnabled } from './chunk-WCTZ7WZX.js';
5
5
  import { isPortalSlot } from './chunk-K2D5D3WK.js';
@@ -10916,6 +10916,14 @@ function IsometricCanvas({
10916
10916
  handleWheel(e, () => draw(animTimeRef.current));
10917
10917
  }
10918
10918
  }, [enableCamera, handleWheel, draw]);
10919
+ useEffect(() => {
10920
+ const canvas = canvasRef.current;
10921
+ if (!canvas) return;
10922
+ canvas.addEventListener("wheel", handleWheelWithCamera, { passive: false });
10923
+ return () => {
10924
+ canvas.removeEventListener("wheel", handleWheelWithCamera);
10925
+ };
10926
+ }, [handleWheelWithCamera]);
10919
10927
  const handleClick = useCallback((e) => {
10920
10928
  if (dragDistance() > 5) return;
10921
10929
  if (!canvasRef.current) return;
@@ -10971,7 +10979,6 @@ function IsometricCanvas({
10971
10979
  onMouseMove: handleMouseMoveWithCamera,
10972
10980
  onMouseUp: enableCamera ? handleMouseUp : void 0,
10973
10981
  onMouseLeave: handleMouseLeaveWithCamera,
10974
- onWheel: handleWheelWithCamera,
10975
10982
  onContextMenu: (e) => e.preventDefault(),
10976
10983
  className: "cursor-pointer",
10977
10984
  style: {
@@ -1,6 +1,6 @@
1
1
  import { subscribe, getSnapshot, clearEntities, removeEntity, updateSingleton, updateEntity, spawnEntity, getSingleton, getAllEntities, getByType, getEntity } from './chunk-N7MVUW4R.js';
2
2
  import { apiClient } from './chunk-3HJHHULT.js';
3
- import { SelectionContext, entityDataKeys, useEntityList } from './chunk-3CP74CBL.js';
3
+ import { SelectionContext, entityDataKeys, useEntityList } from './chunk-Y7IHEYYE.js';
4
4
  import { useEventBus } from './chunk-YXZM3WCF.js';
5
5
  import { useCallback, useState, useEffect, useMemo, useContext, useSyncExternalStore, useRef } from 'react';
6
6
  import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query';
@@ -1,6 +1,6 @@
1
- import { SuspenseConfigProvider } from './chunk-YYCP5CD7.js';
2
- import { ThemeProvider } from './chunk-YLKXEXBP.js';
3
- import { SelectionProvider, EntityDataProvider } from './chunk-3CP74CBL.js';
1
+ import { SuspenseConfigProvider } from './chunk-MSLMORZK.js';
2
+ import { ThemeProvider } from './chunk-DKQN5FVU.js';
3
+ import { SelectionProvider, EntityDataProvider } from './chunk-Y7IHEYYE.js';
4
4
  import { useEventBus, EventBusProvider } from './chunk-YXZM3WCF.js';
5
5
  import { recordTransition, registerCheck, bindEventBus, bindTraitStateGetter } from './chunk-WCTZ7WZX.js';
6
6
  import { useOfflineExecutor } from './chunk-K2D5D3WK.js';