@almadar/ui 1.0.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.
@@ -0,0 +1,291 @@
1
+ import { ClassValue } from 'clsx';
2
+
3
+ /**
4
+ * Utility function to merge Tailwind CSS classes
5
+ * Combines clsx for conditional classes with tailwind-merge to handle conflicts
6
+ */
7
+ declare function cn(...inputs: ClassValue[]): string;
8
+
9
+ /**
10
+ * API Client - HTTP client for backend API calls
11
+ *
12
+ * Provides typed methods for making API requests.
13
+ * All requests go through the backend server, NOT directly to Firestore.
14
+ *
15
+ * @packageDocumentation
16
+ */
17
+ /**
18
+ * API Error class for handling HTTP errors
19
+ */
20
+ declare class ApiError extends Error {
21
+ status: number;
22
+ statusText: string;
23
+ constructor(status: number, statusText: string, message?: string);
24
+ }
25
+ /**
26
+ * API client with typed methods
27
+ */
28
+ declare const apiClient: {
29
+ /**
30
+ * GET request
31
+ */
32
+ get<T>(endpoint: string): Promise<T>;
33
+ /**
34
+ * POST request
35
+ */
36
+ post<T>(endpoint: string, data?: unknown): Promise<T>;
37
+ /**
38
+ * PUT request
39
+ */
40
+ put<T>(endpoint: string, data?: unknown): Promise<T>;
41
+ /**
42
+ * PATCH request
43
+ */
44
+ patch<T>(endpoint: string, data?: unknown): Promise<T>;
45
+ /**
46
+ * DELETE request
47
+ */
48
+ delete<T = void>(endpoint: string): Promise<T>;
49
+ };
50
+
51
+ /**
52
+ * Debug utilities for development
53
+ */
54
+ declare function isDebugEnabled(): boolean;
55
+ declare function debug(...args: unknown[]): void;
56
+ declare function debugGroup(label: string): void;
57
+ declare function debugGroupEnd(): void;
58
+ declare function debugWarn(...args: unknown[]): void;
59
+ declare function debugError(...args: unknown[]): void;
60
+ declare function debugTable(data: unknown): void;
61
+ declare function debugTime(label: string): void;
62
+ declare function debugTimeEnd(label: string): void;
63
+ /**
64
+ * Debug input events (keyboard, mouse, touch)
65
+ * @param inputType - Type of input (e.g., 'keydown', 'keyup', 'mouse')
66
+ * @param data - Input data to log
67
+ */
68
+ declare function debugInput(inputType: string, data: unknown): void;
69
+ /**
70
+ * Debug collision events between entities
71
+ * @param entityA - First entity in collision
72
+ * @param entityB - Second entity in collision
73
+ * @param details - Additional collision details
74
+ */
75
+ declare function debugCollision(entityA: {
76
+ id?: string;
77
+ type?: string;
78
+ }, entityB: {
79
+ id?: string;
80
+ type?: string;
81
+ }, details?: unknown): void;
82
+ /**
83
+ * Debug physics updates (position, velocity)
84
+ * @param entityId - Entity identifier
85
+ * @param physics - Physics data to log
86
+ */
87
+ declare function debugPhysics(entityId: string, physics: unknown): void;
88
+ /**
89
+ * Debug game state changes
90
+ * @param stateName - Name of the state that changed
91
+ * @param value - New state value
92
+ */
93
+ declare function debugGameState(stateName: string, value: unknown): void;
94
+
95
+ /**
96
+ * Debug Utilities - Functions for toggling and checking debug mode
97
+ *
98
+ * @packageDocumentation
99
+ */
100
+ type DebugToggleListener = (enabled: boolean) => void;
101
+ /**
102
+ * Enable or disable debug mode
103
+ */
104
+ declare function setDebugEnabled(enabled: boolean): void;
105
+ /**
106
+ * Toggle debug mode
107
+ */
108
+ declare function toggleDebug(): boolean;
109
+ /**
110
+ * Subscribe to debug mode changes
111
+ */
112
+ declare function onDebugToggle(listener: DebugToggleListener): () => void;
113
+ /**
114
+ * Initialize debug mode from keyboard shortcut (Ctrl+Shift+D)
115
+ */
116
+ declare function initDebugShortcut(): () => void;
117
+
118
+ /**
119
+ * Entity Debug - Provides entity state snapshots for debugging
120
+ *
121
+ * @packageDocumentation
122
+ */
123
+ interface EntityState {
124
+ id: string;
125
+ type: string;
126
+ fields: Record<string, unknown>;
127
+ lastUpdated: number;
128
+ }
129
+ interface RuntimeEntity {
130
+ id: string;
131
+ type: string;
132
+ data: Record<string, unknown>;
133
+ }
134
+ interface PersistentEntityInfo {
135
+ loaded: boolean;
136
+ count: number;
137
+ }
138
+ interface EntitySnapshot {
139
+ entities: EntityState[];
140
+ timestamp: number;
141
+ totalCount: number;
142
+ /** Singleton entities by name */
143
+ singletons: Record<string, unknown>;
144
+ /** Runtime entities (in-memory) */
145
+ runtime: RuntimeEntity[];
146
+ /** Persistent entities info by type */
147
+ persistent: Record<string, PersistentEntityInfo>;
148
+ }
149
+ type EntityProvider = () => EntityState[];
150
+ declare function setEntityProvider(provider: EntityProvider): void;
151
+ declare function clearEntityProvider(): void;
152
+ declare function getEntitySnapshot(): EntitySnapshot | null;
153
+ declare function getEntityById(id: string): EntityState | undefined;
154
+ declare function getEntitiesByType(type: string): EntityState[];
155
+
156
+ /**
157
+ * Debug Registry - Central event log for debugging
158
+ *
159
+ * @packageDocumentation
160
+ */
161
+ type DebugEventType = 'state-change' | 'event-fired' | 'effect-executed' | 'guard-evaluated' | 'error' | 'warning' | 'info';
162
+ interface DebugEvent {
163
+ id: string;
164
+ type: DebugEventType;
165
+ source: string;
166
+ message: string;
167
+ data?: Record<string, unknown>;
168
+ timestamp: number;
169
+ }
170
+ type ChangeListener$3 = () => void;
171
+ declare function logDebugEvent(type: DebugEventType, source: string, message: string, data?: Record<string, unknown>): void;
172
+ declare function logStateChange(source: string, from: string, to: string, event?: string): void;
173
+ declare function logEventFired(source: string, eventName: string, payload?: unknown): void;
174
+ declare function logEffectExecuted(source: string, effectType: string, details?: unknown): void;
175
+ declare function logError(source: string, message: string, error?: unknown): void;
176
+ declare function logWarning(source: string, message: string, data?: Record<string, unknown>): void;
177
+ declare function logInfo(source: string, message: string, data?: Record<string, unknown>): void;
178
+ declare function getDebugEvents(): DebugEvent[];
179
+ declare function getRecentEvents(count: number): DebugEvent[];
180
+ declare function getEventsByType(type: DebugEventType): DebugEvent[];
181
+ declare function getEventsBySource(source: string): DebugEvent[];
182
+ declare function subscribeToDebugEvents(listener: ChangeListener$3): () => void;
183
+ declare function clearDebugEvents(): void;
184
+
185
+ /**
186
+ * Guard Registry - Tracks guard evaluations for debugging
187
+ *
188
+ * @packageDocumentation
189
+ */
190
+ interface GuardContext {
191
+ traitName?: string;
192
+ type?: "transition" | "tick";
193
+ transitionFrom?: string;
194
+ transitionTo?: string;
195
+ tickName?: string;
196
+ [key: string]: unknown;
197
+ }
198
+ interface GuardEvaluation {
199
+ id: string;
200
+ traitName: string;
201
+ guardName: string;
202
+ expression: string;
203
+ result: boolean;
204
+ context: GuardContext;
205
+ timestamp: number;
206
+ /** Input values used in guard evaluation */
207
+ inputs: Record<string, unknown>;
208
+ }
209
+ type ChangeListener$2 = () => void;
210
+ declare function recordGuardEvaluation(evaluation: Omit<GuardEvaluation, "id" | "timestamp">): void;
211
+ declare function getGuardHistory(): GuardEvaluation[];
212
+ declare function getRecentGuardEvaluations(count: number): GuardEvaluation[];
213
+ declare function getGuardEvaluationsForTrait(traitName: string): GuardEvaluation[];
214
+ declare function subscribeToGuardChanges(listener: ChangeListener$2): () => void;
215
+ declare function clearGuardHistory(): void;
216
+
217
+ /**
218
+ * Tick Registry - Tracks scheduled tick executions for debugging
219
+ *
220
+ * @packageDocumentation
221
+ */
222
+ interface TickExecution {
223
+ id: string;
224
+ traitName: string;
225
+ /** Tick name (display name) */
226
+ name: string;
227
+ /** Tick identifier */
228
+ tickName: string;
229
+ interval: number;
230
+ /** Last execution timestamp */
231
+ lastRun: number;
232
+ lastExecuted: number | null;
233
+ nextExecution: number | null;
234
+ /** Number of times this tick has run */
235
+ runCount: number;
236
+ executionCount: number;
237
+ /** Average execution time in ms */
238
+ executionTime: number;
239
+ /** Whether the tick is currently active */
240
+ active: boolean;
241
+ isActive: boolean;
242
+ /** Guard name if this tick has a guard */
243
+ guardName?: string;
244
+ /** Whether the guard passed on last evaluation */
245
+ guardPassed?: boolean;
246
+ }
247
+ type ChangeListener$1 = () => void;
248
+ declare function registerTick(tick: TickExecution): void;
249
+ declare function updateTickExecution(id: string, timestamp: number): void;
250
+ declare function setTickActive(id: string, isActive: boolean): void;
251
+ declare function unregisterTick(id: string): void;
252
+ declare function getAllTicks(): TickExecution[];
253
+ declare function getTick(id: string): TickExecution | undefined;
254
+ declare function subscribeToTickChanges(listener: ChangeListener$1): () => void;
255
+ declare function clearTicks(): void;
256
+
257
+ /**
258
+ * Trait Registry - Tracks active traits and their state machines for debugging
259
+ *
260
+ * @packageDocumentation
261
+ */
262
+ interface TraitTransition {
263
+ from: string;
264
+ to: string;
265
+ event: string;
266
+ guard?: string;
267
+ }
268
+ interface TraitGuard {
269
+ name: string;
270
+ lastResult?: boolean;
271
+ }
272
+ interface TraitDebugInfo {
273
+ id: string;
274
+ name: string;
275
+ currentState: string;
276
+ states: string[];
277
+ transitions: TraitTransition[];
278
+ guards: TraitGuard[];
279
+ transitionCount: number;
280
+ }
281
+ type ChangeListener = () => void;
282
+ declare function registerTrait(info: TraitDebugInfo): void;
283
+ declare function updateTraitState(id: string, newState: string): void;
284
+ declare function updateGuardResult(traitId: string, guardName: string, result: boolean): void;
285
+ declare function unregisterTrait(id: string): void;
286
+ declare function getAllTraits(): TraitDebugInfo[];
287
+ declare function getTrait(id: string): TraitDebugInfo | undefined;
288
+ declare function subscribeToTraitChanges(listener: ChangeListener): () => void;
289
+ declare function clearTraits(): void;
290
+
291
+ export { ApiError, type DebugEvent, type DebugEventType, type EntitySnapshot, type EntityState, type GuardContext, type GuardEvaluation, type PersistentEntityInfo, type RuntimeEntity, type TickExecution, type TraitDebugInfo, type TraitGuard, type TraitTransition, apiClient, clearDebugEvents, clearEntityProvider, clearGuardHistory, clearTicks, clearTraits, cn, debug, debugCollision, debugError, debugGameState, debugGroup, debugGroupEnd, debugInput, debugPhysics, debugTable, debugTime, debugTimeEnd, debugWarn, getAllTicks, getAllTraits, getDebugEvents, getEntitiesByType, getEntityById, getEntitySnapshot, getEventsBySource, getEventsByType, getGuardEvaluationsForTrait, getGuardHistory, getRecentEvents, getRecentGuardEvaluations, getTick, getTrait, initDebugShortcut, isDebugEnabled, logDebugEvent, logEffectExecuted, logError, logEventFired, logInfo, logStateChange, logWarning, onDebugToggle, recordGuardEvaluation, registerTick, registerTrait, setDebugEnabled, setEntityProvider, setTickActive, subscribeToDebugEvents, subscribeToGuardChanges, subscribeToTickChanges, subscribeToTraitChanges, toggleDebug, unregisterTick, unregisterTrait, updateGuardResult, updateTickExecution, updateTraitState };
@@ -0,0 +1,431 @@
1
+ import { clsx } from 'clsx';
2
+ import { twMerge } from 'tailwind-merge';
3
+
4
+ // lib/cn.ts
5
+ function cn(...inputs) {
6
+ return twMerge(clsx(inputs));
7
+ }
8
+
9
+ // lib/api-client.ts
10
+ var API_BASE_URL = typeof import.meta !== "undefined" && import.meta.env?.VITE_API_URL ? import.meta.env.VITE_API_URL : "/api";
11
+ var ApiError = class extends Error {
12
+ constructor(status, statusText, message) {
13
+ super(message || `API Error: ${status} ${statusText}`);
14
+ this.status = status;
15
+ this.statusText = statusText;
16
+ this.name = "ApiError";
17
+ }
18
+ };
19
+ async function handleResponse(response) {
20
+ if (!response.ok) {
21
+ let message;
22
+ try {
23
+ const errorData = await response.json();
24
+ message = errorData.message || errorData.error;
25
+ } catch {
26
+ }
27
+ throw new ApiError(response.status, response.statusText, message);
28
+ }
29
+ const text = await response.text();
30
+ if (!text) {
31
+ return void 0;
32
+ }
33
+ return JSON.parse(text);
34
+ }
35
+ function getHeaders() {
36
+ const headers = {
37
+ "Content-Type": "application/json"
38
+ };
39
+ const token = typeof localStorage !== "undefined" ? localStorage.getItem("authToken") : null;
40
+ if (token) {
41
+ headers["Authorization"] = `Bearer ${token}`;
42
+ }
43
+ return headers;
44
+ }
45
+ var apiClient = {
46
+ /**
47
+ * GET request
48
+ */
49
+ async get(endpoint) {
50
+ const response = await fetch(`${API_BASE_URL}${endpoint}`, {
51
+ method: "GET",
52
+ headers: getHeaders()
53
+ });
54
+ return handleResponse(response);
55
+ },
56
+ /**
57
+ * POST request
58
+ */
59
+ async post(endpoint, data) {
60
+ const response = await fetch(`${API_BASE_URL}${endpoint}`, {
61
+ method: "POST",
62
+ headers: getHeaders(),
63
+ body: data ? JSON.stringify(data) : void 0
64
+ });
65
+ return handleResponse(response);
66
+ },
67
+ /**
68
+ * PUT request
69
+ */
70
+ async put(endpoint, data) {
71
+ const response = await fetch(`${API_BASE_URL}${endpoint}`, {
72
+ method: "PUT",
73
+ headers: getHeaders(),
74
+ body: data ? JSON.stringify(data) : void 0
75
+ });
76
+ return handleResponse(response);
77
+ },
78
+ /**
79
+ * PATCH request
80
+ */
81
+ async patch(endpoint, data) {
82
+ const response = await fetch(`${API_BASE_URL}${endpoint}`, {
83
+ method: "PATCH",
84
+ headers: getHeaders(),
85
+ body: data ? JSON.stringify(data) : void 0
86
+ });
87
+ return handleResponse(response);
88
+ },
89
+ /**
90
+ * DELETE request
91
+ */
92
+ async delete(endpoint) {
93
+ const response = await fetch(`${API_BASE_URL}${endpoint}`, {
94
+ method: "DELETE",
95
+ headers: getHeaders()
96
+ });
97
+ return handleResponse(response);
98
+ }
99
+ };
100
+
101
+ // lib/debug.ts
102
+ var DEBUG_ENABLED = typeof window !== "undefined" && (localStorage.getItem("debug") === "true" || process.env.NODE_ENV === "development");
103
+ function isDebugEnabled() {
104
+ return DEBUG_ENABLED;
105
+ }
106
+ function debug(...args) {
107
+ if (DEBUG_ENABLED) {
108
+ console.log("[DEBUG]", ...args);
109
+ }
110
+ }
111
+ function debugGroup(label) {
112
+ if (DEBUG_ENABLED) {
113
+ console.group(`[DEBUG] ${label}`);
114
+ }
115
+ }
116
+ function debugGroupEnd() {
117
+ if (DEBUG_ENABLED) {
118
+ console.groupEnd();
119
+ }
120
+ }
121
+ function debugWarn(...args) {
122
+ if (DEBUG_ENABLED) {
123
+ console.warn("[DEBUG]", ...args);
124
+ }
125
+ }
126
+ function debugError(...args) {
127
+ if (DEBUG_ENABLED) {
128
+ console.error("[DEBUG]", ...args);
129
+ }
130
+ }
131
+ function debugTable(data) {
132
+ if (DEBUG_ENABLED) {
133
+ console.table(data);
134
+ }
135
+ }
136
+ function debugTime(label) {
137
+ if (DEBUG_ENABLED) {
138
+ console.time(`[DEBUG] ${label}`);
139
+ }
140
+ }
141
+ function debugTimeEnd(label) {
142
+ if (DEBUG_ENABLED) {
143
+ console.timeEnd(`[DEBUG] ${label}`);
144
+ }
145
+ }
146
+ function debugInput(inputType, data) {
147
+ if (DEBUG_ENABLED) {
148
+ console.log(`[DEBUG:INPUT] ${inputType}:`, data);
149
+ }
150
+ }
151
+ function debugCollision(entityA, entityB, details) {
152
+ if (DEBUG_ENABLED) {
153
+ console.log(
154
+ `[DEBUG:COLLISION] ${entityA.type || entityA.id} <-> ${entityB.type || entityB.id}`,
155
+ details ?? ""
156
+ );
157
+ }
158
+ }
159
+ function debugPhysics(entityId, physics) {
160
+ if (DEBUG_ENABLED) {
161
+ console.log(`[DEBUG:PHYSICS] ${entityId}:`, physics);
162
+ }
163
+ }
164
+ function debugGameState(stateName, value) {
165
+ if (DEBUG_ENABLED) {
166
+ console.log(`[DEBUG:GAME_STATE] ${stateName}:`, value);
167
+ }
168
+ }
169
+
170
+ // lib/debugUtils.ts
171
+ var DEBUG_STORAGE_KEY = "orbital-debug";
172
+ var listeners = /* @__PURE__ */ new Set();
173
+ function isDebugEnabled2() {
174
+ if (typeof window === "undefined") return false;
175
+ return localStorage.getItem(DEBUG_STORAGE_KEY) === "true";
176
+ }
177
+ function setDebugEnabled(enabled) {
178
+ if (typeof window === "undefined") return;
179
+ localStorage.setItem(DEBUG_STORAGE_KEY, String(enabled));
180
+ listeners.forEach((listener) => listener(enabled));
181
+ }
182
+ function toggleDebug() {
183
+ const newValue = !isDebugEnabled2();
184
+ setDebugEnabled(newValue);
185
+ return newValue;
186
+ }
187
+ function onDebugToggle(listener) {
188
+ listeners.add(listener);
189
+ return () => listeners.delete(listener);
190
+ }
191
+ function initDebugShortcut() {
192
+ if (typeof window === "undefined") return () => {
193
+ };
194
+ const handleKeyDown = (e) => {
195
+ if (e.ctrlKey && e.shiftKey && e.key === "D") {
196
+ e.preventDefault();
197
+ toggleDebug();
198
+ }
199
+ };
200
+ window.addEventListener("keydown", handleKeyDown);
201
+ return () => window.removeEventListener("keydown", handleKeyDown);
202
+ }
203
+
204
+ // lib/entityDebug.ts
205
+ var entityProvider = null;
206
+ function setEntityProvider(provider) {
207
+ entityProvider = provider;
208
+ }
209
+ function clearEntityProvider() {
210
+ entityProvider = null;
211
+ }
212
+ function getEntitySnapshot() {
213
+ if (!entityProvider) {
214
+ return null;
215
+ }
216
+ const entities = entityProvider();
217
+ return {
218
+ entities,
219
+ timestamp: Date.now(),
220
+ totalCount: entities.length,
221
+ singletons: {},
222
+ runtime: entities.map((e) => ({ id: e.id, type: e.type, data: e.fields })),
223
+ persistent: {}
224
+ };
225
+ }
226
+ function getEntityById(id) {
227
+ if (!entityProvider) {
228
+ return void 0;
229
+ }
230
+ return entityProvider().find((e) => e.id === id);
231
+ }
232
+ function getEntitiesByType(type) {
233
+ if (!entityProvider) {
234
+ return [];
235
+ }
236
+ return entityProvider().filter((e) => e.type === type);
237
+ }
238
+
239
+ // lib/debugRegistry.ts
240
+ var events = [];
241
+ var listeners2 = /* @__PURE__ */ new Set();
242
+ var MAX_EVENTS = 500;
243
+ function notifyListeners() {
244
+ listeners2.forEach((listener) => listener());
245
+ }
246
+ function logDebugEvent(type, source, message, data) {
247
+ const event = {
248
+ id: `event-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
249
+ type,
250
+ source,
251
+ message,
252
+ data,
253
+ timestamp: Date.now()
254
+ };
255
+ events.unshift(event);
256
+ if (events.length > MAX_EVENTS) {
257
+ events.pop();
258
+ }
259
+ notifyListeners();
260
+ }
261
+ function logStateChange(source, from, to, event) {
262
+ logDebugEvent("state-change", source, `${from} \u2192 ${to}`, { from, to, event });
263
+ }
264
+ function logEventFired(source, eventName, payload) {
265
+ logDebugEvent("event-fired", source, eventName, { eventName, payload });
266
+ }
267
+ function logEffectExecuted(source, effectType, details) {
268
+ logDebugEvent("effect-executed", source, effectType, { effectType, details });
269
+ }
270
+ function logError(source, message, error) {
271
+ logDebugEvent("error", source, message, { error });
272
+ }
273
+ function logWarning(source, message, data) {
274
+ logDebugEvent("warning", source, message, data);
275
+ }
276
+ function logInfo(source, message, data) {
277
+ logDebugEvent("info", source, message, data);
278
+ }
279
+ function getDebugEvents() {
280
+ return [...events];
281
+ }
282
+ function getRecentEvents(count) {
283
+ return events.slice(0, count);
284
+ }
285
+ function getEventsByType(type) {
286
+ return events.filter((e) => e.type === type);
287
+ }
288
+ function getEventsBySource(source) {
289
+ return events.filter((e) => e.source === source);
290
+ }
291
+ function subscribeToDebugEvents(listener) {
292
+ listeners2.add(listener);
293
+ return () => listeners2.delete(listener);
294
+ }
295
+ function clearDebugEvents() {
296
+ events.length = 0;
297
+ notifyListeners();
298
+ }
299
+
300
+ // lib/guardRegistry.ts
301
+ var guardHistory = [];
302
+ var listeners3 = /* @__PURE__ */ new Set();
303
+ var MAX_HISTORY = 100;
304
+ function notifyListeners2() {
305
+ listeners3.forEach((listener) => listener());
306
+ }
307
+ function recordGuardEvaluation(evaluation) {
308
+ const entry = {
309
+ ...evaluation,
310
+ id: `guard-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
311
+ timestamp: Date.now()
312
+ };
313
+ guardHistory.unshift(entry);
314
+ if (guardHistory.length > MAX_HISTORY) {
315
+ guardHistory.pop();
316
+ }
317
+ notifyListeners2();
318
+ }
319
+ function getGuardHistory() {
320
+ return [...guardHistory];
321
+ }
322
+ function getRecentGuardEvaluations(count) {
323
+ return guardHistory.slice(0, count);
324
+ }
325
+ function getGuardEvaluationsForTrait(traitName) {
326
+ return guardHistory.filter((g) => g.traitName === traitName);
327
+ }
328
+ function subscribeToGuardChanges(listener) {
329
+ listeners3.add(listener);
330
+ return () => listeners3.delete(listener);
331
+ }
332
+ function clearGuardHistory() {
333
+ guardHistory.length = 0;
334
+ notifyListeners2();
335
+ }
336
+
337
+ // lib/tickRegistry.ts
338
+ var ticks = /* @__PURE__ */ new Map();
339
+ var listeners4 = /* @__PURE__ */ new Set();
340
+ function notifyListeners3() {
341
+ listeners4.forEach((listener) => listener());
342
+ }
343
+ function registerTick(tick) {
344
+ ticks.set(tick.id, tick);
345
+ notifyListeners3();
346
+ }
347
+ function updateTickExecution(id, timestamp) {
348
+ const tick = ticks.get(id);
349
+ if (tick) {
350
+ tick.lastExecuted = timestamp;
351
+ tick.nextExecution = timestamp + tick.interval;
352
+ tick.executionCount++;
353
+ notifyListeners3();
354
+ }
355
+ }
356
+ function setTickActive(id, isActive) {
357
+ const tick = ticks.get(id);
358
+ if (tick) {
359
+ tick.isActive = isActive;
360
+ notifyListeners3();
361
+ }
362
+ }
363
+ function unregisterTick(id) {
364
+ ticks.delete(id);
365
+ notifyListeners3();
366
+ }
367
+ function getAllTicks() {
368
+ return Array.from(ticks.values());
369
+ }
370
+ function getTick(id) {
371
+ return ticks.get(id);
372
+ }
373
+ function subscribeToTickChanges(listener) {
374
+ listeners4.add(listener);
375
+ return () => listeners4.delete(listener);
376
+ }
377
+ function clearTicks() {
378
+ ticks.clear();
379
+ notifyListeners3();
380
+ }
381
+
382
+ // lib/traitRegistry.ts
383
+ var traits = /* @__PURE__ */ new Map();
384
+ var listeners5 = /* @__PURE__ */ new Set();
385
+ function notifyListeners4() {
386
+ listeners5.forEach((listener) => listener());
387
+ }
388
+ function registerTrait(info) {
389
+ traits.set(info.id, info);
390
+ notifyListeners4();
391
+ }
392
+ function updateTraitState(id, newState) {
393
+ const trait = traits.get(id);
394
+ if (trait) {
395
+ trait.currentState = newState;
396
+ trait.transitionCount++;
397
+ notifyListeners4();
398
+ }
399
+ }
400
+ function updateGuardResult(traitId, guardName, result) {
401
+ const trait = traits.get(traitId);
402
+ if (trait) {
403
+ const guard = trait.guards.find((g) => g.name === guardName);
404
+ if (guard) {
405
+ guard.lastResult = result;
406
+ notifyListeners4();
407
+ }
408
+ }
409
+ }
410
+ function unregisterTrait(id) {
411
+ traits.delete(id);
412
+ notifyListeners4();
413
+ }
414
+ function getAllTraits() {
415
+ return Array.from(traits.values());
416
+ }
417
+ function getTrait(id) {
418
+ return traits.get(id);
419
+ }
420
+ function subscribeToTraitChanges(listener) {
421
+ listeners5.add(listener);
422
+ return () => listeners5.delete(listener);
423
+ }
424
+ function clearTraits() {
425
+ traits.clear();
426
+ notifyListeners4();
427
+ }
428
+
429
+ export { ApiError, apiClient, clearDebugEvents, clearEntityProvider, clearGuardHistory, clearTicks, clearTraits, cn, debug, debugCollision, debugError, debugGameState, debugGroup, debugGroupEnd, debugInput, debugPhysics, debugTable, debugTime, debugTimeEnd, debugWarn, getAllTicks, getAllTraits, getDebugEvents, getEntitiesByType, getEntityById, getEntitySnapshot, getEventsBySource, getEventsByType, getGuardEvaluationsForTrait, getGuardHistory, getRecentEvents, getRecentGuardEvaluations, getTick, getTrait, initDebugShortcut, isDebugEnabled, logDebugEvent, logEffectExecuted, logError, logEventFired, logInfo, logStateChange, logWarning, onDebugToggle, recordGuardEvaluation, registerTick, registerTrait, setDebugEnabled, setEntityProvider, setTickActive, subscribeToDebugEvents, subscribeToGuardChanges, subscribeToTickChanges, subscribeToTraitChanges, toggleDebug, unregisterTick, unregisterTrait, updateGuardResult, updateTickExecution, updateTraitState };
430
+ //# sourceMappingURL=index.js.map
431
+ //# sourceMappingURL=index.js.map