@almadar/ui 2.0.0 → 2.0.1
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/components/atoms/Avatar.d.ts +58 -0
- package/dist/components/atoms/Badge.d.ts +8 -0
- package/dist/components/atoms/Box.d.ts +57 -0
- package/dist/components/atoms/Button.d.ts +24 -0
- package/dist/components/atoms/Card.d.ts +18 -0
- package/dist/components/atoms/Center.d.ts +33 -0
- package/dist/components/atoms/Checkbox.d.ts +5 -0
- package/dist/components/atoms/ConditionalWrapper.d.ts +68 -0
- package/dist/components/atoms/Divider.d.ts +29 -0
- package/dist/components/atoms/Icon.d.ts +38 -0
- package/dist/components/atoms/Input.d.ts +26 -0
- package/dist/components/atoms/Label.d.ts +5 -0
- package/dist/components/atoms/LawReferenceTooltip.d.ts +48 -0
- package/dist/components/atoms/Overlay.d.ts +16 -0
- package/dist/components/atoms/ProgressBar.d.ts +63 -0
- package/dist/components/atoms/Radio.d.ts +26 -0
- package/dist/components/atoms/Select.d.ts +12 -0
- package/dist/components/atoms/Spacer.d.ts +25 -0
- package/dist/components/atoms/Spinner.d.ts +6 -0
- package/dist/components/atoms/Stack.d.ts +64 -0
- package/dist/components/atoms/Switch.d.ts +12 -0
- package/dist/components/atoms/TextHighlight.d.ts +53 -0
- package/dist/components/atoms/Textarea.d.ts +5 -0
- package/dist/components/atoms/ThemeSelector.d.ts +21 -0
- package/dist/components/atoms/ThemeToggle.d.ts +33 -0
- package/dist/components/atoms/Typography.d.ts +57 -0
- package/dist/components/atoms/game/ControlButton.d.ts +31 -0
- package/dist/components/atoms/game/HealthBar.d.ts +18 -0
- package/dist/components/atoms/game/ScoreDisplay.d.ts +21 -0
- package/dist/components/atoms/game/Sprite.d.ts +63 -0
- package/dist/components/atoms/game/StateIndicator.d.ts +31 -0
- package/dist/components/atoms/game/index.d.ts +12 -0
- package/dist/components/atoms/index.d.ts +27 -0
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.js +5 -5
- package/dist/components/molecules/Accordion.d.ts +67 -0
- package/dist/components/molecules/Alert.d.ts +24 -0
- package/dist/components/molecules/Breadcrumb.d.ts +55 -0
- package/dist/components/molecules/ButtonGroup.d.ts +67 -0
- package/dist/components/molecules/Card.d.ts +44 -0
- package/dist/components/molecules/Container.d.ts +30 -0
- package/dist/components/molecules/Drawer.d.ts +46 -0
- package/dist/components/molecules/EmptyState.d.ts +25 -0
- package/dist/components/molecules/ErrorBoundary.d.ts +55 -0
- package/dist/components/molecules/ErrorState.d.ts +13 -0
- package/dist/components/molecules/FilterGroup.d.ts +54 -0
- package/dist/components/molecules/Flex.d.ts +43 -0
- package/dist/components/molecules/FloatingActionButton.d.ts +69 -0
- package/dist/components/molecules/FormField.d.ts +16 -0
- package/dist/components/molecules/FormSectionHeader.d.ts +30 -0
- package/dist/components/molecules/Grid.d.ts +54 -0
- package/dist/components/molecules/InputGroup.d.ts +24 -0
- package/dist/components/molecules/LoadingState.d.ts +7 -0
- package/dist/components/molecules/Menu.d.ts +40 -0
- package/dist/components/molecules/Modal.d.ts +26 -0
- package/dist/components/molecules/Pagination.d.ts +66 -0
- package/dist/components/molecules/Popover.d.ts +39 -0
- package/dist/components/molecules/QuizBlock.d.ts +20 -0
- package/dist/components/molecules/RelationSelect.d.ts +48 -0
- package/dist/components/molecules/RepeatableFormSection.d.ts +58 -0
- package/dist/components/molecules/ScaledDiagram.d.ts +20 -0
- package/dist/components/molecules/SearchInput.d.ts +60 -0
- package/dist/components/molecules/SidePanel.d.ts +47 -0
- package/dist/components/molecules/SimpleGrid.d.ts +27 -0
- package/dist/components/molecules/Skeleton.d.ts +35 -0
- package/dist/components/molecules/Tabs.d.ts +45 -0
- package/dist/components/molecules/Toast.d.ts +35 -0
- package/dist/components/molecules/Tooltip.d.ts +25 -0
- package/dist/components/molecules/ViolationAlert.d.ts +49 -0
- package/dist/components/molecules/WizardNavigation.d.ts +51 -0
- package/dist/components/molecules/WizardProgress.d.ts +42 -0
- package/dist/components/molecules/game/StatBadge.d.ts +27 -0
- package/dist/components/molecules/index.d.ts +38 -0
- package/dist/components/molecules/markdown/CodeBlock.d.ts +25 -0
- package/dist/components/molecules/markdown/MarkdownContent.d.ts +26 -0
- package/dist/components/organisms/CardGrid.d.ts +72 -0
- package/dist/components/organisms/Chart.d.ts +59 -0
- package/dist/components/organisms/CodeViewer.d.ts +67 -0
- package/dist/components/organisms/ComponentPatterns.d.ts +441 -0
- package/dist/components/organisms/ConfirmDialog.d.ts +50 -0
- package/dist/components/organisms/ContentRenderer.d.ts +23 -0
- package/dist/components/organisms/CustomPattern.d.ts +104 -0
- package/dist/components/organisms/DataTable.d.ts +63 -0
- package/dist/components/organisms/DetailPanel.d.ts +71 -0
- package/dist/components/organisms/DocumentViewer.d.ts +60 -0
- package/dist/components/organisms/DrawerSlot.d.ts +39 -0
- package/dist/components/organisms/Form.d.ts +203 -0
- package/dist/components/organisms/FormSection.d.ts +59 -0
- package/dist/components/organisms/GraphCanvas.d.ts +69 -0
- package/dist/components/organisms/Header.d.ts +110 -0
- package/dist/components/organisms/JazariStateMachine.d.ts +60 -0
- package/dist/components/organisms/LayoutPatterns.d.ts +181 -0
- package/dist/components/organisms/List.d.ts +76 -0
- package/dist/components/organisms/MasterDetail.d.ts +43 -0
- package/dist/components/organisms/MediaGallery.d.ts +66 -0
- package/dist/components/organisms/Meter.d.ts +58 -0
- package/dist/components/organisms/ModalSlot.d.ts +35 -0
- package/dist/components/organisms/Navigation.d.ts +68 -0
- package/dist/components/organisms/OrbitalVisualization.d.ts +48 -0
- package/dist/components/organisms/PageHeader.d.ts +59 -0
- package/dist/components/organisms/Section.d.ts +44 -0
- package/dist/components/organisms/Sidebar.d.ts +65 -0
- package/dist/components/organisms/SignaturePad.d.ts +44 -0
- package/dist/components/organisms/Split.d.ts +42 -0
- package/dist/components/organisms/StatCard.d.ts +66 -0
- package/dist/components/organisms/StateMachineView.d.ts +36 -0
- package/dist/components/organisms/Table.d.ts +99 -0
- package/dist/components/organisms/Timeline.d.ts +58 -0
- package/dist/components/organisms/ToastSlot.d.ts +38 -0
- package/dist/components/organisms/UISlotRenderer.d.ts +112 -0
- package/dist/components/organisms/WizardContainer.d.ts +160 -0
- package/dist/components/organisms/book/BookChapterView.d.ts +17 -0
- package/dist/components/organisms/book/BookCoverPage.d.ts +19 -0
- package/dist/components/organisms/book/BookNavBar.d.ts +18 -0
- package/dist/components/organisms/book/BookTableOfContents.d.ts +18 -0
- package/dist/components/organisms/book/BookViewer.d.ts +28 -0
- package/dist/components/organisms/book/index.d.ts +7 -0
- package/dist/components/organisms/book/types.d.ts +77 -0
- package/dist/components/organisms/game/BattleBoard.d.ts +167 -0
- package/dist/components/organisms/game/CanvasEffect.d.ts +68 -0
- package/dist/components/organisms/game/CastleBoard.d.ts +85 -0
- package/dist/components/organisms/game/DialogueBox.d.ts +73 -0
- package/dist/components/organisms/game/GameAudioProvider.d.ts +47 -0
- package/dist/components/organisms/game/GameAudioToggle.d.ts +28 -0
- package/dist/components/organisms/game/GameHud.d.ts +40 -0
- package/dist/components/organisms/game/GameMenu.d.ts +43 -0
- package/dist/components/organisms/game/GameOverScreen.d.ts +56 -0
- package/dist/components/organisms/game/InventoryPanel.d.ts +67 -0
- package/dist/components/organisms/game/IsometricCanvas.d.ts +123 -0
- package/dist/components/organisms/game/TraitSlot.d.ts +86 -0
- package/dist/components/organisms/game/TraitStateViewer.d.ts +53 -0
- package/dist/components/organisms/game/UncontrolledBattleBoard.d.ts +26 -0
- package/dist/components/organisms/game/WorldMapBoard.d.ts +147 -0
- package/dist/components/organisms/game/editor/editorUtils.d.ts +109 -0
- package/dist/components/organisms/game/editor/index.d.ts +9 -0
- package/dist/components/organisms/game/hooks/useBattleState.d.ts +35 -0
- package/dist/components/organisms/game/hooks/useCamera.d.ts +41 -0
- package/dist/components/organisms/game/hooks/useGameAudio.d.ts +47 -0
- package/dist/components/organisms/game/hooks/useImageCache.d.ts +16 -0
- package/dist/components/organisms/game/hooks/usePhysics2D.d.ts +45 -0
- package/dist/components/organisms/game/hooks/useSpriteAnimations.d.ts +43 -0
- package/dist/components/organisms/game/index.d.ts +36 -0
- package/dist/components/organisms/game/managers/PhysicsManager.d.ts +103 -0
- package/dist/components/organisms/game/types/effects.d.ts +253 -0
- package/dist/components/organisms/game/types/isometric.d.ts +109 -0
- package/dist/components/organisms/game/types/spriteAnimation.d.ts +73 -0
- package/dist/components/organisms/game/utils/canvasEffects.d.ts +50 -0
- package/dist/components/organisms/game/utils/combatPresets.d.ts +15 -0
- package/dist/components/organisms/game/utils/isometric.d.ts +61 -0
- package/dist/components/organisms/game/utils/spriteAnimation.d.ts +57 -0
- package/dist/components/organisms/game/utils/spriteSheetConstants.d.ts +16 -0
- package/dist/components/organisms/index.d.ts +37 -0
- package/dist/components/organisms/layout/DashboardGrid.d.ts +34 -0
- package/dist/components/organisms/layout/MasterDetail.d.ts +32 -0
- package/dist/components/organisms/layout/SplitPane.d.ts +34 -0
- package/dist/components/organisms/layout/TabbedContainer.d.ts +42 -0
- package/dist/components/organisms/layout/index.d.ts +9 -0
- package/dist/components/organisms/types.d.ts +65 -0
- package/dist/components/templates/AuthLayout.d.ts +14 -0
- package/dist/components/templates/BattleTemplate.d.ts +25 -0
- package/dist/components/templates/CastleTemplate.d.ts +23 -0
- package/dist/components/templates/CounterTemplate.d.ts +44 -0
- package/dist/components/templates/DashboardLayout.d.ts +32 -0
- package/dist/components/templates/GameShell.d.ts +33 -0
- package/dist/components/templates/GameTemplate.d.ts +36 -0
- package/dist/components/templates/GenericAppTemplate.d.ts +30 -0
- package/dist/components/templates/WorldMapTemplate.d.ts +29 -0
- package/dist/components/templates/index.d.ts +10 -0
- package/dist/components/templates/types.d.ts +17 -0
- package/dist/context/DesignThemeContext.d.ts +21 -0
- package/dist/context/ThemeContext.d.ts +104 -0
- package/dist/context/UISlotContext.d.ts +75 -0
- package/dist/context/UserContext.d.ts +111 -0
- package/dist/context/index.d.ts +8 -0
- package/dist/hooks/event-bus-types.d.ts +71 -0
- package/dist/hooks/index.d.ts +25 -0
- package/dist/hooks/useAgentChat.d.ts +104 -0
- package/dist/hooks/useAuthContext.d.ts +25 -0
- package/dist/hooks/useCompile.d.ts +22 -0
- package/dist/hooks/useDeepAgentGeneration.d.ts +46 -0
- package/dist/hooks/useEntities.d.ts +52 -0
- package/dist/hooks/useEntityData.d.ts +155 -0
- package/dist/hooks/useEntityMutations.d.ts +80 -0
- package/dist/hooks/useEventBus.d.ts +96 -0
- package/dist/hooks/useExtensions.d.ts +32 -0
- package/dist/hooks/useFileEditor.d.ts +32 -0
- package/dist/hooks/useFileSystem.d.ts +40 -0
- package/dist/hooks/useGitHub.d.ts +58 -0
- package/dist/hooks/useOrbitalHistory.d.ts +39 -0
- package/dist/hooks/useOrbitalMutations.d.ts +95 -0
- package/dist/hooks/usePreview.d.ts +57 -0
- package/dist/hooks/useQuerySingleton.d.ts +78 -0
- package/dist/hooks/useResolvedEntity.d.ts +32 -0
- package/dist/hooks/useTranslate.d.ts +35 -0
- package/dist/hooks/useUIEvents.d.ts +35 -0
- package/dist/hooks/useUISlots.d.ts +84 -0
- package/dist/hooks/useValidation.d.ts +46 -0
- package/dist/lib/api-client.d.ts +42 -0
- package/dist/lib/cn.d.ts +6 -0
- package/dist/lib/debug.d.ts +43 -0
- package/dist/lib/debugRegistry.d.ts +29 -0
- package/dist/lib/debugUtils.d.ts +27 -0
- package/dist/lib/entityDebug.d.ts +38 -0
- package/dist/lib/getNestedValue.d.ts +33 -0
- package/dist/lib/guardRegistry.d.ts +32 -0
- package/dist/lib/index.d.ts +18 -0
- package/dist/lib/jazari/svg-paths.d.ts +61 -0
- package/dist/lib/parseContentSegments.d.ts +41 -0
- package/dist/lib/tickRegistry.d.ts +40 -0
- package/dist/lib/traitRegistry.d.ts +34 -0
- package/dist/lib/verificationRegistry.d.ts +107 -0
- package/dist/lib/visualizer/index.d.ts +143 -0
- package/dist/locales/index.d.ts +20 -0
- package/dist/providers/EventBusProvider.d.ts +60 -0
- package/dist/providers/FetchedDataProvider.d.ts +105 -0
- package/dist/providers/OfflineModeProvider.d.ts +79 -0
- package/dist/providers/OrbitalProvider.d.ts +101 -0
- package/dist/providers/SelectionProvider.d.ts +81 -0
- package/dist/providers/VerificationProvider.d.ts +63 -0
- package/dist/providers/index.d.ts +17 -0
- package/dist/providers/index.js +3 -3
- package/dist/renderer/client-effect-executor.d.ts +68 -0
- package/dist/renderer/data-resolver.d.ts +68 -0
- package/dist/renderer/index.d.ts +28 -0
- package/dist/renderer/index.js +1 -1
- package/dist/renderer/init.d.ts +14 -0
- package/dist/renderer/navigation.d.ts +142 -0
- package/dist/renderer/offline-executor.d.ts +238 -0
- package/dist/renderer/pattern-resolver.d.ts +91 -0
- package/dist/renderer/slot-definitions.d.ts +45 -0
- package/dist/renderer/types.d.ts +160 -0
- package/dist/renderer/useClientEffects.d.ts +88 -0
- package/dist/stores/entityStore.d.ts +99 -0
- package/dist/stores/filtering.d.ts +51 -0
- package/dist/stores/index.d.ts +7 -0
- package/package.json +4 -3
- package/dist/{chunk-YNP2OBK4.js → chunk-RIZ76XRF.js} +1 -1
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Offline Effect Executor
|
|
3
|
+
*
|
|
4
|
+
* Enables client-only mode for applications that need to work without
|
|
5
|
+
* server connectivity. Provides:
|
|
6
|
+
* - Mock data providers for simulating server responses
|
|
7
|
+
* - Local effect execution without server round-trip
|
|
8
|
+
* - Sync queue for effects that need server persistence when back online
|
|
9
|
+
*
|
|
10
|
+
* Used by both Builder preview (offline mode) and compiled shells (PWA mode).
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
*/
|
|
14
|
+
import type { ClientEffect, ClientEffectExecutorConfig, EventResponse } from './types';
|
|
15
|
+
/**
|
|
16
|
+
* Effect that needs to be synced to server when online
|
|
17
|
+
*/
|
|
18
|
+
export interface PendingSyncEffect {
|
|
19
|
+
/** Unique ID for this effect */
|
|
20
|
+
id: string;
|
|
21
|
+
/** Timestamp when effect was queued */
|
|
22
|
+
timestamp: number;
|
|
23
|
+
/** Effect type (persist, call-service, etc.) */
|
|
24
|
+
type: string;
|
|
25
|
+
/** Effect payload */
|
|
26
|
+
payload: unknown;
|
|
27
|
+
/** Number of retry attempts */
|
|
28
|
+
retries: number;
|
|
29
|
+
/** Maximum retries before giving up */
|
|
30
|
+
maxRetries: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Configuration for offline executor
|
|
34
|
+
*/
|
|
35
|
+
export interface OfflineExecutorConfig extends ClientEffectExecutorConfig {
|
|
36
|
+
/**
|
|
37
|
+
* Mock data provider for simulating fetch responses.
|
|
38
|
+
* Returns data for a given entity name.
|
|
39
|
+
*/
|
|
40
|
+
mockDataProvider?: (entityName: string) => unknown[];
|
|
41
|
+
/**
|
|
42
|
+
* Whether to queue server effects for sync when online.
|
|
43
|
+
* Default: true
|
|
44
|
+
*/
|
|
45
|
+
enableSyncQueue?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Maximum number of effects to queue before dropping oldest.
|
|
48
|
+
* Default: 100
|
|
49
|
+
*/
|
|
50
|
+
maxQueueSize?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Callback when an effect is added to sync queue.
|
|
53
|
+
*/
|
|
54
|
+
onEffectQueued?: (effect: PendingSyncEffect) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Callback when sync queue changes.
|
|
57
|
+
*/
|
|
58
|
+
onQueueChange?: (queue: PendingSyncEffect[]) => void;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Offline executor state
|
|
62
|
+
*/
|
|
63
|
+
export interface OfflineExecutorState {
|
|
64
|
+
/** Whether we're in offline mode */
|
|
65
|
+
isOffline: boolean;
|
|
66
|
+
/** Pending effects waiting for sync */
|
|
67
|
+
syncQueue: PendingSyncEffect[];
|
|
68
|
+
/** Number of effects processed locally */
|
|
69
|
+
localEffectsProcessed: number;
|
|
70
|
+
/** Number of effects synced to server */
|
|
71
|
+
effectsSynced: number;
|
|
72
|
+
/** Last sync attempt timestamp */
|
|
73
|
+
lastSyncAttempt?: number;
|
|
74
|
+
/** Last successful sync timestamp */
|
|
75
|
+
lastSuccessfulSync?: number;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* OfflineExecutor - Handles effects in offline/client-only mode.
|
|
79
|
+
*
|
|
80
|
+
* Features:
|
|
81
|
+
* - Executes client effects immediately (render-ui, navigate, notify, emit)
|
|
82
|
+
* - Queues server effects (persist, fetch, call-service) for later sync
|
|
83
|
+
* - Provides mock data for fetch effects when offline
|
|
84
|
+
* - Syncs queued effects when connection is restored
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const executor = new OfflineExecutor({
|
|
89
|
+
* renderToSlot: (slot, pattern) => slotManager.render(slot, pattern),
|
|
90
|
+
* navigate: (path) => router.push(path),
|
|
91
|
+
* notify: (message, opts) => toast.show(message, opts),
|
|
92
|
+
* eventBus: { emit: (event, payload) => bus.emit(event, payload) },
|
|
93
|
+
* mockDataProvider: (entityName) => mockStore.getAll(entityName),
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* // Process effects locally
|
|
97
|
+
* const response = executor.processEventOffline('LOAD', { id: '123' });
|
|
98
|
+
*
|
|
99
|
+
* // When back online
|
|
100
|
+
* await executor.syncPendingEffects(serverUrl);
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare class OfflineExecutor {
|
|
104
|
+
private config;
|
|
105
|
+
private state;
|
|
106
|
+
private storage;
|
|
107
|
+
constructor(config: OfflineExecutorConfig);
|
|
108
|
+
/**
|
|
109
|
+
* Check if we're online (browser API)
|
|
110
|
+
*/
|
|
111
|
+
private checkOnline;
|
|
112
|
+
/**
|
|
113
|
+
* Handle going online
|
|
114
|
+
*/
|
|
115
|
+
private handleOnline;
|
|
116
|
+
/**
|
|
117
|
+
* Handle going offline
|
|
118
|
+
*/
|
|
119
|
+
private handleOffline;
|
|
120
|
+
/**
|
|
121
|
+
* Load sync queue from localStorage
|
|
122
|
+
*/
|
|
123
|
+
private loadSyncQueue;
|
|
124
|
+
/**
|
|
125
|
+
* Save sync queue to localStorage
|
|
126
|
+
*/
|
|
127
|
+
private saveSyncQueue;
|
|
128
|
+
/**
|
|
129
|
+
* Add an effect to the sync queue
|
|
130
|
+
*/
|
|
131
|
+
private queueForSync;
|
|
132
|
+
/**
|
|
133
|
+
* Execute client effects immediately.
|
|
134
|
+
*/
|
|
135
|
+
executeClientEffects(effects: ClientEffect[]): void;
|
|
136
|
+
/**
|
|
137
|
+
* Process an event in offline mode.
|
|
138
|
+
*
|
|
139
|
+
* Returns a simulated EventResponse with mock data.
|
|
140
|
+
* Client effects are executed immediately.
|
|
141
|
+
* Server effects are queued for sync.
|
|
142
|
+
*/
|
|
143
|
+
processEventOffline(event: string, payload?: Record<string, unknown>, effects?: Array<unknown[]>): EventResponse;
|
|
144
|
+
/**
|
|
145
|
+
* Sync pending effects to server.
|
|
146
|
+
*
|
|
147
|
+
* @param serverUrl - Base URL for the orbital server
|
|
148
|
+
* @param authToken - Optional auth token for requests
|
|
149
|
+
* @returns Number of successfully synced effects
|
|
150
|
+
*/
|
|
151
|
+
syncPendingEffects(serverUrl: string, authToken?: string): Promise<number>;
|
|
152
|
+
/**
|
|
153
|
+
* Get current executor state
|
|
154
|
+
*/
|
|
155
|
+
getState(): OfflineExecutorState;
|
|
156
|
+
/**
|
|
157
|
+
* Get number of pending effects
|
|
158
|
+
*/
|
|
159
|
+
getPendingCount(): number;
|
|
160
|
+
/**
|
|
161
|
+
* Clear the sync queue
|
|
162
|
+
*/
|
|
163
|
+
clearQueue(): void;
|
|
164
|
+
/**
|
|
165
|
+
* Dispose the executor and clean up listeners
|
|
166
|
+
*/
|
|
167
|
+
dispose(): void;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Create an offline executor with sensible defaults.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```typescript
|
|
174
|
+
* const executor = createOfflineExecutor({
|
|
175
|
+
* renderToSlot: slotManager.render,
|
|
176
|
+
* navigate: router.push,
|
|
177
|
+
* notify: toast.show,
|
|
178
|
+
* eventBus: { emit: bus.emit },
|
|
179
|
+
* mockDataProvider: (entity) => store.getAll(entity),
|
|
180
|
+
* });
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
export declare function createOfflineExecutor(config: OfflineExecutorConfig): OfflineExecutor;
|
|
184
|
+
/**
|
|
185
|
+
* Options for useOfflineExecutor hook
|
|
186
|
+
*/
|
|
187
|
+
export interface UseOfflineExecutorOptions extends OfflineExecutorConfig {
|
|
188
|
+
/** Server URL for syncing */
|
|
189
|
+
serverUrl?: string;
|
|
190
|
+
/** Auth token for server requests */
|
|
191
|
+
authToken?: string;
|
|
192
|
+
/** Auto-sync when coming back online */
|
|
193
|
+
autoSync?: boolean;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Result of useOfflineExecutor hook
|
|
197
|
+
*/
|
|
198
|
+
export interface UseOfflineExecutorResult {
|
|
199
|
+
/** Current executor state */
|
|
200
|
+
state: OfflineExecutorState;
|
|
201
|
+
/** Whether we're offline */
|
|
202
|
+
isOffline: boolean;
|
|
203
|
+
/** Number of pending effects */
|
|
204
|
+
pendingCount: number;
|
|
205
|
+
/** Execute client effects */
|
|
206
|
+
executeClientEffects: (effects: ClientEffect[]) => void;
|
|
207
|
+
/** Process event offline */
|
|
208
|
+
processEventOffline: (event: string, payload?: Record<string, unknown>, effects?: Array<unknown[]>) => EventResponse;
|
|
209
|
+
/** Manually trigger sync */
|
|
210
|
+
sync: () => Promise<number>;
|
|
211
|
+
/** Clear the queue */
|
|
212
|
+
clearQueue: () => void;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* React hook for offline effect execution.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```tsx
|
|
219
|
+
* function MyComponent() {
|
|
220
|
+
* const { isOffline, pendingCount, processEventOffline, sync } = useOfflineExecutor({
|
|
221
|
+
* renderToSlot: slotManager.render,
|
|
222
|
+
* navigate: router.push,
|
|
223
|
+
* notify: toast.show,
|
|
224
|
+
* eventBus: { emit: bus.emit },
|
|
225
|
+
* serverUrl: '/api/orbitals',
|
|
226
|
+
* autoSync: true,
|
|
227
|
+
* });
|
|
228
|
+
*
|
|
229
|
+
* return (
|
|
230
|
+
* <div>
|
|
231
|
+
* {isOffline && <Banner>Offline - {pendingCount} changes pending</Banner>}
|
|
232
|
+
* <button onClick={() => processEventOffline('SAVE', data)}>Save</button>
|
|
233
|
+
* </div>
|
|
234
|
+
* );
|
|
235
|
+
* }
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
export declare function useOfflineExecutor(options: UseOfflineExecutorOptions): UseOfflineExecutorResult;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pattern Resolver
|
|
3
|
+
*
|
|
4
|
+
* Resolves pattern configurations to component information.
|
|
5
|
+
* Uses the central pattern registry and component mapping from orbital-shared/patterns/.
|
|
6
|
+
*
|
|
7
|
+
* This is the shared logic used by both Builder's PatternRenderer and
|
|
8
|
+
* the compiled shell's UISlotRenderer.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
import type { PatternConfig, ResolvedPattern } from './types';
|
|
13
|
+
/**
|
|
14
|
+
* Component mapping entry from component-mapping.json
|
|
15
|
+
*/
|
|
16
|
+
interface ComponentMappingEntry {
|
|
17
|
+
component: string;
|
|
18
|
+
importPath: string;
|
|
19
|
+
category: string;
|
|
20
|
+
deprecated?: boolean;
|
|
21
|
+
replacedBy?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Pattern definition from registry.json
|
|
25
|
+
*/
|
|
26
|
+
interface PatternDefinition {
|
|
27
|
+
type: string;
|
|
28
|
+
category: string;
|
|
29
|
+
description: string;
|
|
30
|
+
propsSchema?: Record<string, {
|
|
31
|
+
required?: boolean;
|
|
32
|
+
types?: string[];
|
|
33
|
+
description?: string;
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Initialize the pattern resolver with mappings.
|
|
38
|
+
* Called at app startup with data from JSON files.
|
|
39
|
+
*/
|
|
40
|
+
export declare function initializePatternResolver(config: {
|
|
41
|
+
componentMapping: Record<string, ComponentMappingEntry>;
|
|
42
|
+
patternRegistry: Record<string, PatternDefinition>;
|
|
43
|
+
}): void;
|
|
44
|
+
/**
|
|
45
|
+
* Set component mapping (alternative to full initialization).
|
|
46
|
+
*/
|
|
47
|
+
export declare function setComponentMapping(mapping: Record<string, ComponentMappingEntry>): void;
|
|
48
|
+
/**
|
|
49
|
+
* Set pattern registry (alternative to full initialization).
|
|
50
|
+
*/
|
|
51
|
+
export declare function setPatternRegistry(registry: Record<string, PatternDefinition>): void;
|
|
52
|
+
/**
|
|
53
|
+
* Resolve a pattern configuration to component information.
|
|
54
|
+
*
|
|
55
|
+
* @param config - Pattern configuration from render-ui effect
|
|
56
|
+
* @returns Resolved pattern with component name, import path, and validated props
|
|
57
|
+
* @throws Error if pattern type is unknown
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const resolved = resolvePattern({
|
|
62
|
+
* type: 'entity-table',
|
|
63
|
+
* entity: 'Task',
|
|
64
|
+
* columns: ['title', 'status']
|
|
65
|
+
* });
|
|
66
|
+
* // resolved.component === 'DataTable'
|
|
67
|
+
* // resolved.importPath === '@/components/organisms/DataTable'
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function resolvePattern(config: PatternConfig): ResolvedPattern;
|
|
71
|
+
/**
|
|
72
|
+
* Check if a pattern type is known.
|
|
73
|
+
*/
|
|
74
|
+
export declare function isKnownPattern(type: string): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Get all known pattern types.
|
|
77
|
+
*/
|
|
78
|
+
export declare function getKnownPatterns(): string[];
|
|
79
|
+
/**
|
|
80
|
+
* Get patterns by category.
|
|
81
|
+
*/
|
|
82
|
+
export declare function getPatternsByCategory(category: string): string[];
|
|
83
|
+
/**
|
|
84
|
+
* Get the component mapping for a pattern type.
|
|
85
|
+
*/
|
|
86
|
+
export declare function getPatternMapping(type: string): ComponentMappingEntry | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Get the pattern definition from the registry.
|
|
89
|
+
*/
|
|
90
|
+
export declare function getPatternDefinition(type: string): PatternDefinition | undefined;
|
|
91
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slot Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the available UI slots and their rendering behavior.
|
|
5
|
+
* Slots are either inline (rendered in the component tree) or
|
|
6
|
+
* portal (rendered to document.body via React Portal).
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
import type { UISlot, SlotDefinition, SlotType } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* Definitions for all available UI slots.
|
|
13
|
+
*
|
|
14
|
+
* Inline slots render within the component hierarchy.
|
|
15
|
+
* Portal slots render to document.body, breaking out of overflow containers.
|
|
16
|
+
*/
|
|
17
|
+
export declare const SLOT_DEFINITIONS: Record<UISlot, SlotDefinition>;
|
|
18
|
+
/**
|
|
19
|
+
* Get the slot definition for a slot name.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getSlotDefinition(slot: UISlot): SlotDefinition;
|
|
22
|
+
/**
|
|
23
|
+
* Check if a slot is a portal slot.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isPortalSlot(slot: UISlot): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a slot is an inline slot.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isInlineSlot(slot: UISlot): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Get all slots of a specific type.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getSlotsByType(type: SlotType): UISlot[];
|
|
34
|
+
/**
|
|
35
|
+
* Get all inline slots.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getInlineSlots(): UISlot[];
|
|
38
|
+
/**
|
|
39
|
+
* Get all portal slots.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getPortalSlots(): UISlot[];
|
|
42
|
+
/**
|
|
43
|
+
* All valid slot names.
|
|
44
|
+
*/
|
|
45
|
+
export declare const ALL_SLOTS: UISlot[];
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Renderer Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions used by both Builder and compiled shells for
|
|
5
|
+
* the dual execution model. These types define the contract between
|
|
6
|
+
* server and client for effect execution.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* A client effect is a tuple where the first element is the effect type
|
|
12
|
+
* and the remaining elements are the arguments.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ['render-ui', 'main', { type: 'entity-table', ... }]
|
|
16
|
+
* ['navigate', '/tasks/123']
|
|
17
|
+
* ['notify', 'Task created!', { type: 'success' }]
|
|
18
|
+
* ['emit', 'TASK_CREATED', { id: '123' }]
|
|
19
|
+
*/
|
|
20
|
+
export type ClientEffect = ['render-ui', string, PatternConfig | null] | ['navigate', string, Record<string, unknown>?] | ['notify', string, NotifyOptions?] | ['emit', string, unknown?];
|
|
21
|
+
/**
|
|
22
|
+
* Options for notify effect
|
|
23
|
+
*/
|
|
24
|
+
export interface NotifyOptions {
|
|
25
|
+
type?: 'success' | 'error' | 'info' | 'warning';
|
|
26
|
+
duration?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Configuration for a pattern to render in a slot.
|
|
30
|
+
* This is what render-ui effects carry as their payload.
|
|
31
|
+
*/
|
|
32
|
+
export interface PatternConfig {
|
|
33
|
+
/** Pattern type from registry (e.g., 'entity-table', 'form-section') */
|
|
34
|
+
type: string;
|
|
35
|
+
/** Entity name for data binding */
|
|
36
|
+
entity?: string;
|
|
37
|
+
/** Additional props for the pattern component */
|
|
38
|
+
[key: string]: unknown;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolved pattern with component information from component-mapping.json
|
|
42
|
+
*/
|
|
43
|
+
export interface ResolvedPattern {
|
|
44
|
+
/** Component name (e.g., 'DataTable') */
|
|
45
|
+
component: string;
|
|
46
|
+
/** Import path for the component */
|
|
47
|
+
importPath: string;
|
|
48
|
+
/** Pattern category (e.g., 'display', 'form') */
|
|
49
|
+
category: string;
|
|
50
|
+
/** Validated and normalized props */
|
|
51
|
+
validatedProps: Record<string, unknown>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Response from server after processing an event.
|
|
55
|
+
* This is the unified response format for both Builder and compiled shells.
|
|
56
|
+
*/
|
|
57
|
+
export interface EventResponse {
|
|
58
|
+
/** Whether the event was processed successfully */
|
|
59
|
+
success: boolean;
|
|
60
|
+
/** New state after transition (if transition occurred) */
|
|
61
|
+
newState?: string;
|
|
62
|
+
/** Data fetched by server effects (e.g., { Task: [...] }) */
|
|
63
|
+
data?: Record<string, unknown[]>;
|
|
64
|
+
/** Client effects to execute (render-ui, navigate, notify, emit) */
|
|
65
|
+
clientEffects?: ClientEffect[];
|
|
66
|
+
/** Results of individual effect executions (for debugging) */
|
|
67
|
+
effectResults?: Array<{
|
|
68
|
+
effect: string;
|
|
69
|
+
success: boolean;
|
|
70
|
+
data?: unknown;
|
|
71
|
+
error?: string;
|
|
72
|
+
}>;
|
|
73
|
+
/** Error message if success is false */
|
|
74
|
+
error?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Configuration for the client effect executor.
|
|
78
|
+
* Provides implementations for each effect type.
|
|
79
|
+
*/
|
|
80
|
+
export interface ClientEffectExecutorConfig {
|
|
81
|
+
/**
|
|
82
|
+
* Render a pattern to a slot.
|
|
83
|
+
* Called for 'render-ui' effects.
|
|
84
|
+
*/
|
|
85
|
+
renderToSlot: (slot: string, pattern: PatternConfig | null) => void;
|
|
86
|
+
/**
|
|
87
|
+
* Navigate to a route.
|
|
88
|
+
* Called for 'navigate' effects.
|
|
89
|
+
*/
|
|
90
|
+
navigate: (path: string, params?: Record<string, unknown>) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Show a notification.
|
|
93
|
+
* Called for 'notify' effects.
|
|
94
|
+
*/
|
|
95
|
+
notify: (message: string, options?: NotifyOptions) => void;
|
|
96
|
+
/**
|
|
97
|
+
* Emit an event to the event bus.
|
|
98
|
+
* Called for 'emit' effects.
|
|
99
|
+
*/
|
|
100
|
+
eventBus: {
|
|
101
|
+
emit: (event: string, payload?: unknown) => void;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Optional: Data from server response for render-ui.
|
|
105
|
+
* Components can use this to access fetched entity data.
|
|
106
|
+
*/
|
|
107
|
+
data?: Record<string, unknown[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Optional: Callback when all effects have been executed.
|
|
110
|
+
*/
|
|
111
|
+
onComplete?: () => void;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Valid UI slot names
|
|
115
|
+
*/
|
|
116
|
+
export type UISlot = 'main' | 'sidebar' | 'modal' | 'drawer' | 'overlay' | 'center' | 'toast' | 'hud-top' | 'hud-bottom' | 'floating';
|
|
117
|
+
/**
|
|
118
|
+
* Slot type classification
|
|
119
|
+
*/
|
|
120
|
+
export type SlotType = 'inline' | 'portal';
|
|
121
|
+
/**
|
|
122
|
+
* Definition of a slot including its rendering behavior
|
|
123
|
+
*/
|
|
124
|
+
export interface SlotDefinition {
|
|
125
|
+
/** Slot name */
|
|
126
|
+
name: UISlot;
|
|
127
|
+
/** Whether to render inline or via portal */
|
|
128
|
+
type: SlotType;
|
|
129
|
+
/** For portal slots: where to render (default: document.body) */
|
|
130
|
+
portalTarget?: string;
|
|
131
|
+
/** Z-index for portal slots */
|
|
132
|
+
zIndex?: number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Context for resolving entity data.
|
|
136
|
+
* Supports multiple data sources with priority.
|
|
137
|
+
*/
|
|
138
|
+
export interface DataContext {
|
|
139
|
+
/** Server-provided data (highest priority) */
|
|
140
|
+
fetchedData?: Record<string, unknown[]>;
|
|
141
|
+
/** In-memory mock data (for Builder preview) */
|
|
142
|
+
entityStore?: {
|
|
143
|
+
getRecords: (entityName: string) => unknown[];
|
|
144
|
+
};
|
|
145
|
+
/** Query singleton for filtering */
|
|
146
|
+
querySingleton?: {
|
|
147
|
+
getFilters: (queryRef: string) => Record<string, unknown>;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Result of data resolution
|
|
152
|
+
*/
|
|
153
|
+
export interface DataResolution {
|
|
154
|
+
/** Resolved data array */
|
|
155
|
+
data: unknown[];
|
|
156
|
+
/** Whether data is still loading */
|
|
157
|
+
loading: boolean;
|
|
158
|
+
/** Error if resolution failed */
|
|
159
|
+
error?: Error;
|
|
160
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { ClientEffect, ClientEffectExecutorConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Options for the useClientEffects hook
|
|
4
|
+
*/
|
|
5
|
+
export interface UseClientEffectsOptions extends ClientEffectExecutorConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Whether to execute effects. Defaults to true.
|
|
8
|
+
* Set to false to temporarily disable effect execution.
|
|
9
|
+
*/
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Debug mode - logs effect execution details.
|
|
13
|
+
*/
|
|
14
|
+
debug?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Result of useClientEffects hook
|
|
18
|
+
*/
|
|
19
|
+
export interface UseClientEffectsResult {
|
|
20
|
+
/**
|
|
21
|
+
* Number of effects executed in the last batch.
|
|
22
|
+
*/
|
|
23
|
+
executedCount: number;
|
|
24
|
+
/**
|
|
25
|
+
* Whether effects are currently being executed.
|
|
26
|
+
*/
|
|
27
|
+
executing: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Manually trigger effect execution.
|
|
30
|
+
* Useful for imperative control.
|
|
31
|
+
*/
|
|
32
|
+
execute: (effects: ClientEffect[]) => void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Execute client effects from server response.
|
|
36
|
+
*
|
|
37
|
+
* This hook automatically executes effects when they change,
|
|
38
|
+
* tracking which effects have been executed to prevent duplicates.
|
|
39
|
+
*
|
|
40
|
+
* @param effects - Array of client effects to execute (from server response)
|
|
41
|
+
* @param options - Configuration including effect implementations
|
|
42
|
+
* @returns Hook result with execution state and manual trigger
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* function useMyTrait() {
|
|
47
|
+
* const [state, setState] = useState({ pendingEffects: [] });
|
|
48
|
+
* const effectConfig = useClientEffectConfig();
|
|
49
|
+
*
|
|
50
|
+
* useClientEffects(state.pendingEffects, {
|
|
51
|
+
* ...effectConfig,
|
|
52
|
+
* onComplete: () => setState(s => ({ ...s, pendingEffects: [] }))
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* // ...
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function useClientEffects(effects: ClientEffect[] | undefined, options: UseClientEffectsOptions): UseClientEffectsResult;
|
|
60
|
+
declare const ClientEffectConfigContext: import("react").Context<ClientEffectExecutorConfig | null>;
|
|
61
|
+
/**
|
|
62
|
+
* Provider for client effect configuration.
|
|
63
|
+
*/
|
|
64
|
+
export declare const ClientEffectConfigProvider: import("react").Provider<ClientEffectExecutorConfig | null>;
|
|
65
|
+
/**
|
|
66
|
+
* Hook to get the client effect configuration from context.
|
|
67
|
+
*
|
|
68
|
+
* @throws Error if used outside of ClientEffectConfigProvider
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* function MyTraitHook() {
|
|
73
|
+
* const effectConfig = useClientEffectConfig();
|
|
74
|
+
*
|
|
75
|
+
* useClientEffects(pendingEffects, {
|
|
76
|
+
* ...effectConfig,
|
|
77
|
+
* onComplete: () => clearPendingEffects()
|
|
78
|
+
* });
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare function useClientEffectConfig(): ClientEffectExecutorConfig;
|
|
83
|
+
/**
|
|
84
|
+
* Hook to get client effect configuration, returning null if not available.
|
|
85
|
+
* Use this for optional integration where effects may not be configured.
|
|
86
|
+
*/
|
|
87
|
+
export declare function useClientEffectConfigOptional(): ClientEffectExecutorConfig | null;
|
|
88
|
+
export { ClientEffectConfigContext };
|