@almadar/ui 2.7.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
- export { ENTITY_EVENTS, useAgentChat, useAuthContext, useCompile, useConnectGitHub, useCreateEntity, useDeepAgentGeneration, useDeleteEntity, useDisconnectGitHub, useEntities, useEntitiesByType, useEntity as useEntityById, useEntityMutations, useExtensions, useFileEditor, useFileSystem, useGitHubBranches, useGitHubRepo, useGitHubRepos, useGitHubStatus, useInput, useOrbitalHistory, useOrbitalMutations, usePhysics, usePinchZoom, usePlayer, usePreview, useResolvedEntity, useSelectedEntity, useSendOrbitalEvent, useSingletonEntity, useUIEvents, useUpdateEntity, useValidation } from '../chunk-2QM732NQ.js';
1
+ export { ENTITY_EVENTS, useAgentChat, useAuthContext, useCompile, useConnectGitHub, useCreateEntity, useDeepAgentGeneration, useDeleteEntity, useDisconnectGitHub, useEntities, useEntitiesByType, useEntity as useEntityById, useEntityMutations, useExtensions, useFileEditor, useFileSystem, useGitHubBranches, useGitHubRepo, useGitHubRepos, useGitHubStatus, useInput, useOrbitalHistory, useOrbitalMutations, usePhysics, usePinchZoom, usePlayer, usePreview, useResolvedEntity, useSelectedEntity, useSendOrbitalEvent, useSingletonEntity, useUIEvents, useUpdateEntity, useValidation } from '../chunk-GTIAVPI5.js';
2
+ export { clearEntities, getAllEntities, getByType, getEntity, getSingleton, removeEntity, spawnEntity, updateEntity, updateSingleton } from '../chunk-N7MVUW4R.js';
2
3
  import '../chunk-3HJHHULT.js';
3
4
  export { EntityDataProvider, I18nProvider, createTranslate, entityDataKeys, parseQueryBinding, useDragReorder, useEntity, useEntityDataAdapter, useEntityDetail, useEntityList, useEntityListSuspense, useEntitySuspense, useInfiniteScroll, useLongPress, usePullToRefresh, useQuerySingleton, useSwipeGesture, useTranslate } from '../chunk-WGJIL4YR.js';
4
5
  export { useEmitEvent, useEventBus, useEventListener } from '../chunk-YXZM3WCF.js';
5
6
  export { DEFAULT_SLOTS, useUISlotManager } from '../chunk-3JGAROCW.js';
6
7
  import '../chunk-TSETXL2E.js';
7
- export { clearEntities, getAllEntities, getByType, getEntity, getSingleton, removeEntity, spawnEntity, updateEntity, updateSingleton } from '../chunk-N7MVUW4R.js';
8
8
  import '../chunk-PKBMQBKP.js';
package/dist/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { DEFAULT_CONFIG, extractOutputsFromTransitions, extractStateMachine, formatGuard, getEffectSummary, parseContentSegments, parseMarkdownWithCodeBlocks, renderStateMachineToDomData, renderStateMachineToSvg } from '../chunk-N6DJVKZ6.js';
2
2
  export { ApiError, apiClient } from '../chunk-3HJHHULT.js';
3
- export { bindCanvasCapture, bindEventBus, bindTraitStateGetter, clearVerification, cn, debug, debugCollision, debugError, debugGameState, debugGroup, debugGroupEnd, debugInput, debugPhysics, debugTable, debugTime, debugTimeEnd, debugWarn, formatNestedFieldLabel, getAllChecks, getBridgeHealth, getNestedValue, getSnapshot, getSummary, getTransitions, getTransitionsForTrait, isDebugEnabled, recordTransition, registerCheck, subscribeToVerification, updateAssetStatus, updateBridgeHealth, updateCheck, waitForTransition } from '../chunk-RPYMP7ZC.js';
3
+ export { bindCanvasCapture, bindEventBus, bindTraitStateGetter, clearVerification, cn, debug, debugCollision, debugError, debugGameState, debugGroup, debugGroupEnd, debugInput, debugPhysics, debugTable, debugTime, debugTimeEnd, debugWarn, formatNestedFieldLabel, getAllChecks, getBridgeHealth, getNestedValue, getSnapshot, getSummary, getTransitions, getTransitionsForTrait, isDebugEnabled, recordTransition, registerCheck, subscribeToVerification, updateAssetStatus, updateBridgeHealth, updateCheck, waitForTransition } from '../chunk-A5J5CNCU.js';
4
4
  import '../chunk-PKBMQBKP.js';
5
5
 
6
6
  // lib/debugUtils.ts
@@ -1,380 +1,10 @@
1
- import { SuspenseConfigProvider } from '../chunk-VJP2HCLY.js';
2
- import { ThemeProvider } from '../chunk-DKQN5FVU.js';
3
- import { SelectionProvider, EntityDataProvider } from '../chunk-WGJIL4YR.js';
1
+ export { FetchedDataContext, FetchedDataProvider, OfflineModeProvider, OrbitalProvider, VerificationProvider, useFetchedData, useFetchedDataContext, useFetchedEntity, useOfflineMode, useOptionalOfflineMode } from '../chunk-UVMBFEMO.js';
2
+ import '../chunk-NES4SBB7.js';
3
+ import '../chunk-DKQN5FVU.js';
4
4
  export { SelectionContext, SelectionProvider, useSelection, useSelectionOptional } from '../chunk-WGJIL4YR.js';
5
- import { useEventBus, EventBusProvider } from '../chunk-YXZM3WCF.js';
6
5
  export { EventBusContext, EventBusProvider } from '../chunk-YXZM3WCF.js';
7
6
  import '../chunk-3JGAROCW.js';
8
- import { recordTransition, registerCheck, bindEventBus, bindTraitStateGetter } from '../chunk-RPYMP7ZC.js';
7
+ import '../chunk-A5J5CNCU.js';
9
8
  import '../chunk-TSETXL2E.js';
10
- import { useOfflineExecutor } from '../chunk-K2D5D3WK.js';
9
+ import '../chunk-K2D5D3WK.js';
11
10
  import '../chunk-PKBMQBKP.js';
12
- import { createContext, useState, useCallback, useMemo, useContext, useRef, useEffect } from 'react';
13
- import { jsx, Fragment } from 'react/jsx-runtime';
14
-
15
- var FetchedDataContext = createContext(null);
16
- function FetchedDataProvider({
17
- initialData,
18
- children
19
- }) {
20
- const [state, setState] = useState(() => ({
21
- data: initialData || {},
22
- fetchedAt: {},
23
- loading: false,
24
- error: null
25
- }));
26
- const getData = useCallback(
27
- (entityName) => {
28
- return state.data[entityName] || [];
29
- },
30
- [state.data]
31
- );
32
- const getById = useCallback(
33
- (entityName, id) => {
34
- const records = state.data[entityName];
35
- return records?.find((r) => r.id === id);
36
- },
37
- [state.data]
38
- );
39
- const hasData = useCallback(
40
- (entityName) => {
41
- return entityName in state.data && state.data[entityName].length > 0;
42
- },
43
- [state.data]
44
- );
45
- const getFetchedAt = useCallback(
46
- (entityName) => {
47
- return state.fetchedAt[entityName];
48
- },
49
- [state.fetchedAt]
50
- );
51
- const setData = useCallback((data) => {
52
- const now = Date.now();
53
- setState((prev) => ({
54
- ...prev,
55
- data: {
56
- ...prev.data,
57
- ...data
58
- },
59
- fetchedAt: {
60
- ...prev.fetchedAt,
61
- ...Object.keys(data).reduce(
62
- (acc, key) => ({ ...acc, [key]: now }),
63
- {}
64
- )
65
- },
66
- loading: false,
67
- error: null
68
- }));
69
- }, []);
70
- const clearData = useCallback(() => {
71
- setState((prev) => ({
72
- ...prev,
73
- data: {},
74
- fetchedAt: {}
75
- }));
76
- }, []);
77
- const clearEntity = useCallback((entityName) => {
78
- setState((prev) => {
79
- const newData = { ...prev.data };
80
- const newFetchedAt = { ...prev.fetchedAt };
81
- delete newData[entityName];
82
- delete newFetchedAt[entityName];
83
- return {
84
- ...prev,
85
- data: newData,
86
- fetchedAt: newFetchedAt
87
- };
88
- });
89
- }, []);
90
- const setLoading = useCallback((loading) => {
91
- setState((prev) => ({ ...prev, loading }));
92
- }, []);
93
- const setError = useCallback((error) => {
94
- setState((prev) => ({ ...prev, error, loading: false }));
95
- }, []);
96
- const contextValue = useMemo(
97
- () => ({
98
- getData,
99
- getById,
100
- hasData,
101
- getFetchedAt,
102
- setData,
103
- clearData,
104
- clearEntity,
105
- loading: state.loading,
106
- setLoading,
107
- error: state.error,
108
- setError
109
- }),
110
- [
111
- getData,
112
- getById,
113
- hasData,
114
- getFetchedAt,
115
- setData,
116
- clearData,
117
- clearEntity,
118
- state.loading,
119
- setLoading,
120
- state.error,
121
- setError
122
- ]
123
- );
124
- return /* @__PURE__ */ jsx(FetchedDataContext.Provider, { value: contextValue, children });
125
- }
126
- function useFetchedDataContext() {
127
- return useContext(FetchedDataContext);
128
- }
129
- function useFetchedData() {
130
- const context = useContext(FetchedDataContext);
131
- if (!context) {
132
- return {
133
- getData: () => [],
134
- getById: () => void 0,
135
- hasData: () => false,
136
- getFetchedAt: () => void 0,
137
- setData: () => {
138
- },
139
- clearData: () => {
140
- },
141
- clearEntity: () => {
142
- },
143
- loading: false,
144
- setLoading: () => {
145
- },
146
- error: null,
147
- setError: () => {
148
- }
149
- };
150
- }
151
- return context;
152
- }
153
- function useFetchedEntity(entityName) {
154
- const context = useFetchedData();
155
- return {
156
- /** All fetched records for this entity */
157
- records: context.getData(entityName),
158
- /** Get a record by ID */
159
- getById: (id) => context.getById(entityName, id),
160
- /** Whether data has been fetched for this entity */
161
- hasData: context.hasData(entityName),
162
- /** When data was last fetched */
163
- fetchedAt: context.getFetchedAt(entityName),
164
- /** Whether data is loading */
165
- loading: context.loading,
166
- /** Current error */
167
- error: context.error
168
- };
169
- }
170
- var DISPATCH_SUFFIX = ":DISPATCH";
171
- var SUCCESS_SUFFIX = ":SUCCESS";
172
- var ERROR_SUFFIX = ":ERROR";
173
- function parseLifecycleEvent(type) {
174
- if (type.endsWith(DISPATCH_SUFFIX)) {
175
- const traitName = type.slice(0, -DISPATCH_SUFFIX.length);
176
- if (traitName) return { kind: "dispatch", traitName };
177
- } else if (type.endsWith(SUCCESS_SUFFIX)) {
178
- const rest = type.slice(0, -SUCCESS_SUFFIX.length);
179
- const colonIdx = rest.indexOf(":");
180
- if (colonIdx > 0) {
181
- return {
182
- kind: "success",
183
- traitName: rest.slice(0, colonIdx),
184
- event: rest.slice(colonIdx + 1)
185
- };
186
- }
187
- } else if (type.endsWith(ERROR_SUFFIX)) {
188
- const rest = type.slice(0, -ERROR_SUFFIX.length);
189
- const colonIdx = rest.indexOf(":");
190
- if (colonIdx > 0) {
191
- return {
192
- kind: "error",
193
- traitName: rest.slice(0, colonIdx),
194
- event: rest.slice(colonIdx + 1)
195
- };
196
- }
197
- }
198
- return null;
199
- }
200
- function VerificationProvider({
201
- children,
202
- enabled,
203
- runtimeManager,
204
- traitStateGetter
205
- }) {
206
- const isEnabled = enabled ?? (typeof process !== "undefined" && process.env?.NODE_ENV !== "production");
207
- const eventBus = useEventBus();
208
- const pendingRef = useRef(/* @__PURE__ */ new Map());
209
- useEffect(() => {
210
- if (!isEnabled) return;
211
- if (!eventBus.onAny) return;
212
- const unsub = eventBus.onAny((evt) => {
213
- const parsed = parseLifecycleEvent(evt.type);
214
- if (!parsed) return;
215
- const payload = evt.payload ?? {};
216
- if (parsed.kind === "dispatch") {
217
- const key = `${parsed.traitName}:${String(payload["event"] ?? "")}`;
218
- pendingRef.current.set(key, {
219
- traitName: parsed.traitName,
220
- event: String(payload["event"] ?? ""),
221
- from: payload["currentState"],
222
- timestamp: evt.timestamp
223
- });
224
- } else if (parsed.kind === "success" && parsed.event) {
225
- const key = `${parsed.traitName}:${parsed.event}`;
226
- const pending = pendingRef.current.get(key);
227
- pendingRef.current.delete(key);
228
- const newState = payload["newState"] ?? payload["state"] ?? "unknown";
229
- const effects = Array.isArray(payload["clientEffects"]) ? payload["clientEffects"].map((e) => ({
230
- type: String(e["type"] ?? "unknown"),
231
- args: Array.isArray(e["args"]) ? e["args"] : [],
232
- status: "executed"
233
- })) : [];
234
- recordTransition({
235
- traitName: parsed.traitName,
236
- from: pending?.from ?? "unknown",
237
- to: newState,
238
- event: parsed.event,
239
- effects,
240
- timestamp: Date.now()
241
- });
242
- } else if (parsed.kind === "error" && parsed.event) {
243
- const key = `${parsed.traitName}:${parsed.event}`;
244
- const pending = pendingRef.current.get(key);
245
- pendingRef.current.delete(key);
246
- const errorMsg = payload["error"] ?? "Unknown error";
247
- recordTransition({
248
- traitName: parsed.traitName,
249
- from: pending?.from ?? "unknown",
250
- to: pending?.from ?? "unknown",
251
- // state didn't change on error
252
- event: parsed.event,
253
- effects: [{
254
- type: "server-call",
255
- args: [],
256
- status: "failed",
257
- error: errorMsg
258
- }],
259
- timestamp: Date.now()
260
- });
261
- }
262
- });
263
- registerCheck(
264
- "verification-provider",
265
- "VerificationProvider active (compiled path)",
266
- "pass"
267
- );
268
- return unsub;
269
- }, [isEnabled, eventBus]);
270
- useEffect(() => {
271
- if (!isEnabled) return;
272
- if (!runtimeManager) return;
273
- runtimeManager.setObserver({
274
- onTransition(trace) {
275
- recordTransition({
276
- traitName: trace.traitName,
277
- from: trace.from,
278
- to: trace.to,
279
- event: trace.event,
280
- guardResult: trace.guardResult,
281
- effects: trace.effects,
282
- timestamp: Date.now()
283
- });
284
- }
285
- });
286
- registerCheck(
287
- "verification-provider",
288
- "VerificationProvider active (runtime path)",
289
- "pass"
290
- );
291
- }, [isEnabled, runtimeManager]);
292
- useEffect(() => {
293
- if (!isEnabled) return;
294
- bindEventBus(eventBus);
295
- }, [isEnabled, eventBus]);
296
- useEffect(() => {
297
- if (!isEnabled) return;
298
- if (traitStateGetter) {
299
- bindTraitStateGetter(traitStateGetter);
300
- } else if (runtimeManager?.getState) {
301
- const mgr = runtimeManager;
302
- bindTraitStateGetter((traitName) => mgr.getState(traitName));
303
- }
304
- }, [isEnabled, traitStateGetter, runtimeManager]);
305
- return /* @__PURE__ */ jsx(Fragment, { children });
306
- }
307
- VerificationProvider.displayName = "VerificationProvider";
308
- function FetchedDataBridge({ children }) {
309
- const fetchedData = useFetchedData();
310
- const adapter = useMemo(() => ({
311
- getData: (entity) => fetchedData.getData(entity),
312
- getById: (entity, id) => fetchedData.getById(entity, id),
313
- isLoading: fetchedData.loading,
314
- error: fetchedData.error
315
- }), [fetchedData.getData, fetchedData.getById, fetchedData.loading, fetchedData.error]);
316
- return /* @__PURE__ */ jsx(EntityDataProvider, { adapter, children });
317
- }
318
- function OrbitalProvider({
319
- children,
320
- themes,
321
- defaultTheme = "wireframe",
322
- defaultMode = "system",
323
- targetRef,
324
- skipTheme = false,
325
- debug = false,
326
- initialData,
327
- suspense = false,
328
- verification
329
- }) {
330
- const suspenseConfig = useMemo(
331
- () => ({ enabled: suspense }),
332
- [suspense]
333
- );
334
- const inner = /* @__PURE__ */ jsx(FetchedDataProvider, { initialData, children: /* @__PURE__ */ jsx(FetchedDataBridge, { children: /* @__PURE__ */ jsx(EventBusProvider, { debug, children: /* @__PURE__ */ jsx(VerificationProvider, { enabled: verification, children: /* @__PURE__ */ jsx(SelectionProvider, { debug, children: /* @__PURE__ */ jsx(SuspenseConfigProvider, { config: suspenseConfig, children }) }) }) }) }) });
335
- if (skipTheme) {
336
- return inner;
337
- }
338
- return /* @__PURE__ */ jsx(
339
- ThemeProvider,
340
- {
341
- themes,
342
- defaultTheme,
343
- defaultMode,
344
- targetRef,
345
- children: inner
346
- }
347
- );
348
- }
349
- OrbitalProvider.displayName = "OrbitalProvider";
350
- var OfflineModeContext = createContext(null);
351
- function OfflineModeProvider({
352
- children,
353
- ...executorOptions
354
- }) {
355
- const [forceOffline, setForceOffline] = useState(false);
356
- const executor = useOfflineExecutor(executorOptions);
357
- const effectivelyOffline = executor.isOffline || forceOffline;
358
- const contextValue = useMemo(
359
- () => ({
360
- ...executor,
361
- forceOffline,
362
- setForceOffline,
363
- effectivelyOffline
364
- }),
365
- [executor, forceOffline, effectivelyOffline]
366
- );
367
- return /* @__PURE__ */ jsx(OfflineModeContext.Provider, { value: contextValue, children });
368
- }
369
- function useOfflineMode() {
370
- const context = useContext(OfflineModeContext);
371
- if (!context) {
372
- throw new Error("useOfflineMode must be used within OfflineModeProvider");
373
- }
374
- return context;
375
- }
376
- function useOptionalOfflineMode() {
377
- return useContext(OfflineModeContext);
378
- }
379
-
380
- export { FetchedDataContext, FetchedDataProvider, OfflineModeProvider, OrbitalProvider, VerificationProvider, useFetchedData, useFetchedDataContext, useFetchedEntity, useOfflineMode, useOptionalOfflineMode };