@almadar/ui 2.0.4 → 2.1.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/ThemeContext-D9xUORq5.d.ts +105 -0
- package/dist/{chunk-QU4JHKVC.js → chunk-BTXQJGFB.js} +24 -24
- package/dist/{chunk-JZ55M7DV.js → chunk-FZJ73RDM.js} +2 -2
- package/dist/cn-BoBXsxuX.d.ts +194 -0
- package/dist/components/index.d.ts +7080 -0
- package/dist/components/index.js +8 -8
- package/dist/components/organisms/game/three/index.d.ts +1227 -0
- package/dist/context/index.d.ts +208 -0
- package/dist/context/index.js +2 -2
- package/dist/event-bus-types-CjJduURa.d.ts +73 -0
- package/dist/hooks/index.d.ts +1091 -0
- package/dist/hooks/index.js +2 -2
- package/dist/isometric-ynNHVPZx.d.ts +111 -0
- package/dist/lib/index.d.ts +427 -0
- package/dist/locales/index.d.ts +22 -0
- package/dist/offline-executor-CHr4uAhf.d.ts +401 -0
- package/dist/providers/index.d.ts +465 -0
- package/dist/providers/index.js +4 -4
- package/dist/renderer/index.d.ts +525 -0
- package/dist/stores/index.d.ts +151 -0
- package/dist/useUISlots-D0mttBSP.d.ts +85 -0
- package/package.json +1 -1
- package/dist/{chunk-BKC4XU44.js → chunk-6WHMUKED.js} +1 -1
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
import { P as PatternConfig, R as ResolvedPattern, C as ClientEffect, b as ClientEffectExecutorConfig, N as NotifyOptions, D as DataContext, c as DataResolution, d as UISlot, S as SlotDefinition, e as SlotType } from '../offline-executor-CHr4uAhf.js';
|
|
2
|
+
export { E as EventResponse, O as OfflineExecutor, f as OfflineExecutorConfig, g as OfflineExecutorState, h as PendingSyncEffect, a as UseOfflineExecutorOptions, U as UseOfflineExecutorResult, i as createOfflineExecutor, u as useOfflineExecutor } from '../offline-executor-CHr4uAhf.js';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import React__default from 'react';
|
|
5
|
+
import { OrbitalSchema, OrbitalPage } from '@almadar/core';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Pattern Resolver
|
|
9
|
+
*
|
|
10
|
+
* Resolves pattern configurations to component information.
|
|
11
|
+
* Uses the central pattern registry and component mapping from orbital-shared/patterns/.
|
|
12
|
+
*
|
|
13
|
+
* This is the shared logic used by both Builder's PatternRenderer and
|
|
14
|
+
* the compiled shell's UISlotRenderer.
|
|
15
|
+
*
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Component mapping entry from component-mapping.json
|
|
21
|
+
*/
|
|
22
|
+
interface ComponentMappingEntry {
|
|
23
|
+
component: string;
|
|
24
|
+
importPath: string;
|
|
25
|
+
category: string;
|
|
26
|
+
deprecated?: boolean;
|
|
27
|
+
replacedBy?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Pattern definition from registry.json
|
|
31
|
+
*/
|
|
32
|
+
interface PatternDefinition {
|
|
33
|
+
type: string;
|
|
34
|
+
category: string;
|
|
35
|
+
description: string;
|
|
36
|
+
propsSchema?: Record<string, {
|
|
37
|
+
required?: boolean;
|
|
38
|
+
types?: string[];
|
|
39
|
+
description?: string;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Initialize the pattern resolver with mappings.
|
|
44
|
+
* Called at app startup with data from JSON files.
|
|
45
|
+
*/
|
|
46
|
+
declare function initializePatternResolver(config: {
|
|
47
|
+
componentMapping: Record<string, ComponentMappingEntry>;
|
|
48
|
+
patternRegistry: Record<string, PatternDefinition>;
|
|
49
|
+
}): void;
|
|
50
|
+
/**
|
|
51
|
+
* Set component mapping (alternative to full initialization).
|
|
52
|
+
*/
|
|
53
|
+
declare function setComponentMapping(mapping: Record<string, ComponentMappingEntry>): void;
|
|
54
|
+
/**
|
|
55
|
+
* Set pattern registry (alternative to full initialization).
|
|
56
|
+
*/
|
|
57
|
+
declare function setPatternRegistry(registry: Record<string, PatternDefinition>): void;
|
|
58
|
+
/**
|
|
59
|
+
* Resolve a pattern configuration to component information.
|
|
60
|
+
*
|
|
61
|
+
* @param config - Pattern configuration from render-ui effect
|
|
62
|
+
* @returns Resolved pattern with component name, import path, and validated props
|
|
63
|
+
* @throws Error if pattern type is unknown
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const resolved = resolvePattern({
|
|
68
|
+
* type: 'entity-table',
|
|
69
|
+
* entity: 'Task',
|
|
70
|
+
* columns: ['title', 'status']
|
|
71
|
+
* });
|
|
72
|
+
* // resolved.component === 'DataTable'
|
|
73
|
+
* // resolved.importPath === '@/components/organisms/DataTable'
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare function resolvePattern(config: PatternConfig): ResolvedPattern;
|
|
77
|
+
/**
|
|
78
|
+
* Check if a pattern type is known.
|
|
79
|
+
*/
|
|
80
|
+
declare function isKnownPattern(type: string): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Get all known pattern types.
|
|
83
|
+
*/
|
|
84
|
+
declare function getKnownPatterns(): string[];
|
|
85
|
+
/**
|
|
86
|
+
* Get patterns by category.
|
|
87
|
+
*/
|
|
88
|
+
declare function getPatternsByCategory(category: string): string[];
|
|
89
|
+
/**
|
|
90
|
+
* Get the component mapping for a pattern type.
|
|
91
|
+
*/
|
|
92
|
+
declare function getPatternMapping(type: string): ComponentMappingEntry | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* Get the pattern definition from the registry.
|
|
95
|
+
*/
|
|
96
|
+
declare function getPatternDefinition(type: string): PatternDefinition | undefined;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Client Effect Executor
|
|
100
|
+
*
|
|
101
|
+
* Executes client effects returned from the server.
|
|
102
|
+
* This is the core of the dual execution model - the server processes
|
|
103
|
+
* events and returns client effects, which this module executes.
|
|
104
|
+
*
|
|
105
|
+
* Used by both Builder preview and compiled shells.
|
|
106
|
+
*
|
|
107
|
+
* @packageDocumentation
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Execute an array of client effects.
|
|
112
|
+
*
|
|
113
|
+
* Effects are executed sequentially in order.
|
|
114
|
+
* Errors in one effect don't prevent subsequent effects from executing.
|
|
115
|
+
*
|
|
116
|
+
* @param effects - Array of client effects to execute
|
|
117
|
+
* @param config - Configuration providing implementations for each effect type
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* executeClientEffects(
|
|
122
|
+
* [
|
|
123
|
+
* ['render-ui', 'main', { type: 'entity-table', entity: 'Task' }],
|
|
124
|
+
* ['notify', 'Tasks loaded!', { type: 'success' }]
|
|
125
|
+
* ],
|
|
126
|
+
* {
|
|
127
|
+
* renderToSlot: (slot, pattern) => slotManager.render(slot, pattern),
|
|
128
|
+
* navigate: (path) => router.push(path),
|
|
129
|
+
* notify: (message, opts) => toast.show(message, opts),
|
|
130
|
+
* eventBus: { emit: (event, payload) => bus.emit(event, payload) }
|
|
131
|
+
* }
|
|
132
|
+
* );
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
declare function executeClientEffects(effects: ClientEffect[], config: ClientEffectExecutorConfig): void;
|
|
136
|
+
/**
|
|
137
|
+
* Parse a raw effect array into a typed ClientEffect.
|
|
138
|
+
* Handles unknown effect formats gracefully.
|
|
139
|
+
*/
|
|
140
|
+
declare function parseClientEffect(raw: unknown[]): ClientEffect | null;
|
|
141
|
+
/**
|
|
142
|
+
* Parse an array of raw effects into typed ClientEffects.
|
|
143
|
+
* Filters out invalid effects.
|
|
144
|
+
*/
|
|
145
|
+
declare function parseClientEffects(raw: unknown[] | undefined): ClientEffect[];
|
|
146
|
+
/**
|
|
147
|
+
* Filter effects by type.
|
|
148
|
+
*/
|
|
149
|
+
declare function filterEffectsByType<T extends ClientEffect[0]>(effects: ClientEffect[], type: T): Extract<ClientEffect, [T, ...unknown[]]>[];
|
|
150
|
+
/**
|
|
151
|
+
* Get all render-ui effects.
|
|
152
|
+
*/
|
|
153
|
+
declare function getRenderUIEffects(effects: ClientEffect[]): Array<['render-ui', string, PatternConfig | null]>;
|
|
154
|
+
/**
|
|
155
|
+
* Get all navigate effects.
|
|
156
|
+
*/
|
|
157
|
+
declare function getNavigateEffects(effects: ClientEffect[]): Array<['navigate', string, Record<string, unknown>?]>;
|
|
158
|
+
/**
|
|
159
|
+
* Get all notify effects.
|
|
160
|
+
*/
|
|
161
|
+
declare function getNotifyEffects(effects: ClientEffect[]): Array<['notify', string, NotifyOptions?]>;
|
|
162
|
+
/**
|
|
163
|
+
* Get all emit effects.
|
|
164
|
+
*/
|
|
165
|
+
declare function getEmitEffects(effects: ClientEffect[]): Array<['emit', string, unknown?]>;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Options for the useClientEffects hook
|
|
169
|
+
*/
|
|
170
|
+
interface UseClientEffectsOptions extends ClientEffectExecutorConfig {
|
|
171
|
+
/**
|
|
172
|
+
* Whether to execute effects. Defaults to true.
|
|
173
|
+
* Set to false to temporarily disable effect execution.
|
|
174
|
+
*/
|
|
175
|
+
enabled?: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Debug mode - logs effect execution details.
|
|
178
|
+
*/
|
|
179
|
+
debug?: boolean;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Result of useClientEffects hook
|
|
183
|
+
*/
|
|
184
|
+
interface UseClientEffectsResult {
|
|
185
|
+
/**
|
|
186
|
+
* Number of effects executed in the last batch.
|
|
187
|
+
*/
|
|
188
|
+
executedCount: number;
|
|
189
|
+
/**
|
|
190
|
+
* Whether effects are currently being executed.
|
|
191
|
+
*/
|
|
192
|
+
executing: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Manually trigger effect execution.
|
|
195
|
+
* Useful for imperative control.
|
|
196
|
+
*/
|
|
197
|
+
execute: (effects: ClientEffect[]) => void;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Execute client effects from server response.
|
|
201
|
+
*
|
|
202
|
+
* This hook automatically executes effects when they change,
|
|
203
|
+
* tracking which effects have been executed to prevent duplicates.
|
|
204
|
+
*
|
|
205
|
+
* @param effects - Array of client effects to execute (from server response)
|
|
206
|
+
* @param options - Configuration including effect implementations
|
|
207
|
+
* @returns Hook result with execution state and manual trigger
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* function useMyTrait() {
|
|
212
|
+
* const [state, setState] = useState({ pendingEffects: [] });
|
|
213
|
+
* const effectConfig = useClientEffectConfig();
|
|
214
|
+
*
|
|
215
|
+
* useClientEffects(state.pendingEffects, {
|
|
216
|
+
* ...effectConfig,
|
|
217
|
+
* onComplete: () => setState(s => ({ ...s, pendingEffects: [] }))
|
|
218
|
+
* });
|
|
219
|
+
*
|
|
220
|
+
* // ...
|
|
221
|
+
* }
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
declare function useClientEffects(effects: ClientEffect[] | undefined, options: UseClientEffectsOptions): UseClientEffectsResult;
|
|
225
|
+
declare const ClientEffectConfigContext: React.Context<ClientEffectExecutorConfig | null>;
|
|
226
|
+
/**
|
|
227
|
+
* Provider for client effect configuration.
|
|
228
|
+
*/
|
|
229
|
+
declare const ClientEffectConfigProvider: React.Provider<ClientEffectExecutorConfig | null>;
|
|
230
|
+
/**
|
|
231
|
+
* Hook to get the client effect configuration from context.
|
|
232
|
+
*
|
|
233
|
+
* @throws Error if used outside of ClientEffectConfigProvider
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```typescript
|
|
237
|
+
* function MyTraitHook() {
|
|
238
|
+
* const effectConfig = useClientEffectConfig();
|
|
239
|
+
*
|
|
240
|
+
* useClientEffects(pendingEffects, {
|
|
241
|
+
* ...effectConfig,
|
|
242
|
+
* onComplete: () => clearPendingEffects()
|
|
243
|
+
* });
|
|
244
|
+
* }
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
declare function useClientEffectConfig(): ClientEffectExecutorConfig;
|
|
248
|
+
/**
|
|
249
|
+
* Hook to get client effect configuration, returning null if not available.
|
|
250
|
+
* Use this for optional integration where effects may not be configured.
|
|
251
|
+
*/
|
|
252
|
+
declare function useClientEffectConfigOptional(): ClientEffectExecutorConfig | null;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Data Resolver
|
|
256
|
+
*
|
|
257
|
+
* Resolves entity data for pattern rendering.
|
|
258
|
+
* Supports multiple data sources with priority:
|
|
259
|
+
* 1. Server-provided data (from EventResponse.data)
|
|
260
|
+
* 2. Entity store (Builder in-memory mock data)
|
|
261
|
+
* 3. Empty array (fallback)
|
|
262
|
+
*
|
|
263
|
+
* Used by both Builder's PatternRenderer and compiled shell's UISlotRenderer.
|
|
264
|
+
*
|
|
265
|
+
* @packageDocumentation
|
|
266
|
+
*/
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Resolve entity data from available sources.
|
|
270
|
+
*
|
|
271
|
+
* Priority:
|
|
272
|
+
* 1. fetchedData (from server response) - highest priority
|
|
273
|
+
* 2. entityStore (Builder mock data)
|
|
274
|
+
* 3. Empty array (fallback)
|
|
275
|
+
*
|
|
276
|
+
* @param entityName - Name of the entity to resolve data for
|
|
277
|
+
* @param context - Data context with available sources
|
|
278
|
+
* @returns Resolved data with loading state
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* const { data, loading } = resolveEntityData('Task', {
|
|
283
|
+
* fetchedData: response.data,
|
|
284
|
+
* entityStore: mockStore
|
|
285
|
+
* });
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
declare function resolveEntityData(entityName: string, context: DataContext): DataResolution;
|
|
289
|
+
/**
|
|
290
|
+
* Resolve entity data with query filtering.
|
|
291
|
+
*
|
|
292
|
+
* Applies query singleton filters if available.
|
|
293
|
+
*
|
|
294
|
+
* @param entityName - Name of the entity
|
|
295
|
+
* @param queryRef - Optional query reference for filtering
|
|
296
|
+
* @param context - Data context
|
|
297
|
+
* @returns Filtered resolved data
|
|
298
|
+
*/
|
|
299
|
+
declare function resolveEntityDataWithQuery(entityName: string, queryRef: string | undefined, context: DataContext): DataResolution;
|
|
300
|
+
/**
|
|
301
|
+
* Get a single entity record by ID.
|
|
302
|
+
*/
|
|
303
|
+
declare function resolveEntityById(entityName: string, id: string | number, context: DataContext): unknown | null;
|
|
304
|
+
/**
|
|
305
|
+
* Get the count of entities matching criteria.
|
|
306
|
+
*/
|
|
307
|
+
declare function resolveEntityCount(entityName: string, context: DataContext, filters?: Record<string, unknown>): number;
|
|
308
|
+
/**
|
|
309
|
+
* Check if any entities exist for a given entity name.
|
|
310
|
+
*/
|
|
311
|
+
declare function hasEntities(entityName: string, context: DataContext): boolean;
|
|
312
|
+
/**
|
|
313
|
+
* Create a data context from fetched data only.
|
|
314
|
+
* Convenience function for compiled shells.
|
|
315
|
+
*/
|
|
316
|
+
declare function createFetchedDataContext(data: Record<string, unknown[]>): DataContext;
|
|
317
|
+
/**
|
|
318
|
+
* Merge multiple data contexts.
|
|
319
|
+
* Later contexts take precedence.
|
|
320
|
+
*/
|
|
321
|
+
declare function mergeDataContexts(...contexts: DataContext[]): DataContext;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Slot Definitions
|
|
325
|
+
*
|
|
326
|
+
* Defines the available UI slots and their rendering behavior.
|
|
327
|
+
* Slots are either inline (rendered in the component tree) or
|
|
328
|
+
* portal (rendered to document.body via React Portal).
|
|
329
|
+
*
|
|
330
|
+
* @packageDocumentation
|
|
331
|
+
*/
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Definitions for all available UI slots.
|
|
335
|
+
*
|
|
336
|
+
* Inline slots render within the component hierarchy.
|
|
337
|
+
* Portal slots render to document.body, breaking out of overflow containers.
|
|
338
|
+
*/
|
|
339
|
+
declare const SLOT_DEFINITIONS: Record<UISlot, SlotDefinition>;
|
|
340
|
+
/**
|
|
341
|
+
* Get the slot definition for a slot name.
|
|
342
|
+
*/
|
|
343
|
+
declare function getSlotDefinition(slot: UISlot): SlotDefinition;
|
|
344
|
+
/**
|
|
345
|
+
* Check if a slot is a portal slot.
|
|
346
|
+
*/
|
|
347
|
+
declare function isPortalSlot(slot: UISlot): boolean;
|
|
348
|
+
/**
|
|
349
|
+
* Check if a slot is an inline slot.
|
|
350
|
+
*/
|
|
351
|
+
declare function isInlineSlot(slot: UISlot): boolean;
|
|
352
|
+
/**
|
|
353
|
+
* Get all slots of a specific type.
|
|
354
|
+
*/
|
|
355
|
+
declare function getSlotsByType(type: SlotType): UISlot[];
|
|
356
|
+
/**
|
|
357
|
+
* Get all inline slots.
|
|
358
|
+
*/
|
|
359
|
+
declare function getInlineSlots(): UISlot[];
|
|
360
|
+
/**
|
|
361
|
+
* Get all portal slots.
|
|
362
|
+
*/
|
|
363
|
+
declare function getPortalSlots(): UISlot[];
|
|
364
|
+
/**
|
|
365
|
+
* All valid slot names.
|
|
366
|
+
*/
|
|
367
|
+
declare const ALL_SLOTS: UISlot[];
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* NavigationContext - Schema-Driven Navigation for Orbital Runtime
|
|
371
|
+
*
|
|
372
|
+
* Provides navigation within the orbital schema without react-router dependency.
|
|
373
|
+
* Navigation works by:
|
|
374
|
+
* 1. Matching path to a page in the schema
|
|
375
|
+
* 2. Extracting route params (e.g., /inspection/:id → { id: "123" })
|
|
376
|
+
* 3. Switching active page
|
|
377
|
+
* 4. Triggering INIT with merged payload
|
|
378
|
+
*
|
|
379
|
+
* This approach works whether OrbitalRuntime is standalone or embedded in another app.
|
|
380
|
+
*
|
|
381
|
+
* Used by both:
|
|
382
|
+
* - Builder runtime (interpreted execution)
|
|
383
|
+
* - Compiled shells (generated applications)
|
|
384
|
+
*
|
|
385
|
+
* @packageDocumentation
|
|
386
|
+
*/
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Match a concrete path against a pattern with :param placeholders.
|
|
390
|
+
* Returns null if no match, or the extracted params if match.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* matchPath('/inspection/:id', '/inspection/123') // { id: '123' }
|
|
394
|
+
* matchPath('/users/:userId/posts/:postId', '/users/42/posts/7') // { userId: '42', postId: '7' }
|
|
395
|
+
* matchPath('/about', '/about') // {}
|
|
396
|
+
* matchPath('/about', '/contact') // null
|
|
397
|
+
*/
|
|
398
|
+
declare function matchPath(pattern: string, path: string): Record<string, string> | null;
|
|
399
|
+
/**
|
|
400
|
+
* Extract route params from a path given its pattern.
|
|
401
|
+
* Wrapper around matchPath for explicit use.
|
|
402
|
+
*/
|
|
403
|
+
declare function extractRouteParams(pattern: string, path: string): Record<string, string>;
|
|
404
|
+
/**
|
|
405
|
+
* Check if a path matches a pattern.
|
|
406
|
+
*/
|
|
407
|
+
declare function pathMatches(pattern: string, path: string): boolean;
|
|
408
|
+
/**
|
|
409
|
+
* Find a page in the schema by matching its path pattern against a concrete path.
|
|
410
|
+
* Returns the page and extracted route params.
|
|
411
|
+
*/
|
|
412
|
+
declare function findPageByPath(schema: OrbitalSchema, path: string): {
|
|
413
|
+
page: OrbitalPage;
|
|
414
|
+
params: Record<string, string>;
|
|
415
|
+
orbitalName: string;
|
|
416
|
+
} | null;
|
|
417
|
+
/**
|
|
418
|
+
* Find a page by name.
|
|
419
|
+
*/
|
|
420
|
+
declare function findPageByName(schema: OrbitalSchema, pageName: string): {
|
|
421
|
+
page: OrbitalPage;
|
|
422
|
+
orbitalName: string;
|
|
423
|
+
} | null;
|
|
424
|
+
/**
|
|
425
|
+
* Get the first page in the schema (default page).
|
|
426
|
+
*/
|
|
427
|
+
declare function getDefaultPage(schema: OrbitalSchema): {
|
|
428
|
+
page: OrbitalPage;
|
|
429
|
+
orbitalName: string;
|
|
430
|
+
} | null;
|
|
431
|
+
/**
|
|
432
|
+
* Get all pages from the schema.
|
|
433
|
+
*/
|
|
434
|
+
declare function getAllPages(schema: OrbitalSchema): Array<{
|
|
435
|
+
page: OrbitalPage;
|
|
436
|
+
orbitalName: string;
|
|
437
|
+
}>;
|
|
438
|
+
interface NavigationState {
|
|
439
|
+
/** Current active page name */
|
|
440
|
+
activePage: string;
|
|
441
|
+
/** Current path (for URL sync) */
|
|
442
|
+
currentPath: string;
|
|
443
|
+
/** Payload to pass to INIT when page loads */
|
|
444
|
+
initPayload: Record<string, unknown>;
|
|
445
|
+
/** Navigation counter (increments on each navigation) */
|
|
446
|
+
navigationId: number;
|
|
447
|
+
}
|
|
448
|
+
interface NavigationContextValue {
|
|
449
|
+
/** Current navigation state */
|
|
450
|
+
state: NavigationState;
|
|
451
|
+
/** Navigate to a path with optional payload */
|
|
452
|
+
navigateTo: (path: string, payload?: Record<string, unknown>) => void;
|
|
453
|
+
/** Navigate to a page by name with optional payload */
|
|
454
|
+
navigateToPage: (pageName: string, payload?: Record<string, unknown>) => void;
|
|
455
|
+
/** The schema being navigated */
|
|
456
|
+
schema: OrbitalSchema;
|
|
457
|
+
/** Whether navigation is ready (schema loaded) */
|
|
458
|
+
isReady: boolean;
|
|
459
|
+
}
|
|
460
|
+
interface NavigationProviderProps {
|
|
461
|
+
/** The schema to navigate within */
|
|
462
|
+
schema: OrbitalSchema;
|
|
463
|
+
/** Initial page name (optional, defaults to first page) */
|
|
464
|
+
initialPage?: string;
|
|
465
|
+
/** Whether to update browser URL on navigation (default: true) */
|
|
466
|
+
updateUrl?: boolean;
|
|
467
|
+
/** Callback when navigation occurs */
|
|
468
|
+
onNavigate?: (pageName: string, path: string, payload: Record<string, unknown>) => void;
|
|
469
|
+
/** Children */
|
|
470
|
+
children: React__default.ReactNode;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* NavigationProvider - Provides schema-driven navigation context
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```tsx
|
|
477
|
+
* <NavigationProvider schema={mySchema}>
|
|
478
|
+
* <OrbitalRuntimeContent />
|
|
479
|
+
* </NavigationProvider>
|
|
480
|
+
* ```
|
|
481
|
+
*/
|
|
482
|
+
declare function NavigationProvider({ schema, initialPage, updateUrl, onNavigate, children, }: NavigationProviderProps): React__default.ReactElement;
|
|
483
|
+
/**
|
|
484
|
+
* Hook to access navigation context.
|
|
485
|
+
* Returns null if not within NavigationProvider.
|
|
486
|
+
*/
|
|
487
|
+
declare function useNavigation(): NavigationContextValue | null;
|
|
488
|
+
/**
|
|
489
|
+
* Hook to get the navigateTo function.
|
|
490
|
+
* Returns a no-op function if not within NavigationProvider.
|
|
491
|
+
*/
|
|
492
|
+
declare function useNavigateTo(): (path: string, payload?: Record<string, unknown>) => void;
|
|
493
|
+
/**
|
|
494
|
+
* Hook to get current navigation state.
|
|
495
|
+
*/
|
|
496
|
+
declare function useNavigationState(): NavigationState | null;
|
|
497
|
+
/**
|
|
498
|
+
* Hook to get the current INIT payload (for passing to trait INIT events).
|
|
499
|
+
*/
|
|
500
|
+
declare function useInitPayload(): Record<string, unknown>;
|
|
501
|
+
/**
|
|
502
|
+
* Hook to get current active page name.
|
|
503
|
+
*/
|
|
504
|
+
declare function useActivePage(): string | null;
|
|
505
|
+
/**
|
|
506
|
+
* Hook to get navigation ID (changes on each navigation, useful for triggering effects).
|
|
507
|
+
*/
|
|
508
|
+
declare function useNavigationId(): number;
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Pattern Resolver Initialization
|
|
512
|
+
*
|
|
513
|
+
* Loads pattern registry and component mapping from orbital-shared/patterns/
|
|
514
|
+
* and initializes the pattern resolver at app startup.
|
|
515
|
+
*
|
|
516
|
+
* @packageDocumentation
|
|
517
|
+
*/
|
|
518
|
+
/**
|
|
519
|
+
* Initialize the pattern resolver with shared pattern data.
|
|
520
|
+
* Must be called once at app startup before any pattern rendering.
|
|
521
|
+
* @returns The number of patterns initialized
|
|
522
|
+
*/
|
|
523
|
+
declare function initializePatterns(): number;
|
|
524
|
+
|
|
525
|
+
export { ALL_SLOTS, ClientEffect, ClientEffectConfigContext, ClientEffectConfigProvider, ClientEffectExecutorConfig, DataContext, DataResolution, type NavigationContextValue, NavigationProvider, type NavigationProviderProps, type NavigationState, NotifyOptions, PatternConfig, ResolvedPattern, SLOT_DEFINITIONS, SlotDefinition, SlotType, UISlot, type UseClientEffectsOptions, type UseClientEffectsResult, createFetchedDataContext, executeClientEffects, extractRouteParams, filterEffectsByType, findPageByName, findPageByPath, getAllPages, getDefaultPage, getEmitEffects, getInlineSlots, getKnownPatterns, getNavigateEffects, getNotifyEffects, getPatternDefinition, getPatternMapping, getPatternsByCategory, getPortalSlots, getRenderUIEffects, getSlotDefinition, getSlotsByType, hasEntities, initializePatternResolver, initializePatterns, isInlineSlot, isKnownPattern, isPortalSlot, matchPath, mergeDataContexts, parseClientEffect, parseClientEffects, pathMatches, resolveEntityById, resolveEntityCount, resolveEntityData, resolveEntityDataWithQuery, resolvePattern, setComponentMapping, setPatternRegistry, useActivePage, useClientEffectConfig, useClientEffectConfigOptional, useClientEffects, useInitPayload, useNavigateTo, useNavigation, useNavigationId, useNavigationState };
|
|
@@ -0,0 +1,151 @@
|
|
|
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 };
|