@almadar/ui 2.9.4 → 2.11.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.
@@ -744,4 +744,263 @@ function parseContentSegments(content) {
744
744
  return segments;
745
745
  }
746
746
 
747
- export { DEFAULT_CONFIG, extractOutputsFromTransitions, extractStateMachine, formatGuard, getEffectSummary, parseContentSegments, parseMarkdownWithCodeBlocks, renderStateMachineToDomData, renderStateMachineToSvg };
747
+ // lib/traitRegistry.ts
748
+ var traits = /* @__PURE__ */ new Map();
749
+ var listeners = /* @__PURE__ */ new Set();
750
+ function notifyListeners() {
751
+ listeners.forEach((listener) => listener());
752
+ }
753
+ function registerTrait(info) {
754
+ traits.set(info.id, info);
755
+ notifyListeners();
756
+ }
757
+ function updateTraitState(id, newState) {
758
+ const trait = traits.get(id);
759
+ if (trait) {
760
+ trait.currentState = newState;
761
+ trait.transitionCount++;
762
+ notifyListeners();
763
+ }
764
+ }
765
+ function updateGuardResult(traitId, guardName, result) {
766
+ const trait = traits.get(traitId);
767
+ if (trait) {
768
+ const guard = trait.guards.find((g) => g.name === guardName);
769
+ if (guard) {
770
+ guard.lastResult = result;
771
+ notifyListeners();
772
+ }
773
+ }
774
+ }
775
+ function unregisterTrait(id) {
776
+ traits.delete(id);
777
+ notifyListeners();
778
+ }
779
+ function getAllTraits() {
780
+ return Array.from(traits.values());
781
+ }
782
+ function getTrait(id) {
783
+ return traits.get(id);
784
+ }
785
+ function subscribeToTraitChanges(listener) {
786
+ listeners.add(listener);
787
+ return () => listeners.delete(listener);
788
+ }
789
+ function clearTraits() {
790
+ traits.clear();
791
+ notifyListeners();
792
+ }
793
+
794
+ // lib/tickRegistry.ts
795
+ var ticks = /* @__PURE__ */ new Map();
796
+ var listeners2 = /* @__PURE__ */ new Set();
797
+ function notifyListeners2() {
798
+ listeners2.forEach((listener) => listener());
799
+ }
800
+ function registerTick(tick) {
801
+ ticks.set(tick.id, tick);
802
+ notifyListeners2();
803
+ }
804
+ function updateTickExecution(id, timestamp) {
805
+ const tick = ticks.get(id);
806
+ if (tick) {
807
+ tick.lastExecuted = timestamp;
808
+ tick.nextExecution = timestamp + tick.interval;
809
+ tick.executionCount++;
810
+ notifyListeners2();
811
+ }
812
+ }
813
+ function setTickActive(id, isActive) {
814
+ const tick = ticks.get(id);
815
+ if (tick) {
816
+ tick.isActive = isActive;
817
+ notifyListeners2();
818
+ }
819
+ }
820
+ function unregisterTick(id) {
821
+ ticks.delete(id);
822
+ notifyListeners2();
823
+ }
824
+ function getAllTicks() {
825
+ return Array.from(ticks.values());
826
+ }
827
+ function getTick(id) {
828
+ return ticks.get(id);
829
+ }
830
+ function subscribeToTickChanges(listener) {
831
+ listeners2.add(listener);
832
+ return () => listeners2.delete(listener);
833
+ }
834
+ function clearTicks() {
835
+ ticks.clear();
836
+ notifyListeners2();
837
+ }
838
+
839
+ // lib/guardRegistry.ts
840
+ var guardHistory = [];
841
+ var listeners3 = /* @__PURE__ */ new Set();
842
+ var MAX_HISTORY = 100;
843
+ function notifyListeners3() {
844
+ listeners3.forEach((listener) => listener());
845
+ }
846
+ function recordGuardEvaluation(evaluation) {
847
+ const entry = {
848
+ ...evaluation,
849
+ id: `guard-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
850
+ timestamp: Date.now()
851
+ };
852
+ guardHistory.unshift(entry);
853
+ if (guardHistory.length > MAX_HISTORY) {
854
+ guardHistory.pop();
855
+ }
856
+ notifyListeners3();
857
+ }
858
+ function getGuardHistory() {
859
+ return [...guardHistory];
860
+ }
861
+ function getRecentGuardEvaluations(count) {
862
+ return guardHistory.slice(0, count);
863
+ }
864
+ function getGuardEvaluationsForTrait(traitName) {
865
+ return guardHistory.filter((g) => g.traitName === traitName);
866
+ }
867
+ function subscribeToGuardChanges(listener) {
868
+ listeners3.add(listener);
869
+ return () => listeners3.delete(listener);
870
+ }
871
+ function clearGuardHistory() {
872
+ guardHistory.length = 0;
873
+ notifyListeners3();
874
+ }
875
+
876
+ // lib/entityDebug.ts
877
+ var entityProvider = null;
878
+ function setEntityProvider(provider) {
879
+ entityProvider = provider;
880
+ }
881
+ function clearEntityProvider() {
882
+ entityProvider = null;
883
+ }
884
+ function getEntitySnapshot() {
885
+ if (!entityProvider) {
886
+ return null;
887
+ }
888
+ const entities = entityProvider();
889
+ return {
890
+ entities,
891
+ timestamp: Date.now(),
892
+ totalCount: entities.length,
893
+ singletons: {},
894
+ runtime: entities.map((e) => ({ id: e.id, type: e.type, data: e.fields })),
895
+ persistent: {}
896
+ };
897
+ }
898
+ function getEntityById(id) {
899
+ if (!entityProvider) {
900
+ return void 0;
901
+ }
902
+ return entityProvider().find((e) => e.id === id);
903
+ }
904
+ function getEntitiesByType(type) {
905
+ if (!entityProvider) {
906
+ return [];
907
+ }
908
+ return entityProvider().filter((e) => e.type === type);
909
+ }
910
+
911
+ // lib/debugRegistry.ts
912
+ var events = [];
913
+ var listeners4 = /* @__PURE__ */ new Set();
914
+ var MAX_EVENTS = 500;
915
+ function notifyListeners4() {
916
+ listeners4.forEach((listener) => listener());
917
+ }
918
+ function logDebugEvent(type, source, message, data) {
919
+ const event = {
920
+ id: `event-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
921
+ type,
922
+ source,
923
+ message,
924
+ data,
925
+ timestamp: Date.now()
926
+ };
927
+ events.unshift(event);
928
+ if (events.length > MAX_EVENTS) {
929
+ events.pop();
930
+ }
931
+ notifyListeners4();
932
+ }
933
+ function logStateChange(source, from, to, event) {
934
+ logDebugEvent("state-change", source, `${from} \u2192 ${to}`, { from, to, event });
935
+ }
936
+ function logEventFired(source, eventName, payload) {
937
+ logDebugEvent("event-fired", source, eventName, { eventName, payload });
938
+ }
939
+ function logEffectExecuted(source, effectType, details) {
940
+ logDebugEvent("effect-executed", source, effectType, { effectType, details });
941
+ }
942
+ function logError(source, message, error) {
943
+ logDebugEvent("error", source, message, { error });
944
+ }
945
+ function logWarning(source, message, data) {
946
+ logDebugEvent("warning", source, message, data);
947
+ }
948
+ function logInfo(source, message, data) {
949
+ logDebugEvent("info", source, message, data);
950
+ }
951
+ function getDebugEvents() {
952
+ return [...events];
953
+ }
954
+ function getRecentEvents(count) {
955
+ return events.slice(0, count);
956
+ }
957
+ function getEventsByType(type) {
958
+ return events.filter((e) => e.type === type);
959
+ }
960
+ function getEventsBySource(source) {
961
+ return events.filter((e) => e.source === source);
962
+ }
963
+ function subscribeToDebugEvents(listener) {
964
+ listeners4.add(listener);
965
+ return () => listeners4.delete(listener);
966
+ }
967
+ function clearDebugEvents() {
968
+ events.length = 0;
969
+ notifyListeners4();
970
+ }
971
+
972
+ // lib/debugUtils.ts
973
+ var DEBUG_STORAGE_KEY = "orbital-debug";
974
+ var listeners5 = /* @__PURE__ */ new Set();
975
+ function isDebugEnabled() {
976
+ if (typeof window === "undefined") return false;
977
+ return localStorage.getItem(DEBUG_STORAGE_KEY) === "true";
978
+ }
979
+ function setDebugEnabled(enabled) {
980
+ if (typeof window === "undefined") return;
981
+ localStorage.setItem(DEBUG_STORAGE_KEY, String(enabled));
982
+ listeners5.forEach((listener) => listener(enabled));
983
+ }
984
+ function toggleDebug() {
985
+ const newValue = !isDebugEnabled();
986
+ setDebugEnabled(newValue);
987
+ return newValue;
988
+ }
989
+ function onDebugToggle(listener) {
990
+ listeners5.add(listener);
991
+ return () => listeners5.delete(listener);
992
+ }
993
+ function initDebugShortcut() {
994
+ if (typeof window === "undefined") return () => {
995
+ };
996
+ const handleKeyDown = (e) => {
997
+ if (e.ctrlKey && e.shiftKey && e.key === "D") {
998
+ e.preventDefault();
999
+ toggleDebug();
1000
+ }
1001
+ };
1002
+ window.addEventListener("keydown", handleKeyDown);
1003
+ return () => window.removeEventListener("keydown", handleKeyDown);
1004
+ }
1005
+
1006
+ export { DEFAULT_CONFIG, clearDebugEvents, clearEntityProvider, clearGuardHistory, clearTicks, clearTraits, extractOutputsFromTransitions, extractStateMachine, formatGuard, getAllTicks, getAllTraits, getDebugEvents, getEffectSummary, getEntitiesByType, getEntityById, getEntitySnapshot, getEventsBySource, getEventsByType, getGuardEvaluationsForTrait, getGuardHistory, getRecentEvents, getRecentGuardEvaluations, getTick, getTrait, initDebugShortcut, isDebugEnabled, logDebugEvent, logEffectExecuted, logError, logEventFired, logInfo, logStateChange, logWarning, onDebugToggle, parseContentSegments, parseMarkdownWithCodeBlocks, recordGuardEvaluation, registerTick, registerTrait, renderStateMachineToDomData, renderStateMachineToSvg, setDebugEnabled, setEntityProvider, setTickActive, subscribeToDebugEvents, subscribeToGuardChanges, subscribeToTickChanges, subscribeToTraitChanges, toggleDebug, unregisterTick, unregisterTrait, updateGuardResult, updateTickExecution, updateTraitState };