@almadar/ui 2.13.3 → 2.14.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.
Files changed (34) hide show
  1. package/dist/chunk-4N3BAPDB.js +1667 -0
  2. package/dist/{chunk-PERGHHON.js → chunk-IRIGCHP4.js} +2 -12
  3. package/dist/{chunk-UNDQO6DL.js → chunk-M7MOIE46.js} +3 -3
  4. package/dist/{chunk-Y7IHEYYE.js → chunk-QU2X55WH.js} +11 -1
  5. package/dist/{chunk-MSLMORZK.js → chunk-SKWPSQHQ.js} +13418 -2256
  6. package/dist/{chunk-4ZBSL37D.js → chunk-XL7WB2O5.js} +415 -58
  7. package/dist/components/index.css +508 -0
  8. package/dist/components/index.js +769 -11187
  9. package/dist/components/organisms/game/three/index.js +49 -1709
  10. package/dist/hooks/index.js +2 -2
  11. package/dist/lib/index.js +1 -3
  12. package/dist/providers/index.css +599 -0
  13. package/dist/providers/index.js +5 -4
  14. package/dist/runtime/index.css +599 -0
  15. package/dist/runtime/index.js +6 -6
  16. package/package.json +5 -4
  17. package/dist/ThemeContext-D9xUORq5.d.ts +0 -105
  18. package/dist/chunk-42YQ6JVR.js +0 -48
  19. package/dist/chunk-WCTZ7WZX.js +0 -311
  20. package/dist/cn-C_ATNPvi.d.ts +0 -332
  21. package/dist/components/index.d.ts +0 -9788
  22. package/dist/components/organisms/game/three/index.d.ts +0 -1233
  23. package/dist/context/index.d.ts +0 -208
  24. package/dist/event-bus-types-CjJduURa.d.ts +0 -73
  25. package/dist/hooks/index.d.ts +0 -1221
  26. package/dist/isometric-ynNHVPZx.d.ts +0 -111
  27. package/dist/lib/index.d.ts +0 -320
  28. package/dist/locales/index.d.ts +0 -22
  29. package/dist/offline-executor-CHr4uAhf.d.ts +0 -401
  30. package/dist/providers/index.d.ts +0 -465
  31. package/dist/renderer/index.d.ts +0 -525
  32. package/dist/runtime/index.d.ts +0 -280
  33. package/dist/stores/index.d.ts +0 -151
  34. package/dist/useUISlots-BBjNvQtb.d.ts +0 -85
@@ -1,280 +0,0 @@
1
- import { TraitState, EffectHandlers } from '@almadar/runtime';
2
- import { PatternConfig, ResolvedTrait, ResolvedTraitBinding, ResolvedPage, ResolvedEntity, ResolvedIR, OrbitalSchema } from '@almadar/core';
3
- export { ResolvedEntity, ResolvedIR, ResolvedPage, ResolvedTrait, ResolvedTraitBinding } from '@almadar/core';
4
- import React__default from 'react';
5
-
6
- /**
7
- * SlotsContext - React state-based UI slot management
8
- *
9
- * Replaces the UIEnvironment observable store with plain React state.
10
- * No stacking logic, no priority system, no source tracking for arbitration.
11
- *
12
- * A transition's effects produce the COMPLETE content for each slot.
13
- * The runtime collects all render-ui effects from a transition, groups by slot,
14
- * and sets each slot's patterns array in one atomic operation.
15
- *
16
- * @packageDocumentation
17
- */
18
-
19
- /** A single pattern entry in a slot */
20
- interface SlotPatternEntry {
21
- pattern: PatternConfig;
22
- props: Record<string, unknown>;
23
- }
24
- /**
25
- * Source metadata for a rendered slot.
26
- * Used by the Slot Inspector to show debug info.
27
- */
28
- interface SlotSource {
29
- trait: string;
30
- state: string;
31
- transition: string;
32
- effects?: unknown[];
33
- /** Full trait definition for inspector */
34
- traitDefinition?: ResolvedTrait;
35
- }
36
- /** Full state of a single slot */
37
- interface SlotState {
38
- patterns: SlotPatternEntry[];
39
- source?: SlotSource;
40
- }
41
- /** All slots state */
42
- type SlotsState = Record<string, SlotState>;
43
- /** Mutation functions for slots (stable references, won't trigger re-renders) */
44
- interface SlotsActions {
45
- /** Set all patterns for a slot atomically (replaces previous content) */
46
- setSlotPatterns: (slot: string, patterns: SlotPatternEntry[], source?: SlotSource) => void;
47
- /** Clear a single slot */
48
- clearSlot: (slot: string) => void;
49
- /** Clear all slots */
50
- clearAllSlots: () => void;
51
- }
52
- interface SlotsProviderProps {
53
- children: React__default.ReactNode;
54
- }
55
- /**
56
- * SlotsProvider - Manages UI slot state via React useState.
57
- *
58
- * Replaces UIEnvironmentProvider. No observable store, no stacking logic.
59
- * Slots are set atomically per transition — React diffs and re-renders.
60
- */
61
- declare function SlotsProvider({ children }: SlotsProviderProps): React__default.ReactElement;
62
- /**
63
- * Get the full slots state. Triggers re-render on ANY slot change.
64
- * Prefer useSlotContent(name) for individual slot subscriptions.
65
- */
66
- declare function useSlots(): SlotsState;
67
- /**
68
- * Get content for a specific slot. Returns null if slot is empty.
69
- */
70
- declare function useSlotContent(slotName: string): SlotState | null;
71
- /**
72
- * Get slot mutation actions. Stable reference — never triggers re-renders.
73
- */
74
- declare function useSlotsActions(): SlotsActions;
75
-
76
- /**
77
- * useTraitStateMachine Hook
78
- *
79
- * Manages trait state machines with event-driven transitions.
80
- * Subscribes to eventBus events and executes effects when transitions occur.
81
- *
82
- * CONSOLIDATED RUNTIME:
83
- * - Uses StateMachineManager from @almadar/runtime for state management
84
- * - Uses the same state machine logic as the server runtime (OrbitalServerRuntime)
85
- * - Ensures consistent behavior between client preview and server execution
86
- *
87
- * SLOT MANAGEMENT:
88
- * - Collects all render-ui effects from a transition, groups by slot
89
- * - Sets each slot's patterns array atomically via SlotsActions
90
- * - No stacking logic, no priority system — transition produces complete slot content
91
- *
92
- * @packageDocumentation
93
- */
94
-
95
- interface TraitStateMachineResult {
96
- /** Current state for each trait */
97
- traitStates: Map<string, TraitState>;
98
- /** Send an event to trigger a transition */
99
- sendEvent: (eventKey: string, payload?: Record<string, unknown>) => void;
100
- /** Get current state for a specific trait */
101
- getTraitState: (traitName: string) => TraitState | undefined;
102
- /** Check if a trait can handle an event from its current state */
103
- canHandleEvent: (traitName: string, eventKey: string) => boolean;
104
- }
105
- interface UseTraitStateMachineOptions {
106
- /** Callback invoked after each event is processed (for server forwarding) */
107
- onEventProcessed?: (eventKey: string, payload?: Record<string, unknown>) => void;
108
- /** Router navigate function for navigate effects */
109
- navigate?: (path: string, params?: Record<string, unknown>) => void;
110
- /** Notification function for notify effects */
111
- notify?: (message: string, type?: 'success' | 'error' | 'warning' | 'info') => void;
112
- }
113
- /**
114
- * useTraitStateMachine - Manages state machines for multiple traits
115
- *
116
- * Uses the shared StateMachineManager for consistent behavior with server runtime.
117
- * Collects render-ui effects per transition and sets slot content atomically.
118
- */
119
- declare function useTraitStateMachine(traitBindings: ResolvedTraitBinding[], slotsActions: SlotsActions, options?: UseTraitStateMachineOptions): TraitStateMachineResult;
120
-
121
- /**
122
- * useResolvedSchema Hook
123
- *
124
- * Resolves OrbitalSchema to IR for the OrbitalRuntime.
125
- * Uses the shared resolver to ensure consistency with the compiler.
126
- *
127
- * TRAIT-DRIVEN ARCHITECTURE:
128
- * - Pages have traits, NOT sections
129
- * - UI is produced by trait effects (render_ui)
130
- * - No backwards compatibility with legacy formats
131
- *
132
- * @packageDocumentation
133
- */
134
-
135
- interface ResolvedSchemaResult {
136
- /** The resolved page (or undefined if not found) */
137
- page: ResolvedPage | undefined;
138
- /** Trait bindings for this page */
139
- traits: ResolvedTraitBinding[];
140
- /** Entities used by this page */
141
- entities: Map<string, ResolvedEntity>;
142
- /** All entities from schema */
143
- allEntities: Map<string, ResolvedEntity>;
144
- /** All resolved traits */
145
- allTraits: Map<string, ResolvedTrait>;
146
- /** Loading state */
147
- loading: boolean;
148
- /** Error message if resolution failed */
149
- error: string | null;
150
- /** Full IR (for debugging) */
151
- ir: ResolvedIR | null;
152
- }
153
- /**
154
- * Hook to resolve an OrbitalSchema to IR.
155
- *
156
- * @param schema - The OrbitalSchema to resolve
157
- * @param pageName - Optional page name (defaults to first page or initial page)
158
- * @returns Resolved schema data including page, traits, and entities
159
- */
160
- declare function useResolvedSchema(schema: OrbitalSchema | null | undefined, pageName?: string): ResolvedSchemaResult;
161
- /**
162
- * Clear the schema resolution cache
163
- */
164
- declare function clearSchemaCache(): void;
165
-
166
- /**
167
- * EntitySchemaContext
168
- *
169
- * Minimal context providing entity schema definitions (field metadata).
170
- * This is NOT a data store - data comes from FetchedDataContext via server.
171
- *
172
- * Replaces EntityStore's schema functionality without the mock data generation.
173
- *
174
- * @packageDocumentation
175
- */
176
-
177
- interface EntitySchemaContextValue {
178
- /** Entity definitions (schema metadata only) */
179
- entities: Map<string, ResolvedEntity>;
180
- }
181
- interface EntitySchemaProviderProps {
182
- /** Entity definitions from resolved schema */
183
- entities: ResolvedEntity[];
184
- /** Children */
185
- children: React__default.ReactNode;
186
- }
187
- /**
188
- * Provides entity schema definitions to the component tree.
189
- *
190
- * This is a lightweight provider that only holds schema metadata (field definitions).
191
- * Actual entity data comes from FetchedDataContext via server responses.
192
- */
193
- declare function EntitySchemaProvider({ entities, children, }: EntitySchemaProviderProps): React__default.ReactElement;
194
- /**
195
- * Access entity schema definitions.
196
- * Use this for field metadata (form building, filter enrichment).
197
- * For actual data, use useFetchedDataContext.
198
- */
199
- declare function useEntitySchema(): EntitySchemaContextValue;
200
- /**
201
- * Get a specific entity's schema definition.
202
- */
203
- declare function useEntityDefinition(entityName: string): ResolvedEntity | undefined;
204
-
205
- /**
206
- * TraitProvider Component
207
- *
208
- * Provides trait state machines to child components via React context.
209
- *
210
- * @packageDocumentation
211
- */
212
-
213
- interface TraitInstance {
214
- /** Trait name */
215
- name: string;
216
- /** Current state */
217
- currentState: string;
218
- /** Available events (can be triggered) */
219
- availableEvents: string[];
220
- /** Dispatch an event to the state machine */
221
- dispatch: (eventKey: string, payload?: Record<string, unknown>) => void;
222
- /** Check if an event can be dispatched */
223
- canDispatch: (eventKey: string) => boolean;
224
- /** Get the full trait definition */
225
- trait: ResolvedTrait;
226
- }
227
- interface TraitContextValue {
228
- /** All trait instances on this page */
229
- traits: Map<string, TraitInstance>;
230
- /** Get a trait instance by name */
231
- getTrait: (name: string) => TraitInstance | undefined;
232
- /** Dispatch an event to a specific trait */
233
- dispatchToTrait: (traitName: string, eventKey: string, payload?: Record<string, unknown>) => void;
234
- /** Check if an event can be dispatched to a trait */
235
- canDispatch: (traitName: string, eventKey: string) => boolean;
236
- }
237
- declare const TraitContext: React__default.Context<TraitContextValue | null>;
238
- interface TraitProviderProps {
239
- /** Trait bindings for this page */
240
- traits: ResolvedTraitBinding[];
241
- /** Entity map for context */
242
- entities: Map<string, ResolvedEntity>;
243
- /** Children to render */
244
- children: React__default.ReactNode;
245
- }
246
- declare function TraitProvider({ traits: traitBindings, children, }: TraitProviderProps): React__default.ReactElement;
247
- /**
248
- * Access the trait context from within the TraitProvider.
249
- */
250
- declare function useTraitContext(): TraitContextValue;
251
- /**
252
- * Access a specific trait instance.
253
- */
254
- declare function useTrait(traitName: string): TraitInstance | undefined;
255
-
256
- /**
257
- * Client Effect Handlers Factory
258
- *
259
- * Creates the standard effect handler set for client-side trait execution.
260
- *
261
- * @packageDocumentation
262
- */
263
-
264
- interface ClientEventBus {
265
- emit: (type: string, payload?: Record<string, unknown>) => void;
266
- }
267
- interface SlotSetter {
268
- addPattern: (slot: string, pattern: unknown, props?: Record<string, unknown>) => void;
269
- clearSlot: (slot: string) => void;
270
- }
271
- interface CreateClientEffectHandlersOptions {
272
- eventBus: ClientEventBus;
273
- slotSetter: SlotSetter;
274
- navigate?: (path: string, params?: Record<string, unknown>) => void;
275
- notify?: (message: string, type: 'success' | 'error' | 'warning' | 'info') => void;
276
- enrichPattern?: (pattern: unknown) => unknown;
277
- }
278
- declare function createClientEffectHandlers(options: CreateClientEffectHandlersOptions): EffectHandlers;
279
-
280
- export { type ClientEventBus, type CreateClientEffectHandlersOptions, type EntitySchemaContextValue, EntitySchemaProvider, type EntitySchemaProviderProps, type ResolvedSchemaResult, type SlotPatternEntry, type SlotSetter, type SlotSource, type SlotState, type SlotsActions, SlotsProvider, type SlotsProviderProps, type SlotsState, TraitContext, type TraitContextValue, type TraitInstance, TraitProvider, type TraitProviderProps, type TraitStateMachineResult, type UseTraitStateMachineOptions, clearSchemaCache, createClientEffectHandlers, useEntityDefinition, useEntitySchema, useResolvedSchema, useSlotContent, useSlots, useSlotsActions, useTrait, useTraitContext, useTraitStateMachine };
@@ -1,151 +0,0 @@
1
- /**
2
- * Entity Filtering Utilities
3
- *
4
- * Provides filter types and utility functions for filtering entity records.
5
- * Used by EntityStore and can be imported by runtime preview.
6
- */
7
- /** Filter value for a single field (entity filtering) */
8
- interface EntityFilterValue {
9
- /** The field key (may include suffix like _from, _to for date ranges) */
10
- field: string;
11
- /** The actual record field to compare against (defaults to field if not specified) */
12
- targetField?: string;
13
- value: unknown;
14
- /** Comparison operator for filtering
15
- * - eq: exact match (default)
16
- * - contains: substring match for strings
17
- * - in: value is in array
18
- * - date_eq: same date (ignoring time)
19
- * - date_gte: on or after date
20
- * - date_lte: on or before date
21
- */
22
- operator?: FilterOperator;
23
- }
24
- /** Operator type for filter */
25
- type FilterOperator = 'eq' | 'contains' | 'in' | 'date_eq' | 'date_gte' | 'date_lte' | 'search';
26
- /** Filter state for an entity - Map of field key to filter value */
27
- type EntityFilters = Map<string, EntityFilterValue>;
28
- /** Record type that can be filtered */
29
- interface FilterableRecord {
30
- id: string;
31
- [key: string]: unknown;
32
- }
33
- /**
34
- * Extract date part from ISO string or Date object.
35
- * Returns format: "YYYY-MM-DD"
36
- */
37
- declare function getDateString(value: unknown): string | null;
38
- /**
39
- * Apply a single filter to check if a record matches.
40
- * Returns true if the record passes the filter.
41
- */
42
- declare function matchesFilter(record: FilterableRecord, filter: EntityFilterValue): boolean;
43
- /**
44
- * Apply all filters to a list of records.
45
- * Returns only records that match ALL filters.
46
- */
47
- declare function applyFilters<T extends FilterableRecord>(records: T[], entityFilters: EntityFilters): T[];
48
- /**
49
- * Create a filter value with proper defaults.
50
- */
51
- declare function createFilter(field: string, value: unknown, operator?: FilterOperator, targetField?: string): EntityFilterValue;
52
-
53
- /**
54
- * Entity Store
55
- *
56
- * Simple module-level store for runtime entities.
57
- * No providers needed - hooks import and use directly.
58
- *
59
- * NOTE: Mutations create new Map instances to trigger React rerenders
60
- * when using useSyncExternalStore.
61
- */
62
-
63
- interface Entity {
64
- id: string;
65
- type: string;
66
- [key: string]: unknown;
67
- }
68
- type Listener = () => void;
69
- /**
70
- * Subscribe to store changes
71
- */
72
- declare function subscribe(listener: Listener): () => void;
73
- /**
74
- * Get all entities
75
- */
76
- declare function getEntities(): Map<string, Entity>;
77
- /**
78
- * Get entity by ID
79
- */
80
- declare function getEntity(id: string): Entity | undefined;
81
- /**
82
- * Get entities by type
83
- */
84
- declare function getByType(type: string | string[]): Entity[];
85
- /**
86
- * Get all entities as array
87
- */
88
- declare function getAllEntities(): Entity[];
89
- /**
90
- * Get singleton entity by type (first of that type)
91
- */
92
- declare function getSingleton(type: string): Entity | undefined;
93
- /**
94
- * Spawn a new entity
95
- */
96
- declare function spawnEntity(config: {
97
- type: string;
98
- id?: string;
99
- [key: string]: unknown;
100
- }): string;
101
- /**
102
- * Update an entity
103
- */
104
- declare function updateEntity(id: string, updates: Partial<Entity>): void;
105
- /**
106
- * Update singleton entity by type
107
- */
108
- declare function updateSingleton(type: string, updates: Partial<Entity>): void;
109
- /**
110
- * Remove an entity
111
- */
112
- declare function removeEntity(id: string): void;
113
- /**
114
- * Clear all entities
115
- */
116
- declare function clearEntities(): void;
117
- /**
118
- * Set a filter for an entity type
119
- * @param entityType - The entity type to filter (e.g., "Player", "Enemy")
120
- * @param field - The filter key (e.g., 'status' or 'date_from')
121
- * @param value - The filter value
122
- * @param operator - The comparison operator
123
- * @param targetField - The actual record field to compare (defaults to field)
124
- */
125
- declare function setFilter(entityType: string, field: string, value: unknown, operator?: FilterOperator, targetField?: string): void;
126
- /**
127
- * Clear a specific filter
128
- */
129
- declare function clearFilter(entityType: string, field: string): void;
130
- /**
131
- * Clear all filters for an entity type
132
- */
133
- declare function clearAllFilters(entityType: string): void;
134
- /**
135
- * Get active filters for an entity type
136
- */
137
- declare function getFilters(entityType: string): EntityFilters;
138
- /**
139
- * Get entities by type with optional filtering
140
- */
141
- declare function getByTypeFiltered(type: string | string[]): Entity[];
142
- /**
143
- * Get snapshot for React useSyncExternalStore
144
- */
145
- declare function getSnapshot(): Map<string, Entity>;
146
- /**
147
- * Get filter snapshot for React useSyncExternalStore
148
- */
149
- declare function getFilterSnapshot(): Map<string, EntityFilters>;
150
-
151
- export { type Entity, type EntityFilterValue, type EntityFilters, type FilterOperator, type FilterableRecord, applyFilters, clearAllFilters, clearEntities, clearFilter, createFilter, getAllEntities, getByType, getByTypeFiltered, getDateString, getEntities, getEntity, getFilterSnapshot, getFilters, getSingleton, getSnapshot, matchesFilter, removeEntity, setFilter, spawnEntity, subscribe, updateEntity, updateSingleton };
@@ -1,85 +0,0 @@
1
- /**
2
- * Valid UI slot names
3
- */
4
- type UISlot = 'main' | 'sidebar' | 'modal' | 'drawer' | 'overlay' | 'center' | 'toast' | 'hud-top' | 'hud-bottom' | 'hud-left' | 'hud-right' | 'floating';
5
- /**
6
- * Animation types for slot transitions
7
- */
8
- type SlotAnimation = 'fade' | 'slide' | 'scale' | 'none';
9
- /**
10
- * Content rendered in a slot
11
- */
12
- interface SlotContent {
13
- /** Unique ID for this content */
14
- id: string;
15
- /** Pattern/component type to render */
16
- pattern: string;
17
- /** Props to pass to the pattern component */
18
- props: Record<string, unknown>;
19
- /** Priority for conflict resolution (higher wins) */
20
- priority: number;
21
- /** Animation for showing/hiding */
22
- animation?: SlotAnimation;
23
- /** Auto-dismiss timestamp (for toasts) */
24
- autoDismissAt?: number;
25
- /** Callback when dismissed */
26
- onDismiss?: () => void;
27
- /** Source trait that rendered this content */
28
- sourceTrait?: string;
29
- }
30
- /**
31
- * Configuration for render_ui effect
32
- */
33
- interface RenderUIConfig {
34
- /** Target slot */
35
- target: UISlot;
36
- /** Pattern/component to render */
37
- pattern: string;
38
- /** Props for the pattern */
39
- props?: Record<string, unknown>;
40
- /** Priority (default: 0) */
41
- priority?: number;
42
- /** Animation type */
43
- animation?: SlotAnimation;
44
- /** Auto-dismiss after ms (for toasts) */
45
- autoDismissMs?: number;
46
- /** Callback on dismiss */
47
- onDismiss?: () => void;
48
- /** Source trait name */
49
- sourceTrait?: string;
50
- }
51
- /**
52
- * Callback for slot changes
53
- */
54
- type SlotChangeCallback = (slot: UISlot, content: SlotContent | null) => void;
55
- /**
56
- * UI Slot Manager interface
57
- */
58
- interface UISlotManager {
59
- /** Current content for each slot */
60
- slots: Record<UISlot, SlotContent | null>;
61
- /** Render content to a slot */
62
- render: (config: RenderUIConfig) => string;
63
- /** Clear a specific slot */
64
- clear: (slot: UISlot) => void;
65
- /** Clear content by ID */
66
- clearById: (id: string) => void;
67
- /** Clear all slots */
68
- clearAll: () => void;
69
- /** Subscribe to slot changes */
70
- subscribe: (callback: SlotChangeCallback) => () => void;
71
- /** Check if a slot has content */
72
- hasContent: (slot: UISlot) => boolean;
73
- /** Get content for a slot */
74
- getContent: (slot: UISlot) => SlotContent | null;
75
- }
76
- declare const DEFAULT_SLOTS: Record<UISlot, SlotContent | null>;
77
- /**
78
- * Create a UI Slot Manager instance.
79
- *
80
- * This is the internal hook that creates the manager.
81
- * Use `useUISlots()` from context in components.
82
- */
83
- declare function useUISlotManager(): UISlotManager;
84
-
85
- export { DEFAULT_SLOTS as D, type RenderUIConfig as R, type SlotContent as S, type UISlotManager as U, type UISlot as a, type SlotAnimation as b, type SlotChangeCallback as c, useUISlotManager as u };