@almadar/ui 1.0.34 → 2.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.
@@ -1,111 +0,0 @@
1
- /**
2
- * Isometric Game Types
3
- *
4
- * Type definitions for isometric grid rendering: tiles, units, features.
5
- * Used by IsometricCanvas and game hooks.
6
- *
7
- * @packageDocumentation
8
- */
9
- /** A single isometric tile on the grid */
10
- interface IsometricTile {
11
- /** Optional unique identifier (required for 3D rendering) */
12
- id?: string;
13
- /** Grid x coordinate */
14
- x: number;
15
- /** Grid y coordinate (2D) */
16
- y: number;
17
- /** Grid z coordinate (3D alternative to y) */
18
- z?: number;
19
- /** Terrain type key (e.g., 'grass', 'stone', 'water') - 2D */
20
- terrain?: string;
21
- /** Tile type for visual rendering (3D) */
22
- type?: string;
23
- /** Direct sprite URL override (bypasses getTerrainSprite resolver) */
24
- terrainSprite?: string;
25
- /** Whether units can traverse this tile (default true) */
26
- passable?: boolean;
27
- /** Movement cost for pathfinding (default 1) */
28
- movementCost?: number;
29
- /** Optional tile type for visual variants */
30
- tileType?: string;
31
- /** Elevation offset for 3D rendering */
32
- elevation?: number;
33
- }
34
- /** A unit positioned on the isometric grid */
35
- interface IsometricUnit {
36
- /** Unique unit identifier */
37
- id: string;
38
- /** Current grid position (2D format) */
39
- position?: {
40
- x: number;
41
- y: number;
42
- };
43
- /** Grid x coordinate (3D format) */
44
- x?: number;
45
- /** Grid y coordinate (3D format) */
46
- y?: number;
47
- /** Grid z coordinate (3D format) */
48
- z?: number;
49
- /** Static sprite URL (used when no sprite sheet animation) */
50
- sprite?: string;
51
- /** Unit archetype key for sprite resolution */
52
- unitType?: string;
53
- /** Hero identifier for sprite sheet lookup */
54
- heroId?: string;
55
- /** Display name rendered below the unit */
56
- name?: string;
57
- /** Team affiliation for coloring */
58
- team?: 'player' | 'enemy' | 'neutral';
59
- /** Faction for 3D rendering (player/enemy/neutral) */
60
- faction?: 'player' | 'enemy' | 'neutral';
61
- /** Current health */
62
- health?: number;
63
- /** Maximum health */
64
- maxHealth?: number;
65
- /** Trait attachments for state display */
66
- traits?: {
67
- name: string;
68
- currentState: string;
69
- states: string[];
70
- cooldown: number;
71
- }[];
72
- /** Previous position for movement trail ghost */
73
- previousPosition?: {
74
- x: number;
75
- y: number;
76
- };
77
- /** Elevation offset for 3D rendering */
78
- elevation?: number;
79
- }
80
- /** A map feature (resource, building, portal, etc.) */
81
- interface IsometricFeature {
82
- /** Optional unique identifier (required for 3D rendering) */
83
- id?: string;
84
- /** Grid x coordinate */
85
- x: number;
86
- /** Grid y coordinate (2D) */
87
- y: number;
88
- /** Grid z coordinate (3D alternative to y) */
89
- z?: number;
90
- /** Feature type key (e.g., 'goldMine', 'castle', 'portal') */
91
- type: string;
92
- /** Direct sprite URL override (bypasses getFeatureSprite resolver) */
93
- sprite?: string;
94
- /** 3D model URL (GLB format) for GameCanvas3D */
95
- assetUrl?: string;
96
- /** Color override for 3D rendering */
97
- color?: string;
98
- /** Elevation offset for 3D rendering */
99
- elevation?: number;
100
- }
101
- /** Camera state for pan/zoom */
102
- interface CameraState {
103
- /** Camera X offset in pixels */
104
- x: number;
105
- /** Camera Y offset in pixels */
106
- y: number;
107
- /** Zoom level (1.0 = 100%) */
108
- zoom: number;
109
- }
110
-
111
- export type { CameraState as C, IsometricTile as I, IsometricUnit as a, IsometricFeature as b };
@@ -1,427 +0,0 @@
1
- export { C as ContentSegment, D as DEFAULT_CONFIG, a as DomEntityBox, b as DomLayoutData, c as DomOutputsBox, d as DomStateNode, e as DomTransitionLabel, f as DomTransitionPath, E as EntityDefinition, R as RenderOptions, S as StateDefinition, g as StateMachineDefinition, T as TransitionDefinition, V as VisualizerConfig, h as cn, i as extractOutputsFromTransitions, j as extractStateMachine, k as formatGuard, l as getEffectSummary, p as parseContentSegments, m as parseMarkdownWithCodeBlocks, r as renderStateMachineToDomData, n as renderStateMachineToSvg } from '../cn-BoBXsxuX.js';
2
- import 'clsx';
3
-
4
- /**
5
- * API Client - HTTP client for backend API calls
6
- *
7
- * Provides typed methods for making API requests.
8
- * All requests go through the backend server, NOT directly to Firestore.
9
- *
10
- * @packageDocumentation
11
- */
12
- /**
13
- * API Error class for handling HTTP errors
14
- */
15
- declare class ApiError extends Error {
16
- status: number;
17
- statusText: string;
18
- constructor(status: number, statusText: string, message?: string);
19
- }
20
- /**
21
- * API client with typed methods
22
- */
23
- declare const apiClient: {
24
- /**
25
- * GET request
26
- */
27
- get<T>(endpoint: string): Promise<T>;
28
- /**
29
- * POST request
30
- */
31
- post<T>(endpoint: string, data?: unknown): Promise<T>;
32
- /**
33
- * PUT request
34
- */
35
- put<T>(endpoint: string, data?: unknown): Promise<T>;
36
- /**
37
- * PATCH request
38
- */
39
- patch<T>(endpoint: string, data?: unknown): Promise<T>;
40
- /**
41
- * DELETE request
42
- */
43
- delete<T = void>(endpoint: string): Promise<T>;
44
- };
45
-
46
- /**
47
- * Debug utilities for development
48
- */
49
- declare function isDebugEnabled(): boolean;
50
- declare function debug(...args: unknown[]): void;
51
- declare function debugGroup(label: string): void;
52
- declare function debugGroupEnd(): void;
53
- declare function debugWarn(...args: unknown[]): void;
54
- declare function debugError(...args: unknown[]): void;
55
- declare function debugTable(data: unknown): void;
56
- declare function debugTime(label: string): void;
57
- declare function debugTimeEnd(label: string): void;
58
- /**
59
- * Debug input events (keyboard, mouse, touch)
60
- * @param inputType - Type of input (e.g., 'keydown', 'keyup', 'mouse')
61
- * @param data - Input data to log
62
- */
63
- declare function debugInput(inputType: string, data: unknown): void;
64
- /**
65
- * Debug collision events between entities
66
- * @param entityA - First entity in collision
67
- * @param entityB - Second entity in collision
68
- * @param details - Additional collision details
69
- */
70
- declare function debugCollision(entityA: {
71
- id?: string;
72
- type?: string;
73
- }, entityB: {
74
- id?: string;
75
- type?: string;
76
- }, details?: unknown): void;
77
- /**
78
- * Debug physics updates (position, velocity)
79
- * @param entityId - Entity identifier
80
- * @param physics - Physics data to log
81
- */
82
- declare function debugPhysics(entityId: string, physics: unknown): void;
83
- /**
84
- * Debug game state changes
85
- * @param stateName - Name of the state that changed
86
- * @param value - New state value
87
- */
88
- declare function debugGameState(stateName: string, value: unknown): void;
89
-
90
- /**
91
- * Debug Utilities - Functions for toggling and checking debug mode
92
- *
93
- * @packageDocumentation
94
- */
95
- type DebugToggleListener = (enabled: boolean) => void;
96
- /**
97
- * Enable or disable debug mode
98
- */
99
- declare function setDebugEnabled(enabled: boolean): void;
100
- /**
101
- * Toggle debug mode
102
- */
103
- declare function toggleDebug(): boolean;
104
- /**
105
- * Subscribe to debug mode changes
106
- */
107
- declare function onDebugToggle(listener: DebugToggleListener): () => void;
108
- /**
109
- * Initialize debug mode from keyboard shortcut (Ctrl+Shift+D)
110
- */
111
- declare function initDebugShortcut(): () => void;
112
-
113
- /**
114
- * Entity Debug - Provides entity state snapshots for debugging
115
- *
116
- * @packageDocumentation
117
- */
118
- interface EntityState {
119
- id: string;
120
- type: string;
121
- fields: Record<string, unknown>;
122
- lastUpdated: number;
123
- }
124
- interface RuntimeEntity {
125
- id: string;
126
- type: string;
127
- data: Record<string, unknown>;
128
- }
129
- interface PersistentEntityInfo {
130
- loaded: boolean;
131
- count: number;
132
- }
133
- interface EntitySnapshot {
134
- entities: EntityState[];
135
- timestamp: number;
136
- totalCount: number;
137
- /** Singleton entities by name */
138
- singletons: Record<string, unknown>;
139
- /** Runtime entities (in-memory) */
140
- runtime: RuntimeEntity[];
141
- /** Persistent entities info by type */
142
- persistent: Record<string, PersistentEntityInfo>;
143
- }
144
- type EntityProvider = () => EntityState[];
145
- declare function setEntityProvider(provider: EntityProvider): void;
146
- declare function clearEntityProvider(): void;
147
- declare function getEntitySnapshot(): EntitySnapshot | null;
148
- declare function getEntityById(id: string): EntityState | undefined;
149
- declare function getEntitiesByType(type: string): EntityState[];
150
-
151
- /**
152
- * Debug Registry - Central event log for debugging
153
- *
154
- * @packageDocumentation
155
- */
156
- type DebugEventType = 'state-change' | 'event-fired' | 'effect-executed' | 'guard-evaluated' | 'error' | 'warning' | 'info';
157
- interface DebugEvent {
158
- id: string;
159
- type: DebugEventType;
160
- source: string;
161
- message: string;
162
- data?: Record<string, unknown>;
163
- timestamp: number;
164
- }
165
- type ChangeListener$4 = () => void;
166
- declare function logDebugEvent(type: DebugEventType, source: string, message: string, data?: Record<string, unknown>): void;
167
- declare function logStateChange(source: string, from: string, to: string, event?: string): void;
168
- declare function logEventFired(source: string, eventName: string, payload?: unknown): void;
169
- declare function logEffectExecuted(source: string, effectType: string, details?: unknown): void;
170
- declare function logError(source: string, message: string, error?: unknown): void;
171
- declare function logWarning(source: string, message: string, data?: Record<string, unknown>): void;
172
- declare function logInfo(source: string, message: string, data?: Record<string, unknown>): void;
173
- declare function getDebugEvents(): DebugEvent[];
174
- declare function getRecentEvents(count: number): DebugEvent[];
175
- declare function getEventsByType(type: DebugEventType): DebugEvent[];
176
- declare function getEventsBySource(source: string): DebugEvent[];
177
- declare function subscribeToDebugEvents(listener: ChangeListener$4): () => void;
178
- declare function clearDebugEvents(): void;
179
-
180
- /**
181
- * Guard Registry - Tracks guard evaluations for debugging
182
- *
183
- * @packageDocumentation
184
- */
185
- interface GuardContext {
186
- traitName?: string;
187
- type?: "transition" | "tick";
188
- transitionFrom?: string;
189
- transitionTo?: string;
190
- tickName?: string;
191
- [key: string]: unknown;
192
- }
193
- interface GuardEvaluation {
194
- id: string;
195
- traitName: string;
196
- guardName: string;
197
- expression: string;
198
- result: boolean;
199
- context: GuardContext;
200
- timestamp: number;
201
- /** Input values used in guard evaluation */
202
- inputs: Record<string, unknown>;
203
- }
204
- type ChangeListener$3 = () => void;
205
- declare function recordGuardEvaluation(evaluation: Omit<GuardEvaluation, "id" | "timestamp">): void;
206
- declare function getGuardHistory(): GuardEvaluation[];
207
- declare function getRecentGuardEvaluations(count: number): GuardEvaluation[];
208
- declare function getGuardEvaluationsForTrait(traitName: string): GuardEvaluation[];
209
- declare function subscribeToGuardChanges(listener: ChangeListener$3): () => void;
210
- declare function clearGuardHistory(): void;
211
-
212
- /**
213
- * Tick Registry - Tracks scheduled tick executions for debugging
214
- *
215
- * @packageDocumentation
216
- */
217
- interface TickExecution {
218
- id: string;
219
- traitName: string;
220
- /** Tick name (display name) */
221
- name: string;
222
- /** Tick identifier */
223
- tickName: string;
224
- interval: number;
225
- /** Last execution timestamp */
226
- lastRun: number;
227
- lastExecuted: number | null;
228
- nextExecution: number | null;
229
- /** Number of times this tick has run */
230
- runCount: number;
231
- executionCount: number;
232
- /** Average execution time in ms */
233
- executionTime: number;
234
- /** Whether the tick is currently active */
235
- active: boolean;
236
- isActive: boolean;
237
- /** Guard name if this tick has a guard */
238
- guardName?: string;
239
- /** Whether the guard passed on last evaluation */
240
- guardPassed?: boolean;
241
- }
242
- type ChangeListener$2 = () => void;
243
- declare function registerTick(tick: TickExecution): void;
244
- declare function updateTickExecution(id: string, timestamp: number): void;
245
- declare function setTickActive(id: string, isActive: boolean): void;
246
- declare function unregisterTick(id: string): void;
247
- declare function getAllTicks(): TickExecution[];
248
- declare function getTick(id: string): TickExecution | undefined;
249
- declare function subscribeToTickChanges(listener: ChangeListener$2): () => void;
250
- declare function clearTicks(): void;
251
-
252
- /**
253
- * Trait Registry - Tracks active traits and their state machines for debugging
254
- *
255
- * @packageDocumentation
256
- */
257
- interface TraitTransition {
258
- from: string;
259
- to: string;
260
- event: string;
261
- guard?: string;
262
- }
263
- interface TraitGuard {
264
- name: string;
265
- lastResult?: boolean;
266
- }
267
- interface TraitDebugInfo {
268
- id: string;
269
- name: string;
270
- currentState: string;
271
- states: string[];
272
- transitions: TraitTransition[];
273
- guards: TraitGuard[];
274
- transitionCount: number;
275
- }
276
- type ChangeListener$1 = () => void;
277
- declare function registerTrait(info: TraitDebugInfo): void;
278
- declare function updateTraitState(id: string, newState: string): void;
279
- declare function updateGuardResult(traitId: string, guardName: string, result: boolean): void;
280
- declare function unregisterTrait(id: string): void;
281
- declare function getAllTraits(): TraitDebugInfo[];
282
- declare function getTrait(id: string): TraitDebugInfo | undefined;
283
- declare function subscribeToTraitChanges(listener: ChangeListener$1): () => void;
284
- declare function clearTraits(): void;
285
-
286
- /**
287
- * Verification Registry - Tracks runtime verification checks and transition traces
288
- *
289
- * Provides:
290
- * 1. A checklist of pass/fail checks (INIT has fetch, bridge connected, etc.)
291
- * 2. A full transition timeline with effect execution results
292
- * 3. ServerBridge health snapshot
293
- * 4. window.__orbitalVerification for Playwright/automation
294
- *
295
- * @packageDocumentation
296
- */
297
- type CheckStatus = "pass" | "fail" | "pending" | "warn";
298
- interface VerificationCheck {
299
- id: string;
300
- label: string;
301
- status: CheckStatus;
302
- details?: string;
303
- /** Timestamp when status last changed */
304
- updatedAt: number;
305
- }
306
- interface EffectTrace {
307
- type: string;
308
- args: unknown[];
309
- status: "executed" | "failed" | "skipped";
310
- error?: string;
311
- durationMs?: number;
312
- }
313
- interface TransitionTrace {
314
- id: string;
315
- traitName: string;
316
- from: string;
317
- to: string;
318
- event: string;
319
- guardExpression?: string;
320
- guardResult?: boolean;
321
- effects: EffectTrace[];
322
- timestamp: number;
323
- }
324
- interface BridgeHealth {
325
- connected: boolean;
326
- eventsForwarded: number;
327
- eventsReceived: number;
328
- lastError?: string;
329
- lastHeartbeat: number;
330
- }
331
- interface VerificationSummary {
332
- totalChecks: number;
333
- passed: number;
334
- failed: number;
335
- warnings: number;
336
- pending: number;
337
- }
338
- interface VerificationSnapshot {
339
- checks: VerificationCheck[];
340
- transitions: TransitionTrace[];
341
- bridge: BridgeHealth | null;
342
- summary: VerificationSummary;
343
- }
344
- type ChangeListener = () => void;
345
- declare function registerCheck(id: string, label: string, status?: CheckStatus, details?: string): void;
346
- declare function updateCheck(id: string, status: CheckStatus, details?: string): void;
347
- declare function getAllChecks(): VerificationCheck[];
348
- declare function recordTransition(trace: Omit<TransitionTrace, "id">): void;
349
- declare function getTransitions(): TransitionTrace[];
350
- declare function getTransitionsForTrait(traitName: string): TransitionTrace[];
351
- declare function updateBridgeHealth(health: BridgeHealth): void;
352
- declare function getBridgeHealth(): BridgeHealth | null;
353
- declare function getSummary(): VerificationSummary;
354
- declare function getSnapshot(): VerificationSnapshot;
355
- declare function subscribeToVerification(listener: ChangeListener): () => void;
356
- /** Exposed on window for Playwright to query */
357
- interface OrbitalVerificationAPI {
358
- getSnapshot: () => VerificationSnapshot;
359
- getChecks: () => VerificationCheck[];
360
- getTransitions: () => TransitionTrace[];
361
- getBridge: () => BridgeHealth | null;
362
- getSummary: () => VerificationSummary;
363
- /** Wait for a specific event to be processed */
364
- waitForTransition: (event: string, timeoutMs?: number) => Promise<TransitionTrace | null>;
365
- /** Send an event into the runtime (requires eventBus binding) */
366
- sendEvent?: (event: string, payload?: Record<string, unknown>) => void;
367
- /** Get current trait state */
368
- getTraitState?: (traitName: string) => string | undefined;
369
- }
370
- declare global {
371
- interface Window {
372
- __orbitalVerification?: OrbitalVerificationAPI;
373
- }
374
- }
375
- /**
376
- * Wait for a transition matching the given event to appear.
377
- * Returns the trace or null on timeout.
378
- */
379
- declare function waitForTransition(event: string, timeoutMs?: number): Promise<TransitionTrace | null>;
380
- /**
381
- * Bind the EventBus so automation can send events.
382
- * Call this during app initialization.
383
- */
384
- declare function bindEventBus(eventBus: {
385
- emit: (type: string, payload?: Record<string, unknown>) => void;
386
- }): void;
387
- /**
388
- * Bind a trait state getter so automation can query current states.
389
- */
390
- declare function bindTraitStateGetter(getter: (traitName: string) => string | undefined): void;
391
- declare function clearVerification(): void;
392
-
393
- /**
394
- * Get Nested Value Utility
395
- *
396
- * Safely retrieves nested values from objects using dot-notation paths.
397
- * Used by display components to support relation field access like "company.name".
398
- *
399
- * @packageDocumentation
400
- */
401
- /**
402
- * Get a nested value from an object using dot-notation path.
403
- *
404
- * @param obj - The object to traverse
405
- * @param path - Dot-notation path (e.g., "company.name", "address.city")
406
- * @returns The value at the path, or undefined if not found
407
- *
408
- * @example
409
- * const data = { company: { name: "Acme Corp", address: { city: "NYC" } } };
410
- * getNestedValue(data, "company.name"); // => "Acme Corp"
411
- * getNestedValue(data, "company.address.city"); // => "NYC"
412
- * getNestedValue(data, "company.missing"); // => undefined
413
- */
414
- declare function getNestedValue(obj: Record<string, unknown> | null | undefined, path: string): unknown;
415
- /**
416
- * Format a nested field path as a human-readable label.
417
- *
418
- * @param path - Dot-notation path (e.g., "company.name")
419
- * @returns Formatted label (e.g., "Company Name")
420
- *
421
- * @example
422
- * formatFieldLabel("company.name"); // => "Company Name"
423
- * formatFieldLabel("address.zipCode"); // => "Address Zip Code"
424
- */
425
- declare function formatNestedFieldLabel(path: string): string;
426
-
427
- export { ApiError, type BridgeHealth, type CheckStatus, type DebugEvent, type DebugEventType, type EffectTrace, type EntitySnapshot, type EntityState, type GuardContext, type GuardEvaluation, type PersistentEntityInfo, type RuntimeEntity, type TickExecution, type TraitDebugInfo, type TraitGuard, type TraitTransition, type TransitionTrace, type VerificationCheck, type VerificationSnapshot, type VerificationSummary, apiClient, bindEventBus, bindTraitStateGetter, clearDebugEvents, clearEntityProvider, clearGuardHistory, clearTicks, clearTraits, clearVerification, debug, debugCollision, debugError, debugGameState, debugGroup, debugGroupEnd, debugInput, debugPhysics, debugTable, debugTime, debugTimeEnd, debugWarn, formatNestedFieldLabel, getAllChecks, getAllTicks, getAllTraits, getBridgeHealth, getDebugEvents, getEntitiesByType, getEntityById, getEntitySnapshot, getEventsBySource, getEventsByType, getGuardEvaluationsForTrait, getGuardHistory, getNestedValue, getRecentEvents, getRecentGuardEvaluations, getSnapshot, getSummary, getTick, getTrait, getTransitions, getTransitionsForTrait, initDebugShortcut, isDebugEnabled, logDebugEvent, logEffectExecuted, logError, logEventFired, logInfo, logStateChange, logWarning, onDebugToggle, recordGuardEvaluation, recordTransition, registerCheck, registerTick, registerTrait, setDebugEnabled, setEntityProvider, setTickActive, subscribeToDebugEvents, subscribeToGuardChanges, subscribeToTickChanges, subscribeToTraitChanges, subscribeToVerification, toggleDebug, unregisterTick, unregisterTrait, updateBridgeHealth, updateCheck, updateGuardResult, updateTickExecution, updateTraitState, waitForTransition };
@@ -1,22 +0,0 @@
1
- /**
2
- * Core locale loader for @almadar/ui.
3
- *
4
- * Exports message maps for en/ar/sl and a helper to merge
5
- * project-specific messages on top of core.
6
- */
7
- type SupportedLocale = 'en' | 'ar' | 'sl';
8
- interface LocaleMeta {
9
- locale: string;
10
- direction: 'ltr' | 'rtl';
11
- }
12
- /** Core messages keyed by locale */
13
- declare const coreMessages: Record<SupportedLocale, Record<string, string>>;
14
- /** Locale metadata */
15
- declare const localeMeta: Record<SupportedLocale, LocaleMeta>;
16
- /**
17
- * Merge core messages with project-specific messages.
18
- * Project keys override core keys.
19
- */
20
- declare function mergeMessages(locale: SupportedLocale, projectMessages: Record<string, string>): Record<string, string>;
21
-
22
- export { type LocaleMeta, type SupportedLocale, coreMessages, localeMeta, mergeMessages };