@almadar/ui 2.10.0 → 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.
package/dist/lib/index.js CHANGED
@@ -1,265 +1,4 @@
1
- export { DEFAULT_CONFIG, extractOutputsFromTransitions, extractStateMachine, formatGuard, getEffectSummary, parseContentSegments, parseMarkdownWithCodeBlocks, renderStateMachineToDomData, renderStateMachineToSvg } from '../chunk-N6DJVKZ6.js';
1
+ 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, 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 } from '../chunk-3E73CE7J.js';
2
2
  export { ApiError, apiClient } from '../chunk-3HJHHULT.js';
3
3
  export { bindCanvasCapture, bindEventBus, bindTraitStateGetter, clearVerification, cn, debug, debugCollision, debugError, debugGameState, debugGroup, debugGroupEnd, debugInput, debugPhysics, debugTable, debugTime, debugTimeEnd, debugWarn, formatNestedFieldLabel, getAllChecks, getBridgeHealth, getNestedValue, getSnapshot, getSummary, getTransitions, getTransitionsForTrait, isDebugEnabled, recordTransition, registerCheck, subscribeToVerification, updateAssetStatus, updateBridgeHealth, updateCheck, waitForTransition } from '../chunk-6D5QMEUS.js';
4
4
  import '../chunk-PKBMQBKP.js';
5
-
6
- // lib/debugUtils.ts
7
- var DEBUG_STORAGE_KEY = "orbital-debug";
8
- var listeners = /* @__PURE__ */ new Set();
9
- function isDebugEnabled2() {
10
- if (typeof window === "undefined") return false;
11
- return localStorage.getItem(DEBUG_STORAGE_KEY) === "true";
12
- }
13
- function setDebugEnabled(enabled) {
14
- if (typeof window === "undefined") return;
15
- localStorage.setItem(DEBUG_STORAGE_KEY, String(enabled));
16
- listeners.forEach((listener) => listener(enabled));
17
- }
18
- function toggleDebug() {
19
- const newValue = !isDebugEnabled2();
20
- setDebugEnabled(newValue);
21
- return newValue;
22
- }
23
- function onDebugToggle(listener) {
24
- listeners.add(listener);
25
- return () => listeners.delete(listener);
26
- }
27
- function initDebugShortcut() {
28
- if (typeof window === "undefined") return () => {
29
- };
30
- const handleKeyDown = (e) => {
31
- if (e.ctrlKey && e.shiftKey && e.key === "D") {
32
- e.preventDefault();
33
- toggleDebug();
34
- }
35
- };
36
- window.addEventListener("keydown", handleKeyDown);
37
- return () => window.removeEventListener("keydown", handleKeyDown);
38
- }
39
-
40
- // lib/entityDebug.ts
41
- var entityProvider = null;
42
- function setEntityProvider(provider) {
43
- entityProvider = provider;
44
- }
45
- function clearEntityProvider() {
46
- entityProvider = null;
47
- }
48
- function getEntitySnapshot() {
49
- if (!entityProvider) {
50
- return null;
51
- }
52
- const entities = entityProvider();
53
- return {
54
- entities,
55
- timestamp: Date.now(),
56
- totalCount: entities.length,
57
- singletons: {},
58
- runtime: entities.map((e) => ({ id: e.id, type: e.type, data: e.fields })),
59
- persistent: {}
60
- };
61
- }
62
- function getEntityById(id) {
63
- if (!entityProvider) {
64
- return void 0;
65
- }
66
- return entityProvider().find((e) => e.id === id);
67
- }
68
- function getEntitiesByType(type) {
69
- if (!entityProvider) {
70
- return [];
71
- }
72
- return entityProvider().filter((e) => e.type === type);
73
- }
74
-
75
- // lib/debugRegistry.ts
76
- var events = [];
77
- var listeners2 = /* @__PURE__ */ new Set();
78
- var MAX_EVENTS = 500;
79
- function notifyListeners() {
80
- listeners2.forEach((listener) => listener());
81
- }
82
- function logDebugEvent(type, source, message, data) {
83
- const event = {
84
- id: `event-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
85
- type,
86
- source,
87
- message,
88
- data,
89
- timestamp: Date.now()
90
- };
91
- events.unshift(event);
92
- if (events.length > MAX_EVENTS) {
93
- events.pop();
94
- }
95
- notifyListeners();
96
- }
97
- function logStateChange(source, from, to, event) {
98
- logDebugEvent("state-change", source, `${from} \u2192 ${to}`, { from, to, event });
99
- }
100
- function logEventFired(source, eventName, payload) {
101
- logDebugEvent("event-fired", source, eventName, { eventName, payload });
102
- }
103
- function logEffectExecuted(source, effectType, details) {
104
- logDebugEvent("effect-executed", source, effectType, { effectType, details });
105
- }
106
- function logError(source, message, error) {
107
- logDebugEvent("error", source, message, { error });
108
- }
109
- function logWarning(source, message, data) {
110
- logDebugEvent("warning", source, message, data);
111
- }
112
- function logInfo(source, message, data) {
113
- logDebugEvent("info", source, message, data);
114
- }
115
- function getDebugEvents() {
116
- return [...events];
117
- }
118
- function getRecentEvents(count) {
119
- return events.slice(0, count);
120
- }
121
- function getEventsByType(type) {
122
- return events.filter((e) => e.type === type);
123
- }
124
- function getEventsBySource(source) {
125
- return events.filter((e) => e.source === source);
126
- }
127
- function subscribeToDebugEvents(listener) {
128
- listeners2.add(listener);
129
- return () => listeners2.delete(listener);
130
- }
131
- function clearDebugEvents() {
132
- events.length = 0;
133
- notifyListeners();
134
- }
135
-
136
- // lib/guardRegistry.ts
137
- var guardHistory = [];
138
- var listeners3 = /* @__PURE__ */ new Set();
139
- var MAX_HISTORY = 100;
140
- function notifyListeners2() {
141
- listeners3.forEach((listener) => listener());
142
- }
143
- function recordGuardEvaluation(evaluation) {
144
- const entry = {
145
- ...evaluation,
146
- id: `guard-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
147
- timestamp: Date.now()
148
- };
149
- guardHistory.unshift(entry);
150
- if (guardHistory.length > MAX_HISTORY) {
151
- guardHistory.pop();
152
- }
153
- notifyListeners2();
154
- }
155
- function getGuardHistory() {
156
- return [...guardHistory];
157
- }
158
- function getRecentGuardEvaluations(count) {
159
- return guardHistory.slice(0, count);
160
- }
161
- function getGuardEvaluationsForTrait(traitName) {
162
- return guardHistory.filter((g) => g.traitName === traitName);
163
- }
164
- function subscribeToGuardChanges(listener) {
165
- listeners3.add(listener);
166
- return () => listeners3.delete(listener);
167
- }
168
- function clearGuardHistory() {
169
- guardHistory.length = 0;
170
- notifyListeners2();
171
- }
172
-
173
- // lib/tickRegistry.ts
174
- var ticks = /* @__PURE__ */ new Map();
175
- var listeners4 = /* @__PURE__ */ new Set();
176
- function notifyListeners3() {
177
- listeners4.forEach((listener) => listener());
178
- }
179
- function registerTick(tick) {
180
- ticks.set(tick.id, tick);
181
- notifyListeners3();
182
- }
183
- function updateTickExecution(id, timestamp) {
184
- const tick = ticks.get(id);
185
- if (tick) {
186
- tick.lastExecuted = timestamp;
187
- tick.nextExecution = timestamp + tick.interval;
188
- tick.executionCount++;
189
- notifyListeners3();
190
- }
191
- }
192
- function setTickActive(id, isActive) {
193
- const tick = ticks.get(id);
194
- if (tick) {
195
- tick.isActive = isActive;
196
- notifyListeners3();
197
- }
198
- }
199
- function unregisterTick(id) {
200
- ticks.delete(id);
201
- notifyListeners3();
202
- }
203
- function getAllTicks() {
204
- return Array.from(ticks.values());
205
- }
206
- function getTick(id) {
207
- return ticks.get(id);
208
- }
209
- function subscribeToTickChanges(listener) {
210
- listeners4.add(listener);
211
- return () => listeners4.delete(listener);
212
- }
213
- function clearTicks() {
214
- ticks.clear();
215
- notifyListeners3();
216
- }
217
-
218
- // lib/traitRegistry.ts
219
- var traits = /* @__PURE__ */ new Map();
220
- var listeners5 = /* @__PURE__ */ new Set();
221
- function notifyListeners4() {
222
- listeners5.forEach((listener) => listener());
223
- }
224
- function registerTrait(info) {
225
- traits.set(info.id, info);
226
- notifyListeners4();
227
- }
228
- function updateTraitState(id, newState) {
229
- const trait = traits.get(id);
230
- if (trait) {
231
- trait.currentState = newState;
232
- trait.transitionCount++;
233
- notifyListeners4();
234
- }
235
- }
236
- function updateGuardResult(traitId, guardName, result) {
237
- const trait = traits.get(traitId);
238
- if (trait) {
239
- const guard = trait.guards.find((g) => g.name === guardName);
240
- if (guard) {
241
- guard.lastResult = result;
242
- notifyListeners4();
243
- }
244
- }
245
- }
246
- function unregisterTrait(id) {
247
- traits.delete(id);
248
- notifyListeners4();
249
- }
250
- function getAllTraits() {
251
- return Array.from(traits.values());
252
- }
253
- function getTrait(id) {
254
- return traits.get(id);
255
- }
256
- function subscribeToTraitChanges(listener) {
257
- listeners5.add(listener);
258
- return () => listeners5.delete(listener);
259
- }
260
- function clearTraits() {
261
- traits.clear();
262
- notifyListeners4();
263
- }
264
-
265
- export { clearDebugEvents, clearEntityProvider, clearGuardHistory, clearTicks, clearTraits, getAllTicks, getAllTraits, getDebugEvents, getEntitiesByType, getEntityById, getEntitySnapshot, getEventsBySource, getEventsByType, getGuardEvaluationsForTrait, getGuardHistory, getRecentEvents, getRecentGuardEvaluations, getTick, getTrait, initDebugShortcut, logDebugEvent, logEffectExecuted, logError, logEventFired, logInfo, logStateChange, logWarning, onDebugToggle, recordGuardEvaluation, registerTick, registerTrait, setDebugEnabled, setEntityProvider, setTickActive, subscribeToDebugEvents, subscribeToGuardChanges, subscribeToTickChanges, subscribeToTraitChanges, toggleDebug, unregisterTick, unregisterTrait, updateGuardResult, updateTickExecution, updateTraitState };
@@ -4,7 +4,7 @@ import '../chunk-DKQN5FVU.js';
4
4
  export { SelectionContext, SelectionProvider, useSelection, useSelectionOptional } from '../chunk-WGJIL4YR.js';
5
5
  export { EventBusContext, EventBusProvider } from '../chunk-YXZM3WCF.js';
6
6
  import '../chunk-3JGAROCW.js';
7
- import '../chunk-6D5QMEUS.js';
8
7
  import '../chunk-TSETXL2E.js';
8
+ import '../chunk-6D5QMEUS.js';
9
9
  import '../chunk-K2D5D3WK.js';
10
10
  import '../chunk-PKBMQBKP.js';
@@ -7,8 +7,8 @@ import '../chunk-DKQN5FVU.js';
7
7
  import '../chunk-WGJIL4YR.js';
8
8
  import { useEventBus } from '../chunk-YXZM3WCF.js';
9
9
  import '../chunk-3JGAROCW.js';
10
- import '../chunk-6D5QMEUS.js';
11
10
  import '../chunk-TSETXL2E.js';
11
+ import '../chunk-6D5QMEUS.js';
12
12
  import '../chunk-K2D5D3WK.js';
13
13
  import '../chunk-PKBMQBKP.js';
14
14
  import { createContext, useMemo, useContext, useState, useRef, useEffect, useCallback } from 'react';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "main": "./dist/components/index.js",
@@ -1,194 +0,0 @@
1
- import { ClassValue } from 'clsx';
2
-
3
- /**
4
- * Orbital State Machine Visualizer
5
- *
6
- * Renders SVG diagrams from Orbital schemas and Trait definitions.
7
- * Can be used in documentation, IDE previews, and other tools.
8
- */
9
- interface VisualizerConfig {
10
- nodeRadius: number;
11
- nodeSpacing: number;
12
- initialIndicatorOffset: number;
13
- arrowSize: number;
14
- colors: {
15
- background: string;
16
- node: string;
17
- nodeBorder: string;
18
- nodeText: string;
19
- initialNode: string;
20
- finalNode: string;
21
- arrow: string;
22
- arrowText: string;
23
- effectText: string;
24
- guardText: string;
25
- initial: string;
26
- };
27
- fonts: {
28
- node: string;
29
- event: string;
30
- effect: string;
31
- };
32
- }
33
- interface StateDefinition {
34
- name: string;
35
- isInitial?: boolean;
36
- isFinal?: boolean;
37
- description?: string;
38
- }
39
- interface TransitionDefinition {
40
- from: string;
41
- to: string;
42
- event: string;
43
- guard?: unknown;
44
- effects?: unknown[];
45
- }
46
- interface StateMachineDefinition {
47
- states: StateDefinition[];
48
- transitions: TransitionDefinition[];
49
- }
50
- interface EntityDefinition {
51
- name: string;
52
- fields?: (string | {
53
- name: string;
54
- })[];
55
- }
56
- interface RenderOptions {
57
- title?: string;
58
- entity?: EntityDefinition;
59
- }
60
- /** Position data for a state node in DOM layout */
61
- interface DomStateNode {
62
- id: string;
63
- name: string;
64
- x: number;
65
- y: number;
66
- radius: number;
67
- isInitial: boolean;
68
- isFinal: boolean;
69
- description?: string;
70
- }
71
- /** Position data for a transition arrow */
72
- interface DomTransitionPath {
73
- id: string;
74
- from: string;
75
- to: string;
76
- /** SVG path data for the curved arrow */
77
- pathData: string;
78
- /** Midpoint for label positioning */
79
- labelX: number;
80
- labelY: number;
81
- }
82
- /** Position data for a transition label with guard/effect details */
83
- interface DomTransitionLabel {
84
- id: string;
85
- from: string;
86
- to: string;
87
- event: string;
88
- x: number;
89
- y: number;
90
- /** Human-readable guard text (e.g., "if amount > 100") */
91
- guardText?: string;
92
- /** Human-readable effect texts */
93
- effectTexts: string[];
94
- /** Whether this transition has details to show in tooltip */
95
- hasDetails: boolean;
96
- }
97
- /** Entity input box data */
98
- interface DomEntityBox {
99
- name: string;
100
- fields: string[];
101
- x: number;
102
- y: number;
103
- width: number;
104
- height: number;
105
- }
106
- /** Output effects box data */
107
- interface DomOutputsBox {
108
- outputs: string[];
109
- x: number;
110
- y: number;
111
- width: number;
112
- height: number;
113
- }
114
- /** Complete DOM layout data for rendering */
115
- interface DomLayoutData {
116
- width: number;
117
- height: number;
118
- title?: string;
119
- states: DomStateNode[];
120
- paths: DomTransitionPath[];
121
- labels: DomTransitionLabel[];
122
- entity?: DomEntityBox;
123
- outputs?: DomOutputsBox;
124
- config: VisualizerConfig;
125
- }
126
- declare const DEFAULT_CONFIG: VisualizerConfig;
127
- declare function formatGuard(guard: unknown): string;
128
- declare function getEffectSummary(effects: unknown[]): string;
129
- declare function extractOutputsFromTransitions(transitions: TransitionDefinition[]): string[];
130
- /**
131
- * Render a state machine to an SVG string.
132
- * Works in both browser and Node.js environments.
133
- */
134
- declare function renderStateMachineToSvg(stateMachine: StateMachineDefinition, options?: RenderOptions, config?: VisualizerConfig): string;
135
- /**
136
- * Extract state machine from various data formats (Trait, Orbital, or raw)
137
- */
138
- declare function extractStateMachine(data: unknown): StateMachineDefinition | null;
139
- /**
140
- * Render a state machine to DOM layout data.
141
- * This is used by the DOM-based visualizer component for hybrid SVG/DOM rendering.
142
- * Unlike renderStateMachineToSvg, this returns structured data instead of an SVG string.
143
- */
144
- declare function renderStateMachineToDomData(stateMachine: StateMachineDefinition, options?: RenderOptions, config?: VisualizerConfig): DomLayoutData;
145
-
146
- /**
147
- * Content Segment Parsing Utilities
148
- *
149
- * Parses rich content with code blocks and quiz tags into structured
150
- * segments for rendering. Detects orbital schemas in JSON code blocks
151
- * and marks them for JazariStateMachine rendering.
152
- */
153
- /** Segment types for content rendering */
154
- type ContentSegment = {
155
- type: 'markdown';
156
- content: string;
157
- } | {
158
- type: 'code';
159
- language: string;
160
- content: string;
161
- } | {
162
- type: 'orbital';
163
- language: string;
164
- content: string;
165
- schema: unknown;
166
- } | {
167
- type: 'quiz';
168
- question: string;
169
- answer: string;
170
- };
171
- /**
172
- * Parse markdown content to extract code blocks.
173
- *
174
- * Splits markdown into segments of plain markdown and fenced code blocks.
175
- * JSON/orb code blocks containing orbital schemas are tagged as 'orbital'.
176
- */
177
- declare function parseMarkdownWithCodeBlocks(content: string | undefined | null): ContentSegment[];
178
- /**
179
- * Parse content to extract all segments including quiz tags and code blocks.
180
- *
181
- * Supported tags:
182
- * - <question>q</question><answer>a</answer> — Quiz Q&A
183
- *
184
- * Also handles fenced code blocks (```language...```) with orbital detection.
185
- */
186
- declare function parseContentSegments(content: string | undefined | null): ContentSegment[];
187
-
188
- /**
189
- * Utility function to merge Tailwind CSS classes
190
- * Combines clsx for conditional classes with tailwind-merge to handle conflicts
191
- */
192
- declare function cn(...inputs: ClassValue[]): string;
193
-
194
- export { type ContentSegment as C, DEFAULT_CONFIG as D, type EntityDefinition as E, type RenderOptions as R, type StateDefinition as S, type TransitionDefinition as T, type VisualizerConfig as V, type DomEntityBox as a, type DomLayoutData as b, type DomOutputsBox as c, type DomStateNode as d, type DomTransitionLabel as e, type DomTransitionPath as f, type StateMachineDefinition as g, cn as h, extractOutputsFromTransitions as i, extractStateMachine as j, formatGuard as k, getEffectSummary as l, parseMarkdownWithCodeBlocks as m, renderStateMachineToSvg as n, parseContentSegments as p, renderStateMachineToDomData as r };