@almadar/ui 3.9.1 → 4.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/avl/index.cjs +688 -607
- package/dist/avl/index.js +688 -607
- package/dist/components/index.cjs +595 -1210
- package/dist/components/index.js +591 -1192
- package/dist/components/molecules/DataGrid.d.ts +19 -8
- package/dist/components/molecules/DataList.d.ts +22 -7
- package/dist/components/molecules/WizardProgress.d.ts +2 -2
- package/dist/components/organisms/DetailPanel.d.ts +0 -2
- package/dist/components/organisms/Form.d.ts +0 -2
- package/dist/components/organisms/FormSection.d.ts +0 -2
- package/dist/hooks/index.cjs +222 -846
- package/dist/hooks/index.d.ts +0 -4
- package/dist/hooks/index.js +9 -613
- package/dist/providers/index.cjs +604 -762
- package/dist/providers/index.d.ts +0 -2
- package/dist/providers/index.js +605 -758
- package/dist/runtime/EntitySchemaContext.d.ts +7 -3
- package/dist/runtime/index.cjs +1599 -1518
- package/dist/runtime/index.js +830 -749
- package/dist/runtime/ui/SlotsContext.d.ts +57 -17
- package/package.json +1 -1
- package/dist/hooks/useEntityData.d.ts +0 -155
- package/dist/hooks/useEntityMutations.d.ts +0 -80
- package/dist/hooks/useOrbitalMutations.d.ts +0 -95
- package/dist/hooks/useResolvedEntity.d.ts +0 -32
- package/dist/providers/FetchedDataProvider.d.ts +0 -105
package/dist/hooks/index.cjs
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var react = require('react');
|
|
4
4
|
var providers = require('@almadar/ui/providers');
|
|
5
5
|
var reactQuery = require('@tanstack/react-query');
|
|
6
6
|
|
|
7
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
-
|
|
9
|
-
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
10
|
-
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
14
7
|
function useOrbitalHistory(options) {
|
|
15
8
|
const { appId, authToken, userId, onHistoryChange, onRevertSuccess } = options;
|
|
16
|
-
const
|
|
9
|
+
const getHeaders = react.useCallback(() => {
|
|
17
10
|
const headers = {
|
|
18
11
|
"Content-Type": "application/json"
|
|
19
12
|
};
|
|
@@ -25,16 +18,16 @@ function useOrbitalHistory(options) {
|
|
|
25
18
|
}
|
|
26
19
|
return headers;
|
|
27
20
|
}, [authToken, userId]);
|
|
28
|
-
const [timeline, setTimeline] =
|
|
29
|
-
const [currentVersion, setCurrentVersion] =
|
|
30
|
-
const [isLoading, setIsLoading] =
|
|
31
|
-
const [error, setError] =
|
|
32
|
-
const refresh =
|
|
21
|
+
const [timeline, setTimeline] = react.useState([]);
|
|
22
|
+
const [currentVersion, setCurrentVersion] = react.useState(1);
|
|
23
|
+
const [isLoading, setIsLoading] = react.useState(false);
|
|
24
|
+
const [error, setError] = react.useState(null);
|
|
25
|
+
const refresh = react.useCallback(async () => {
|
|
33
26
|
if (!appId) return;
|
|
34
27
|
setIsLoading(true);
|
|
35
28
|
setError(null);
|
|
36
29
|
try {
|
|
37
|
-
const headers =
|
|
30
|
+
const headers = getHeaders();
|
|
38
31
|
const [changesetsRes, snapshotsRes] = await Promise.all([
|
|
39
32
|
fetch(`/api/graphs/${appId}/history/changesets`, { headers }),
|
|
40
33
|
fetch(`/api/graphs/${appId}/history/snapshots`, { headers })
|
|
@@ -77,15 +70,15 @@ function useOrbitalHistory(options) {
|
|
|
77
70
|
} finally {
|
|
78
71
|
setIsLoading(false);
|
|
79
72
|
}
|
|
80
|
-
}, [appId,
|
|
81
|
-
const revertToSnapshot =
|
|
73
|
+
}, [appId, getHeaders]);
|
|
74
|
+
const revertToSnapshot = react.useCallback(async (snapshotId) => {
|
|
82
75
|
if (!appId) {
|
|
83
76
|
return { success: false, error: "No app ID provided" };
|
|
84
77
|
}
|
|
85
78
|
try {
|
|
86
79
|
const response = await fetch(`/api/graphs/${appId}/history/revert/${snapshotId}`, {
|
|
87
80
|
method: "POST",
|
|
88
|
-
headers:
|
|
81
|
+
headers: getHeaders()
|
|
89
82
|
});
|
|
90
83
|
if (!response.ok) {
|
|
91
84
|
const errorData = await response.json().catch(() => ({}));
|
|
@@ -111,13 +104,13 @@ function useOrbitalHistory(options) {
|
|
|
111
104
|
error: err instanceof Error ? err.message : "Failed to revert"
|
|
112
105
|
};
|
|
113
106
|
}
|
|
114
|
-
}, [appId,
|
|
115
|
-
|
|
107
|
+
}, [appId, getHeaders, refresh, onRevertSuccess]);
|
|
108
|
+
react.useEffect(() => {
|
|
116
109
|
if (appId && authToken && userId) {
|
|
117
110
|
refresh();
|
|
118
111
|
}
|
|
119
112
|
}, [appId, authToken, userId]);
|
|
120
|
-
|
|
113
|
+
react.useEffect(() => {
|
|
121
114
|
onHistoryChange?.(timeline);
|
|
122
115
|
}, [timeline]);
|
|
123
116
|
return {
|
|
@@ -130,15 +123,15 @@ function useOrbitalHistory(options) {
|
|
|
130
123
|
};
|
|
131
124
|
}
|
|
132
125
|
function useFileSystem() {
|
|
133
|
-
const [status, setStatus] =
|
|
134
|
-
const [error, setError] =
|
|
135
|
-
const [isLoading, setIsLoading] =
|
|
136
|
-
const [files, setFiles] =
|
|
137
|
-
const [selectedFile, setSelectedFile] =
|
|
138
|
-
const [selectedPath, setSelectedPath] =
|
|
139
|
-
const [previewUrl, setPreviewUrl] =
|
|
140
|
-
const [fileContents, setFileContents] =
|
|
141
|
-
const boot =
|
|
126
|
+
const [status, setStatus] = react.useState("idle");
|
|
127
|
+
const [error, setError] = react.useState(null);
|
|
128
|
+
const [isLoading, setIsLoading] = react.useState(false);
|
|
129
|
+
const [files, setFiles] = react.useState([]);
|
|
130
|
+
const [selectedFile, setSelectedFile] = react.useState(null);
|
|
131
|
+
const [selectedPath, setSelectedPath] = react.useState(null);
|
|
132
|
+
const [previewUrl, setPreviewUrl] = react.useState(null);
|
|
133
|
+
const [fileContents, setFileContents] = react.useState(/* @__PURE__ */ new Map());
|
|
134
|
+
const boot = react.useCallback(async () => {
|
|
142
135
|
setStatus("booting");
|
|
143
136
|
setError(null);
|
|
144
137
|
setIsLoading(true);
|
|
@@ -153,7 +146,7 @@ function useFileSystem() {
|
|
|
153
146
|
setIsLoading(false);
|
|
154
147
|
}
|
|
155
148
|
}, []);
|
|
156
|
-
const mountFiles =
|
|
149
|
+
const mountFiles = react.useCallback(async (filesToMount) => {
|
|
157
150
|
setIsLoading(true);
|
|
158
151
|
try {
|
|
159
152
|
let filesArray;
|
|
@@ -211,17 +204,17 @@ function useFileSystem() {
|
|
|
211
204
|
setIsLoading(false);
|
|
212
205
|
}
|
|
213
206
|
}, []);
|
|
214
|
-
const readFile =
|
|
207
|
+
const readFile = react.useCallback(async (path) => {
|
|
215
208
|
return fileContents.get(path) || "";
|
|
216
209
|
}, [fileContents]);
|
|
217
|
-
const writeFile =
|
|
210
|
+
const writeFile = react.useCallback(async (path, content) => {
|
|
218
211
|
setFileContents((prev) => {
|
|
219
212
|
const next = new Map(prev);
|
|
220
213
|
next.set(path, content);
|
|
221
214
|
return next;
|
|
222
215
|
});
|
|
223
216
|
}, []);
|
|
224
|
-
const selectFile =
|
|
217
|
+
const selectFile = react.useCallback(async (path) => {
|
|
225
218
|
const content = fileContents.get(path) || "";
|
|
226
219
|
const ext = path.split(".").pop()?.toLowerCase() || "";
|
|
227
220
|
const languageMap = {
|
|
@@ -243,7 +236,7 @@ function useFileSystem() {
|
|
|
243
236
|
isDirty: false
|
|
244
237
|
});
|
|
245
238
|
}, [fileContents]);
|
|
246
|
-
const updateContent =
|
|
239
|
+
const updateContent = react.useCallback((pathOrContent, contentArg) => {
|
|
247
240
|
const path = contentArg !== void 0 ? pathOrContent : selectedPath;
|
|
248
241
|
const content = contentArg !== void 0 ? contentArg : pathOrContent;
|
|
249
242
|
if (!path) {
|
|
@@ -259,17 +252,17 @@ function useFileSystem() {
|
|
|
259
252
|
setSelectedFile((prev) => prev ? { ...prev, content, isDirty: true } : null);
|
|
260
253
|
}
|
|
261
254
|
}, [selectedPath]);
|
|
262
|
-
const updateSelectedContent =
|
|
255
|
+
const updateSelectedContent = react.useCallback((content) => {
|
|
263
256
|
setSelectedFile((prev) => prev ? { ...prev, content, isDirty: true } : null);
|
|
264
257
|
}, []);
|
|
265
|
-
const refreshTree =
|
|
258
|
+
const refreshTree = react.useCallback(async () => {
|
|
266
259
|
console.log("[useFileSystem] Refreshing tree");
|
|
267
260
|
}, []);
|
|
268
|
-
const runCommand =
|
|
261
|
+
const runCommand = react.useCallback(async (command) => {
|
|
269
262
|
console.log("[useFileSystem] Running command:", command);
|
|
270
263
|
return { exitCode: 0, output: "" };
|
|
271
264
|
}, []);
|
|
272
|
-
const startDevServer =
|
|
265
|
+
const startDevServer = react.useCallback(async () => {
|
|
273
266
|
console.log("[useFileSystem] Starting dev server");
|
|
274
267
|
setPreviewUrl("http://localhost:5173");
|
|
275
268
|
}, []);
|
|
@@ -306,14 +299,14 @@ var defaultManifest = {
|
|
|
306
299
|
};
|
|
307
300
|
function useExtensions(options) {
|
|
308
301
|
const { appId, loadOnMount = true } = options;
|
|
309
|
-
const [extensions, setExtensions] =
|
|
310
|
-
const [manifest] =
|
|
311
|
-
const [isLoading, setIsLoading] =
|
|
312
|
-
const [error, setError] =
|
|
313
|
-
const loadExtension =
|
|
302
|
+
const [extensions, setExtensions] = react.useState([]);
|
|
303
|
+
const [manifest] = react.useState(defaultManifest);
|
|
304
|
+
const [isLoading, setIsLoading] = react.useState(false);
|
|
305
|
+
const [error, setError] = react.useState(null);
|
|
306
|
+
const loadExtension = react.useCallback(async (extensionId) => {
|
|
314
307
|
console.log("[useExtensions] Loading extension:", extensionId);
|
|
315
308
|
}, []);
|
|
316
|
-
const loadExtensions =
|
|
309
|
+
const loadExtensions = react.useCallback(async () => {
|
|
317
310
|
setIsLoading(true);
|
|
318
311
|
setError(null);
|
|
319
312
|
try {
|
|
@@ -332,7 +325,7 @@ function useExtensions(options) {
|
|
|
332
325
|
setIsLoading(false);
|
|
333
326
|
}
|
|
334
327
|
}, []);
|
|
335
|
-
const getExtensionForFile =
|
|
328
|
+
const getExtensionForFile = react.useCallback((filename) => {
|
|
336
329
|
const ext = filename.split(".").pop()?.toLowerCase();
|
|
337
330
|
if (!ext) return null;
|
|
338
331
|
const languageMap = {
|
|
@@ -350,7 +343,7 @@ function useExtensions(options) {
|
|
|
350
343
|
if (!language) return null;
|
|
351
344
|
return extensions.find((e) => e.language === language) || null;
|
|
352
345
|
}, [extensions]);
|
|
353
|
-
|
|
346
|
+
react.useEffect(() => {
|
|
354
347
|
if (!appId || !loadOnMount) return;
|
|
355
348
|
const loadExtensions2 = async () => {
|
|
356
349
|
setIsLoading(true);
|
|
@@ -385,11 +378,11 @@ function useExtensions(options) {
|
|
|
385
378
|
}
|
|
386
379
|
function useFileEditor(options) {
|
|
387
380
|
const { extensions, fileSystem, onSchemaUpdate } = options;
|
|
388
|
-
const [openFiles, setOpenFiles] =
|
|
389
|
-
const [activeFilePath, setActiveFilePath] =
|
|
390
|
-
const [isSaving, setIsSaving] =
|
|
381
|
+
const [openFiles, setOpenFiles] = react.useState([]);
|
|
382
|
+
const [activeFilePath, setActiveFilePath] = react.useState(null);
|
|
383
|
+
const [isSaving, setIsSaving] = react.useState(false);
|
|
391
384
|
const activeFile = openFiles.find((f) => f.path === activeFilePath) || null;
|
|
392
|
-
const openFile =
|
|
385
|
+
const openFile = react.useCallback(async (path) => {
|
|
393
386
|
const existing = openFiles.find((f) => f.path === path);
|
|
394
387
|
if (existing) {
|
|
395
388
|
setActiveFilePath(path);
|
|
@@ -410,24 +403,24 @@ function useFileEditor(options) {
|
|
|
410
403
|
console.error("[useFileEditor] Failed to open file:", err);
|
|
411
404
|
}
|
|
412
405
|
}, [openFiles, fileSystem, extensions]);
|
|
413
|
-
const closeFile =
|
|
406
|
+
const closeFile = react.useCallback((path) => {
|
|
414
407
|
setOpenFiles((prev) => prev.filter((f) => f.path !== path));
|
|
415
408
|
if (activeFilePath === path) {
|
|
416
409
|
const remaining = openFiles.filter((f) => f.path !== path);
|
|
417
410
|
setActiveFilePath(remaining.length > 0 ? remaining[0].path : null);
|
|
418
411
|
}
|
|
419
412
|
}, [activeFilePath, openFiles]);
|
|
420
|
-
const setActiveFile =
|
|
413
|
+
const setActiveFile = react.useCallback((path) => {
|
|
421
414
|
setActiveFilePath(path);
|
|
422
415
|
}, []);
|
|
423
|
-
const updateFileContent =
|
|
416
|
+
const updateFileContent = react.useCallback((path, content) => {
|
|
424
417
|
setOpenFiles(
|
|
425
418
|
(prev) => prev.map(
|
|
426
419
|
(f) => f.path === path ? { ...f, content, isDirty: true } : f
|
|
427
420
|
)
|
|
428
421
|
);
|
|
429
422
|
}, []);
|
|
430
|
-
const handleFileEdit =
|
|
423
|
+
const handleFileEdit = react.useCallback(async (path, content) => {
|
|
431
424
|
try {
|
|
432
425
|
await fileSystem.writeFile(path, content);
|
|
433
426
|
let action = "saved";
|
|
@@ -449,7 +442,7 @@ function useFileEditor(options) {
|
|
|
449
442
|
};
|
|
450
443
|
}
|
|
451
444
|
}, [fileSystem, onSchemaUpdate]);
|
|
452
|
-
const saveFile =
|
|
445
|
+
const saveFile = react.useCallback(async (path) => {
|
|
453
446
|
const file = openFiles.find((f) => f.path === path);
|
|
454
447
|
if (!file) return;
|
|
455
448
|
setIsSaving(true);
|
|
@@ -473,7 +466,7 @@ function useFileEditor(options) {
|
|
|
473
466
|
setIsSaving(false);
|
|
474
467
|
}
|
|
475
468
|
}, [openFiles, fileSystem, onSchemaUpdate]);
|
|
476
|
-
const saveAllFiles =
|
|
469
|
+
const saveAllFiles = react.useCallback(async () => {
|
|
477
470
|
setIsSaving(true);
|
|
478
471
|
try {
|
|
479
472
|
const dirtyFiles = openFiles.filter((f) => f.isDirty);
|
|
@@ -498,11 +491,11 @@ function useFileEditor(options) {
|
|
|
498
491
|
};
|
|
499
492
|
}
|
|
500
493
|
function useCompile() {
|
|
501
|
-
const [isCompiling, setIsCompiling] =
|
|
502
|
-
const [stage, setStage] =
|
|
503
|
-
const [lastResult, setLastResult] =
|
|
504
|
-
const [error, setError] =
|
|
505
|
-
const compileSchema =
|
|
494
|
+
const [isCompiling, setIsCompiling] = react.useState(false);
|
|
495
|
+
const [stage, setStage] = react.useState("idle");
|
|
496
|
+
const [lastResult, setLastResult] = react.useState(null);
|
|
497
|
+
const [error, setError] = react.useState(null);
|
|
498
|
+
const compileSchema = react.useCallback(async (schema) => {
|
|
506
499
|
setIsCompiling(true);
|
|
507
500
|
setStage("compiling");
|
|
508
501
|
setError(null);
|
|
@@ -534,18 +527,18 @@ function useCompile() {
|
|
|
534
527
|
};
|
|
535
528
|
}
|
|
536
529
|
function usePreview(options) {
|
|
537
|
-
const [previewUrl, setPreviewUrl] =
|
|
538
|
-
const [isLoading, setIsLoading] =
|
|
539
|
-
const [error, setError] =
|
|
540
|
-
const [loadError, setLoadError] =
|
|
541
|
-
const [app, setApp] =
|
|
542
|
-
const [isFullscreen, setIsFullscreen] =
|
|
543
|
-
const [isExecutingEvent, setIsExecutingEvent] =
|
|
544
|
-
const [errorToast, setErrorToast] =
|
|
545
|
-
const [currentStateName, setCurrentStateName] =
|
|
546
|
-
const [notificationsList, setNotificationsList] =
|
|
547
|
-
const [isPanelOpen, setIsPanelOpen] =
|
|
548
|
-
const notifications =
|
|
530
|
+
const [previewUrl, setPreviewUrl] = react.useState(null);
|
|
531
|
+
const [isLoading, setIsLoading] = react.useState(!!options?.appId);
|
|
532
|
+
const [error, setError] = react.useState(null);
|
|
533
|
+
const [loadError, setLoadError] = react.useState(null);
|
|
534
|
+
const [app, setApp] = react.useState(null);
|
|
535
|
+
const [isFullscreen, setIsFullscreen] = react.useState(false);
|
|
536
|
+
const [isExecutingEvent, setIsExecutingEvent] = react.useState(false);
|
|
537
|
+
const [errorToast, setErrorToast] = react.useState(null);
|
|
538
|
+
const [currentStateName, setCurrentStateName] = react.useState(null);
|
|
539
|
+
const [notificationsList, setNotificationsList] = react.useState([]);
|
|
540
|
+
const [isPanelOpen, setIsPanelOpen] = react.useState(false);
|
|
541
|
+
const notifications = react.useMemo(() => ({
|
|
549
542
|
notifications: notificationsList,
|
|
550
543
|
isPanelOpen,
|
|
551
544
|
closePanel: () => setIsPanelOpen(false),
|
|
@@ -559,7 +552,7 @@ function usePreview(options) {
|
|
|
559
552
|
},
|
|
560
553
|
clearAll: () => setNotificationsList([])
|
|
561
554
|
}), [notificationsList, isPanelOpen]);
|
|
562
|
-
|
|
555
|
+
react.useEffect(() => {
|
|
563
556
|
const appId = options?.appId;
|
|
564
557
|
if (!appId) {
|
|
565
558
|
setApp(null);
|
|
@@ -570,10 +563,10 @@ function usePreview(options) {
|
|
|
570
563
|
setPreviewUrl(`/api/orbitals/${appId}`);
|
|
571
564
|
setIsLoading(false);
|
|
572
565
|
}, [options?.appId]);
|
|
573
|
-
const startPreview =
|
|
566
|
+
const startPreview = react.useCallback(async () => {
|
|
574
567
|
console.log("[usePreview] startPreview called");
|
|
575
568
|
}, []);
|
|
576
|
-
const stopPreview =
|
|
569
|
+
const stopPreview = react.useCallback(async () => {
|
|
577
570
|
setIsLoading(true);
|
|
578
571
|
try {
|
|
579
572
|
console.log("[usePreview] Stopping preview server...");
|
|
@@ -583,16 +576,16 @@ function usePreview(options) {
|
|
|
583
576
|
setIsLoading(false);
|
|
584
577
|
}
|
|
585
578
|
}, []);
|
|
586
|
-
const refresh =
|
|
579
|
+
const refresh = react.useCallback(async () => {
|
|
587
580
|
if (!previewUrl) return;
|
|
588
581
|
console.log("[usePreview] Refreshing preview...");
|
|
589
582
|
setPreviewUrl(`${previewUrl.split("?")[0]}?t=${Date.now()}`);
|
|
590
583
|
}, [previewUrl]);
|
|
591
|
-
const handleRefresh =
|
|
584
|
+
const handleRefresh = react.useCallback(async () => {
|
|
592
585
|
console.log("[usePreview] Handle refresh...");
|
|
593
586
|
await refresh();
|
|
594
587
|
}, [refresh]);
|
|
595
|
-
const handleReset =
|
|
588
|
+
const handleReset = react.useCallback(async () => {
|
|
596
589
|
console.log("[usePreview] Resetting preview...");
|
|
597
590
|
setError(null);
|
|
598
591
|
setLoadError(null);
|
|
@@ -600,10 +593,10 @@ function usePreview(options) {
|
|
|
600
593
|
setIsExecutingEvent(false);
|
|
601
594
|
setCurrentStateName(null);
|
|
602
595
|
}, []);
|
|
603
|
-
const toggleFullscreen =
|
|
596
|
+
const toggleFullscreen = react.useCallback(() => {
|
|
604
597
|
setIsFullscreen((prev) => !prev);
|
|
605
598
|
}, []);
|
|
606
|
-
const dismissErrorToast =
|
|
599
|
+
const dismissErrorToast = react.useCallback(() => {
|
|
607
600
|
setErrorToast(null);
|
|
608
601
|
}, []);
|
|
609
602
|
return {
|
|
@@ -628,16 +621,16 @@ function usePreview(options) {
|
|
|
628
621
|
};
|
|
629
622
|
}
|
|
630
623
|
function useAgentChat(options) {
|
|
631
|
-
const [messages, setMessages] =
|
|
632
|
-
const [status, setStatus] =
|
|
633
|
-
const [activities, setActivities] =
|
|
634
|
-
const [todos, setTodos] =
|
|
635
|
-
const [schemaDiffs, setSchemaDiffs] =
|
|
636
|
-
const [isLoading, setIsLoading] =
|
|
637
|
-
const [error, setError] =
|
|
638
|
-
const [threadId] =
|
|
639
|
-
const [interrupt, setInterrupt] =
|
|
640
|
-
const sendMessage =
|
|
624
|
+
const [messages, setMessages] = react.useState([]);
|
|
625
|
+
const [status, setStatus] = react.useState("idle");
|
|
626
|
+
const [activities, setActivities] = react.useState([]);
|
|
627
|
+
const [todos, setTodos] = react.useState([]);
|
|
628
|
+
const [schemaDiffs, setSchemaDiffs] = react.useState([]);
|
|
629
|
+
const [isLoading, setIsLoading] = react.useState(false);
|
|
630
|
+
const [error, setError] = react.useState(null);
|
|
631
|
+
const [threadId] = react.useState(null);
|
|
632
|
+
const [interrupt, setInterrupt] = react.useState(null);
|
|
633
|
+
const sendMessage = react.useCallback(async (content) => {
|
|
641
634
|
setIsLoading(true);
|
|
642
635
|
setStatus("running");
|
|
643
636
|
setError(null);
|
|
@@ -666,7 +659,7 @@ function useAgentChat(options) {
|
|
|
666
659
|
setIsLoading(false);
|
|
667
660
|
}
|
|
668
661
|
}, [options]);
|
|
669
|
-
const startGeneration =
|
|
662
|
+
const startGeneration = react.useCallback(async (skill, prompt, genOptions) => {
|
|
670
663
|
setStatus("running");
|
|
671
664
|
setIsLoading(true);
|
|
672
665
|
setError(null);
|
|
@@ -683,22 +676,22 @@ function useAgentChat(options) {
|
|
|
683
676
|
setIsLoading(false);
|
|
684
677
|
}
|
|
685
678
|
}, [options]);
|
|
686
|
-
const continueConversation =
|
|
679
|
+
const continueConversation = react.useCallback(async (message) => {
|
|
687
680
|
console.log("[useAgentChat] Continue conversation", message);
|
|
688
681
|
}, []);
|
|
689
|
-
const resumeWithDecision =
|
|
682
|
+
const resumeWithDecision = react.useCallback(async (decisions) => {
|
|
690
683
|
console.log("[useAgentChat] Resume with decision:", decisions);
|
|
691
684
|
setInterrupt(null);
|
|
692
685
|
}, []);
|
|
693
|
-
const cancel =
|
|
686
|
+
const cancel = react.useCallback(() => {
|
|
694
687
|
setStatus("idle");
|
|
695
688
|
setIsLoading(false);
|
|
696
689
|
setInterrupt(null);
|
|
697
690
|
}, []);
|
|
698
|
-
const clearMessages =
|
|
691
|
+
const clearMessages = react.useCallback(() => {
|
|
699
692
|
setMessages([]);
|
|
700
693
|
}, []);
|
|
701
|
-
const clearHistory =
|
|
694
|
+
const clearHistory = react.useCallback(() => {
|
|
702
695
|
setMessages([]);
|
|
703
696
|
setActivities([]);
|
|
704
697
|
setTodos([]);
|
|
@@ -725,13 +718,13 @@ function useAgentChat(options) {
|
|
|
725
718
|
};
|
|
726
719
|
}
|
|
727
720
|
function useValidation() {
|
|
728
|
-
const [result, setResult] =
|
|
729
|
-
const [isValidating, setIsValidating] =
|
|
730
|
-
const [error, setError] =
|
|
731
|
-
const [stage, setStage] =
|
|
732
|
-
const [isFixing, setIsFixing] =
|
|
733
|
-
const [progressMessage, setProgressMessage] =
|
|
734
|
-
const validate =
|
|
721
|
+
const [result, setResult] = react.useState(null);
|
|
722
|
+
const [isValidating, setIsValidating] = react.useState(false);
|
|
723
|
+
const [error, setError] = react.useState(null);
|
|
724
|
+
const [stage, setStage] = react.useState("idle");
|
|
725
|
+
const [isFixing, setIsFixing] = react.useState(false);
|
|
726
|
+
const [progressMessage, setProgressMessage] = react.useState(null);
|
|
727
|
+
const validate = react.useCallback(async (appId) => {
|
|
735
728
|
setIsValidating(true);
|
|
736
729
|
setError(null);
|
|
737
730
|
setStage("validating");
|
|
@@ -763,11 +756,11 @@ function useValidation() {
|
|
|
763
756
|
setIsValidating(false);
|
|
764
757
|
}
|
|
765
758
|
}, []);
|
|
766
|
-
const clearResult =
|
|
759
|
+
const clearResult = react.useCallback(() => {
|
|
767
760
|
setResult(null);
|
|
768
761
|
setError(null);
|
|
769
762
|
}, []);
|
|
770
|
-
const reset =
|
|
763
|
+
const reset = react.useCallback(() => {
|
|
771
764
|
setResult(null);
|
|
772
765
|
setError(null);
|
|
773
766
|
setStage("idle");
|
|
@@ -791,15 +784,15 @@ function useValidation() {
|
|
|
791
784
|
};
|
|
792
785
|
}
|
|
793
786
|
function useDeepAgentGeneration() {
|
|
794
|
-
const [requests, setRequests] =
|
|
795
|
-
const [currentRequest, setCurrentRequest] =
|
|
796
|
-
const [isGenerating, setIsGenerating] =
|
|
797
|
-
const [isLoading, setIsLoading] =
|
|
798
|
-
const [isComplete, setIsComplete] =
|
|
799
|
-
const [progress, setProgress] =
|
|
800
|
-
const [error, setError] =
|
|
801
|
-
const [interrupt, setInterrupt] =
|
|
802
|
-
const generate =
|
|
787
|
+
const [requests, setRequests] = react.useState([]);
|
|
788
|
+
const [currentRequest, setCurrentRequest] = react.useState(null);
|
|
789
|
+
const [isGenerating, setIsGenerating] = react.useState(false);
|
|
790
|
+
const [isLoading, setIsLoading] = react.useState(false);
|
|
791
|
+
const [isComplete, setIsComplete] = react.useState(false);
|
|
792
|
+
const [progress, setProgress] = react.useState({ stage: "idle", percent: 0, message: "" });
|
|
793
|
+
const [error, setError] = react.useState(null);
|
|
794
|
+
const [interrupt, setInterrupt] = react.useState(null);
|
|
795
|
+
const generate = react.useCallback(async (prompt) => {
|
|
803
796
|
setIsGenerating(true);
|
|
804
797
|
setIsLoading(true);
|
|
805
798
|
setIsComplete(false);
|
|
@@ -832,11 +825,11 @@ function useDeepAgentGeneration() {
|
|
|
832
825
|
setIsLoading(false);
|
|
833
826
|
}
|
|
834
827
|
}, []);
|
|
835
|
-
const startGeneration =
|
|
828
|
+
const startGeneration = react.useCallback(async (skill, prompt, _options) => {
|
|
836
829
|
console.log("[useDeepAgentGeneration] Starting generation with skill:", skill);
|
|
837
830
|
await generate(prompt);
|
|
838
831
|
}, [generate]);
|
|
839
|
-
const cancelGeneration =
|
|
832
|
+
const cancelGeneration = react.useCallback(() => {
|
|
840
833
|
if (currentRequest) {
|
|
841
834
|
currentRequest.status = "failed";
|
|
842
835
|
currentRequest.error = "Cancelled by user";
|
|
@@ -847,14 +840,14 @@ function useDeepAgentGeneration() {
|
|
|
847
840
|
setIsComplete(false);
|
|
848
841
|
setProgress({ stage: "idle", percent: 0, message: "" });
|
|
849
842
|
}, [currentRequest]);
|
|
850
|
-
const clearRequests =
|
|
843
|
+
const clearRequests = react.useCallback(() => {
|
|
851
844
|
setRequests([]);
|
|
852
845
|
setCurrentRequest(null);
|
|
853
846
|
setError(null);
|
|
854
847
|
setProgress({ stage: "idle", percent: 0, message: "" });
|
|
855
848
|
setIsComplete(false);
|
|
856
849
|
}, []);
|
|
857
|
-
const submitInterruptDecisions =
|
|
850
|
+
const submitInterruptDecisions = react.useCallback((decisions) => {
|
|
858
851
|
console.log("[useDeepAgentGeneration] Submitting interrupt decisions:", decisions);
|
|
859
852
|
setInterrupt(null);
|
|
860
853
|
}, []);
|
|
@@ -997,14 +990,14 @@ var fallbackEventBus = {
|
|
|
997
990
|
}
|
|
998
991
|
};
|
|
999
992
|
function useEventBus() {
|
|
1000
|
-
const context =
|
|
993
|
+
const context = react.useContext(providers.EventBusContext);
|
|
1001
994
|
return context ?? getGlobalEventBus() ?? fallbackEventBus;
|
|
1002
995
|
}
|
|
1003
996
|
function useEventListener(event, handler) {
|
|
1004
997
|
const eventBus = useEventBus();
|
|
1005
|
-
const handlerRef =
|
|
998
|
+
const handlerRef = react.useRef(handler);
|
|
1006
999
|
handlerRef.current = handler;
|
|
1007
|
-
|
|
1000
|
+
react.useEffect(() => {
|
|
1008
1001
|
const wrappedHandler = (evt) => {
|
|
1009
1002
|
handlerRef.current(evt);
|
|
1010
1003
|
};
|
|
@@ -1016,7 +1009,7 @@ function useEventListener(event, handler) {
|
|
|
1016
1009
|
}
|
|
1017
1010
|
function useEmitEvent() {
|
|
1018
1011
|
const eventBus = useEventBus();
|
|
1019
|
-
return
|
|
1012
|
+
return react.useCallback(
|
|
1020
1013
|
(type, payload, source) => {
|
|
1021
1014
|
eventBus.emit(type, payload, source);
|
|
1022
1015
|
},
|
|
@@ -1042,18 +1035,18 @@ function generateId() {
|
|
|
1042
1035
|
return `slot-content-${++idCounter}-${Date.now()}`;
|
|
1043
1036
|
}
|
|
1044
1037
|
function useUISlotManager() {
|
|
1045
|
-
const [slots, setSlots] =
|
|
1046
|
-
const subscribersRef =
|
|
1047
|
-
const timersRef =
|
|
1048
|
-
const traitIndexRef =
|
|
1049
|
-
const traitSubscribersRef =
|
|
1050
|
-
|
|
1038
|
+
const [slots, setSlots] = react.useState(DEFAULT_SLOTS);
|
|
1039
|
+
const subscribersRef = react.useRef(/* @__PURE__ */ new Set());
|
|
1040
|
+
const timersRef = react.useRef(/* @__PURE__ */ new Map());
|
|
1041
|
+
const traitIndexRef = react.useRef(/* @__PURE__ */ new Map());
|
|
1042
|
+
const traitSubscribersRef = react.useRef(/* @__PURE__ */ new Map());
|
|
1043
|
+
react.useEffect(() => {
|
|
1051
1044
|
return () => {
|
|
1052
1045
|
timersRef.current.forEach((timer) => clearTimeout(timer));
|
|
1053
1046
|
timersRef.current.clear();
|
|
1054
1047
|
};
|
|
1055
1048
|
}, []);
|
|
1056
|
-
const notifySubscribers =
|
|
1049
|
+
const notifySubscribers = react.useCallback((slot, content) => {
|
|
1057
1050
|
subscribersRef.current.forEach((callback) => {
|
|
1058
1051
|
try {
|
|
1059
1052
|
callback(slot, content);
|
|
@@ -1062,7 +1055,7 @@ function useUISlotManager() {
|
|
|
1062
1055
|
}
|
|
1063
1056
|
});
|
|
1064
1057
|
}, []);
|
|
1065
|
-
const notifyTraitSubscribers =
|
|
1058
|
+
const notifyTraitSubscribers = react.useCallback(
|
|
1066
1059
|
(traitName, content) => {
|
|
1067
1060
|
const subs = traitSubscribersRef.current.get(traitName);
|
|
1068
1061
|
if (!subs) return;
|
|
@@ -1076,16 +1069,16 @@ function useUISlotManager() {
|
|
|
1076
1069
|
},
|
|
1077
1070
|
[]
|
|
1078
1071
|
);
|
|
1079
|
-
const indexTraitRender =
|
|
1072
|
+
const indexTraitRender = react.useCallback(
|
|
1080
1073
|
(traitName, content) => {
|
|
1081
1074
|
traitIndexRef.current.set(traitName, content);
|
|
1082
1075
|
},
|
|
1083
1076
|
[]
|
|
1084
1077
|
);
|
|
1085
|
-
const unindexTrait =
|
|
1078
|
+
const unindexTrait = react.useCallback((traitName) => {
|
|
1086
1079
|
traitIndexRef.current.delete(traitName);
|
|
1087
1080
|
}, []);
|
|
1088
|
-
const render =
|
|
1081
|
+
const render = react.useCallback((config) => {
|
|
1089
1082
|
const id = generateId();
|
|
1090
1083
|
const content = {
|
|
1091
1084
|
id,
|
|
@@ -1128,7 +1121,7 @@ function useUISlotManager() {
|
|
|
1128
1121
|
});
|
|
1129
1122
|
return id;
|
|
1130
1123
|
}, [notifySubscribers, notifyTraitSubscribers, indexTraitRender]);
|
|
1131
|
-
const clear =
|
|
1124
|
+
const clear = react.useCallback((slot) => {
|
|
1132
1125
|
setSlots((prev) => {
|
|
1133
1126
|
const content = prev[slot];
|
|
1134
1127
|
if (content) {
|
|
@@ -1147,7 +1140,7 @@ function useUISlotManager() {
|
|
|
1147
1140
|
return { ...prev, [slot]: null };
|
|
1148
1141
|
});
|
|
1149
1142
|
}, [notifySubscribers, notifyTraitSubscribers, unindexTrait]);
|
|
1150
|
-
const clearById =
|
|
1143
|
+
const clearById = react.useCallback((id) => {
|
|
1151
1144
|
setSlots((prev) => {
|
|
1152
1145
|
const entry = Object.entries(prev).find(([, content]) => content?.id === id);
|
|
1153
1146
|
if (entry) {
|
|
@@ -1168,7 +1161,7 @@ function useUISlotManager() {
|
|
|
1168
1161
|
return prev;
|
|
1169
1162
|
});
|
|
1170
1163
|
}, [notifySubscribers, notifyTraitSubscribers, unindexTrait]);
|
|
1171
|
-
const clearAll =
|
|
1164
|
+
const clearAll = react.useCallback(() => {
|
|
1172
1165
|
timersRef.current.forEach((timer) => clearTimeout(timer));
|
|
1173
1166
|
timersRef.current.clear();
|
|
1174
1167
|
setSlots((prev) => {
|
|
@@ -1185,25 +1178,25 @@ function useUISlotManager() {
|
|
|
1185
1178
|
});
|
|
1186
1179
|
traitIndexRef.current.clear();
|
|
1187
1180
|
}, [notifySubscribers, notifyTraitSubscribers]);
|
|
1188
|
-
const subscribe2 =
|
|
1181
|
+
const subscribe2 = react.useCallback((callback) => {
|
|
1189
1182
|
subscribersRef.current.add(callback);
|
|
1190
1183
|
return () => {
|
|
1191
1184
|
subscribersRef.current.delete(callback);
|
|
1192
1185
|
};
|
|
1193
1186
|
}, []);
|
|
1194
|
-
const hasContent =
|
|
1187
|
+
const hasContent = react.useCallback((slot) => {
|
|
1195
1188
|
return slots[slot] !== null;
|
|
1196
1189
|
}, [slots]);
|
|
1197
|
-
const getContent =
|
|
1190
|
+
const getContent = react.useCallback((slot) => {
|
|
1198
1191
|
return slots[slot];
|
|
1199
1192
|
}, [slots]);
|
|
1200
|
-
const getTraitContent =
|
|
1193
|
+
const getTraitContent = react.useCallback(
|
|
1201
1194
|
(traitName) => {
|
|
1202
1195
|
return traitIndexRef.current.get(traitName) ?? null;
|
|
1203
1196
|
},
|
|
1204
1197
|
[]
|
|
1205
1198
|
);
|
|
1206
|
-
const subscribeTrait =
|
|
1199
|
+
const subscribeTrait = react.useCallback(
|
|
1207
1200
|
(traitName, callback) => {
|
|
1208
1201
|
let set = traitSubscribersRef.current.get(traitName);
|
|
1209
1202
|
if (!set) {
|
|
@@ -1240,12 +1233,12 @@ function useUIEvents(dispatch, validEvents, eventBusInstance) {
|
|
|
1240
1233
|
const defaultEventBus = useEventBus();
|
|
1241
1234
|
const eventBus = eventBusInstance ?? defaultEventBus;
|
|
1242
1235
|
const validEventsKey = validEvents ? validEvents.slice().sort().join(",") : "";
|
|
1243
|
-
const stableValidEvents =
|
|
1236
|
+
const stableValidEvents = react.useMemo(
|
|
1244
1237
|
() => validEvents,
|
|
1245
1238
|
[validEventsKey]
|
|
1246
1239
|
// intentional — validEventsKey is the stable dep, not validEvents array ref
|
|
1247
1240
|
);
|
|
1248
|
-
|
|
1241
|
+
react.useEffect(() => {
|
|
1249
1242
|
const unsubscribes = [];
|
|
1250
1243
|
if (stableValidEvents) {
|
|
1251
1244
|
for (const smEvent of stableValidEvents) {
|
|
@@ -1283,9 +1276,9 @@ function useSelectedEntity(eventBusInstance) {
|
|
|
1283
1276
|
const defaultEventBus = useEventBus();
|
|
1284
1277
|
const eventBus = eventBusInstance ?? defaultEventBus;
|
|
1285
1278
|
const selectionContext = useSelectionContext();
|
|
1286
|
-
const [localSelected, setLocalSelected] =
|
|
1279
|
+
const [localSelected, setLocalSelected] = react.useState(null);
|
|
1287
1280
|
const usingContext = selectionContext !== null;
|
|
1288
|
-
|
|
1281
|
+
react.useEffect(() => {
|
|
1289
1282
|
if (usingContext) return;
|
|
1290
1283
|
const handleSelect = (event) => {
|
|
1291
1284
|
const row = event.payload?.row;
|
|
@@ -1315,211 +1308,9 @@ function useSelectedEntity(eventBusInstance) {
|
|
|
1315
1308
|
return [localSelected, setLocalSelected];
|
|
1316
1309
|
}
|
|
1317
1310
|
function useSelectionContext() {
|
|
1318
|
-
const context =
|
|
1311
|
+
const context = react.useContext(providers.SelectionContext);
|
|
1319
1312
|
return context;
|
|
1320
1313
|
}
|
|
1321
|
-
var EntityDataContext = React.createContext(null);
|
|
1322
|
-
function EntityDataProvider({
|
|
1323
|
-
adapter,
|
|
1324
|
-
children
|
|
1325
|
-
}) {
|
|
1326
|
-
return React__default.default.createElement(
|
|
1327
|
-
EntityDataContext.Provider,
|
|
1328
|
-
{ value: adapter },
|
|
1329
|
-
children
|
|
1330
|
-
);
|
|
1331
|
-
}
|
|
1332
|
-
function useEntityDataAdapter() {
|
|
1333
|
-
return React.useContext(EntityDataContext);
|
|
1334
|
-
}
|
|
1335
|
-
var entityDataKeys = {
|
|
1336
|
-
all: ["entities"],
|
|
1337
|
-
lists: () => [...entityDataKeys.all, "list"],
|
|
1338
|
-
list: (entity, filters) => [...entityDataKeys.lists(), entity, filters],
|
|
1339
|
-
details: () => [...entityDataKeys.all, "detail"],
|
|
1340
|
-
detail: (entity, id) => [...entityDataKeys.details(), entity, id]
|
|
1341
|
-
};
|
|
1342
|
-
function useEntityList(entity, options = {}) {
|
|
1343
|
-
const { skip = false } = options;
|
|
1344
|
-
const adapter = React.useContext(EntityDataContext);
|
|
1345
|
-
const adapterData = React.useMemo(() => {
|
|
1346
|
-
if (!adapter || !entity || skip) return [];
|
|
1347
|
-
return adapter.getData(entity);
|
|
1348
|
-
}, [adapter, entity, skip, adapter?.isLoading]);
|
|
1349
|
-
const [stubData, setStubData] = React.useState([]);
|
|
1350
|
-
const [stubLoading, setStubLoading] = React.useState(!skip && !!entity && !adapter);
|
|
1351
|
-
const [stubError, setStubError] = React.useState(null);
|
|
1352
|
-
React.useEffect(() => {
|
|
1353
|
-
if (adapter || skip || !entity) {
|
|
1354
|
-
setStubLoading(false);
|
|
1355
|
-
return;
|
|
1356
|
-
}
|
|
1357
|
-
setStubLoading(true);
|
|
1358
|
-
const t = setTimeout(() => {
|
|
1359
|
-
setStubData([]);
|
|
1360
|
-
setStubLoading(false);
|
|
1361
|
-
}, 100);
|
|
1362
|
-
return () => clearTimeout(t);
|
|
1363
|
-
}, [entity, skip, adapter]);
|
|
1364
|
-
if (adapter) {
|
|
1365
|
-
return {
|
|
1366
|
-
data: adapterData,
|
|
1367
|
-
isLoading: adapter.isLoading,
|
|
1368
|
-
error: adapter.error ? new Error(adapter.error) : null,
|
|
1369
|
-
refetch: () => {
|
|
1370
|
-
}
|
|
1371
|
-
};
|
|
1372
|
-
}
|
|
1373
|
-
return { data: stubData, isLoading: stubLoading, error: stubError, refetch: () => {
|
|
1374
|
-
} };
|
|
1375
|
-
}
|
|
1376
|
-
function useEntity(entity, id) {
|
|
1377
|
-
const adapter = React.useContext(EntityDataContext);
|
|
1378
|
-
const adapterData = React.useMemo(() => {
|
|
1379
|
-
if (!adapter || !entity || !id) return null;
|
|
1380
|
-
return adapter.getById(entity, id) ?? null;
|
|
1381
|
-
}, [adapter, entity, id, adapter?.isLoading]);
|
|
1382
|
-
const [stubData, setStubData] = React.useState(null);
|
|
1383
|
-
const [stubLoading, setStubLoading] = React.useState(!!entity && !!id && !adapter);
|
|
1384
|
-
const [stubError, setStubError] = React.useState(null);
|
|
1385
|
-
React.useEffect(() => {
|
|
1386
|
-
if (adapter || !entity || !id) {
|
|
1387
|
-
setStubLoading(false);
|
|
1388
|
-
return;
|
|
1389
|
-
}
|
|
1390
|
-
setStubLoading(true);
|
|
1391
|
-
const t = setTimeout(() => {
|
|
1392
|
-
setStubData(null);
|
|
1393
|
-
setStubLoading(false);
|
|
1394
|
-
}, 100);
|
|
1395
|
-
return () => clearTimeout(t);
|
|
1396
|
-
}, [entity, id, adapter]);
|
|
1397
|
-
if (adapter) {
|
|
1398
|
-
return {
|
|
1399
|
-
data: adapterData,
|
|
1400
|
-
isLoading: adapter.isLoading,
|
|
1401
|
-
error: adapter.error ? new Error(adapter.error) : null
|
|
1402
|
-
};
|
|
1403
|
-
}
|
|
1404
|
-
return { data: stubData, isLoading: stubLoading, error: stubError };
|
|
1405
|
-
}
|
|
1406
|
-
function useEntityDetail(entity, id) {
|
|
1407
|
-
const result = useEntity(entity, id);
|
|
1408
|
-
return { ...result, refetch: () => {
|
|
1409
|
-
} };
|
|
1410
|
-
}
|
|
1411
|
-
var suspenseCache = /* @__PURE__ */ new Map();
|
|
1412
|
-
function getSuspenseCacheKey(entity, type, id) {
|
|
1413
|
-
return id ? `${type}:${entity}:${id}` : `${type}:${entity}`;
|
|
1414
|
-
}
|
|
1415
|
-
function useEntityListSuspense(entity) {
|
|
1416
|
-
const adapter = React.useContext(EntityDataContext);
|
|
1417
|
-
if (adapter) {
|
|
1418
|
-
if (adapter.isLoading) {
|
|
1419
|
-
const cacheKey2 = getSuspenseCacheKey(entity, "list");
|
|
1420
|
-
let entry2 = suspenseCache.get(cacheKey2);
|
|
1421
|
-
if (!entry2 || entry2.status === "resolved") {
|
|
1422
|
-
let resolve;
|
|
1423
|
-
const promise = new Promise((r) => {
|
|
1424
|
-
resolve = r;
|
|
1425
|
-
});
|
|
1426
|
-
entry2 = { promise, status: "pending" };
|
|
1427
|
-
suspenseCache.set(cacheKey2, entry2);
|
|
1428
|
-
const check = setInterval(() => {
|
|
1429
|
-
if (!adapter.isLoading) {
|
|
1430
|
-
clearInterval(check);
|
|
1431
|
-
entry2.status = "resolved";
|
|
1432
|
-
resolve();
|
|
1433
|
-
}
|
|
1434
|
-
}, 50);
|
|
1435
|
-
}
|
|
1436
|
-
if (entry2.status === "pending") {
|
|
1437
|
-
throw entry2.promise;
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
if (adapter.error) {
|
|
1441
|
-
throw new Error(adapter.error);
|
|
1442
|
-
}
|
|
1443
|
-
return {
|
|
1444
|
-
data: adapter.getData(entity),
|
|
1445
|
-
refetch: () => {
|
|
1446
|
-
}
|
|
1447
|
-
};
|
|
1448
|
-
}
|
|
1449
|
-
const cacheKey = getSuspenseCacheKey(entity, "list");
|
|
1450
|
-
let entry = suspenseCache.get(cacheKey);
|
|
1451
|
-
if (!entry) {
|
|
1452
|
-
let resolve;
|
|
1453
|
-
const promise = new Promise((r) => {
|
|
1454
|
-
resolve = r;
|
|
1455
|
-
setTimeout(() => {
|
|
1456
|
-
entry.status = "resolved";
|
|
1457
|
-
resolve();
|
|
1458
|
-
}, 100);
|
|
1459
|
-
});
|
|
1460
|
-
entry = { promise, status: "pending" };
|
|
1461
|
-
suspenseCache.set(cacheKey, entry);
|
|
1462
|
-
}
|
|
1463
|
-
if (entry.status === "pending") {
|
|
1464
|
-
throw entry.promise;
|
|
1465
|
-
}
|
|
1466
|
-
return { data: [], refetch: () => {
|
|
1467
|
-
} };
|
|
1468
|
-
}
|
|
1469
|
-
function useEntitySuspense(entity, id) {
|
|
1470
|
-
const adapter = React.useContext(EntityDataContext);
|
|
1471
|
-
if (adapter) {
|
|
1472
|
-
if (adapter.isLoading) {
|
|
1473
|
-
const cacheKey2 = getSuspenseCacheKey(entity, "detail", id);
|
|
1474
|
-
let entry2 = suspenseCache.get(cacheKey2);
|
|
1475
|
-
if (!entry2 || entry2.status === "resolved") {
|
|
1476
|
-
let resolve;
|
|
1477
|
-
const promise = new Promise((r) => {
|
|
1478
|
-
resolve = r;
|
|
1479
|
-
});
|
|
1480
|
-
entry2 = { promise, status: "pending" };
|
|
1481
|
-
suspenseCache.set(cacheKey2, entry2);
|
|
1482
|
-
const check = setInterval(() => {
|
|
1483
|
-
if (!adapter.isLoading) {
|
|
1484
|
-
clearInterval(check);
|
|
1485
|
-
entry2.status = "resolved";
|
|
1486
|
-
resolve();
|
|
1487
|
-
}
|
|
1488
|
-
}, 50);
|
|
1489
|
-
}
|
|
1490
|
-
if (entry2.status === "pending") {
|
|
1491
|
-
throw entry2.promise;
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
if (adapter.error) {
|
|
1495
|
-
throw new Error(adapter.error);
|
|
1496
|
-
}
|
|
1497
|
-
return {
|
|
1498
|
-
data: adapter.getById(entity, id) ?? null,
|
|
1499
|
-
refetch: () => {
|
|
1500
|
-
}
|
|
1501
|
-
};
|
|
1502
|
-
}
|
|
1503
|
-
const cacheKey = getSuspenseCacheKey(entity, "detail", id);
|
|
1504
|
-
let entry = suspenseCache.get(cacheKey);
|
|
1505
|
-
if (!entry) {
|
|
1506
|
-
let resolve;
|
|
1507
|
-
const promise = new Promise((r) => {
|
|
1508
|
-
resolve = r;
|
|
1509
|
-
setTimeout(() => {
|
|
1510
|
-
entry.status = "resolved";
|
|
1511
|
-
resolve();
|
|
1512
|
-
}, 100);
|
|
1513
|
-
});
|
|
1514
|
-
entry = { promise, status: "pending" };
|
|
1515
|
-
suspenseCache.set(cacheKey, entry);
|
|
1516
|
-
}
|
|
1517
|
-
if (entry.status === "pending") {
|
|
1518
|
-
throw entry.promise;
|
|
1519
|
-
}
|
|
1520
|
-
return { data: null, refetch: () => {
|
|
1521
|
-
} };
|
|
1522
|
-
}
|
|
1523
1314
|
var queryStores = /* @__PURE__ */ new Map();
|
|
1524
1315
|
function getOrCreateStore(query) {
|
|
1525
1316
|
if (!queryStores.has(query)) {
|
|
@@ -1534,35 +1325,35 @@ function getOrCreateStore(query) {
|
|
|
1534
1325
|
return queryStores.get(query);
|
|
1535
1326
|
}
|
|
1536
1327
|
function useQuerySingleton(query) {
|
|
1537
|
-
const [, forceUpdate] =
|
|
1328
|
+
const [, forceUpdate] = react.useState({});
|
|
1538
1329
|
if (!query) {
|
|
1539
1330
|
return null;
|
|
1540
1331
|
}
|
|
1541
|
-
const store =
|
|
1542
|
-
|
|
1332
|
+
const store = react.useMemo(() => getOrCreateStore(query), [query]);
|
|
1333
|
+
react.useMemo(() => {
|
|
1543
1334
|
const listener = () => forceUpdate({});
|
|
1544
1335
|
store.listeners.add(listener);
|
|
1545
1336
|
return () => {
|
|
1546
1337
|
store.listeners.delete(listener);
|
|
1547
1338
|
};
|
|
1548
1339
|
}, [store]);
|
|
1549
|
-
const notifyListeners =
|
|
1340
|
+
const notifyListeners = react.useCallback(() => {
|
|
1550
1341
|
store.listeners.forEach((listener) => listener());
|
|
1551
1342
|
}, [store]);
|
|
1552
|
-
const setSearch =
|
|
1343
|
+
const setSearch = react.useCallback((value) => {
|
|
1553
1344
|
store.search = value;
|
|
1554
1345
|
notifyListeners();
|
|
1555
1346
|
}, [store, notifyListeners]);
|
|
1556
|
-
const setFilter =
|
|
1347
|
+
const setFilter = react.useCallback((key, value) => {
|
|
1557
1348
|
store.filters = { ...store.filters, [key]: value };
|
|
1558
1349
|
notifyListeners();
|
|
1559
1350
|
}, [store, notifyListeners]);
|
|
1560
|
-
const clearFilters =
|
|
1351
|
+
const clearFilters = react.useCallback(() => {
|
|
1561
1352
|
store.filters = {};
|
|
1562
1353
|
store.search = "";
|
|
1563
1354
|
notifyListeners();
|
|
1564
1355
|
}, [store, notifyListeners]);
|
|
1565
|
-
const setSort =
|
|
1356
|
+
const setSort = react.useCallback((field, direction) => {
|
|
1566
1357
|
store.sortField = field;
|
|
1567
1358
|
store.sortDirection = direction;
|
|
1568
1359
|
notifyListeners();
|
|
@@ -1587,385 +1378,6 @@ function parseQueryBinding(binding) {
|
|
|
1587
1378
|
};
|
|
1588
1379
|
}
|
|
1589
1380
|
|
|
1590
|
-
// lib/api-client.ts
|
|
1591
|
-
var API_BASE_URL = typeof process !== "undefined" && process.env?.VITE_API_URL ? process.env.VITE_API_URL : "/api";
|
|
1592
|
-
var ApiError = class extends Error {
|
|
1593
|
-
constructor(status, statusText, message) {
|
|
1594
|
-
super(message || `API Error: ${status} ${statusText}`);
|
|
1595
|
-
__publicField(this, "status", status);
|
|
1596
|
-
__publicField(this, "statusText", statusText);
|
|
1597
|
-
this.name = "ApiError";
|
|
1598
|
-
}
|
|
1599
|
-
};
|
|
1600
|
-
async function handleResponse(response) {
|
|
1601
|
-
if (!response.ok) {
|
|
1602
|
-
let message;
|
|
1603
|
-
try {
|
|
1604
|
-
const errorData = await response.json();
|
|
1605
|
-
message = errorData.message || errorData.error;
|
|
1606
|
-
} catch {
|
|
1607
|
-
}
|
|
1608
|
-
throw new ApiError(response.status, response.statusText, message);
|
|
1609
|
-
}
|
|
1610
|
-
const text = await response.text();
|
|
1611
|
-
if (!text) {
|
|
1612
|
-
return void 0;
|
|
1613
|
-
}
|
|
1614
|
-
return JSON.parse(text);
|
|
1615
|
-
}
|
|
1616
|
-
function getHeaders() {
|
|
1617
|
-
const headers = {
|
|
1618
|
-
"Content-Type": "application/json"
|
|
1619
|
-
};
|
|
1620
|
-
const token = typeof localStorage !== "undefined" ? localStorage.getItem("authToken") : null;
|
|
1621
|
-
if (token) {
|
|
1622
|
-
headers["Authorization"] = `Bearer ${token}`;
|
|
1623
|
-
}
|
|
1624
|
-
return headers;
|
|
1625
|
-
}
|
|
1626
|
-
var apiClient = {
|
|
1627
|
-
/**
|
|
1628
|
-
* GET request
|
|
1629
|
-
*/
|
|
1630
|
-
async get(endpoint) {
|
|
1631
|
-
const response = await fetch(`${API_BASE_URL}${endpoint}`, {
|
|
1632
|
-
method: "GET",
|
|
1633
|
-
headers: getHeaders()
|
|
1634
|
-
});
|
|
1635
|
-
return handleResponse(response);
|
|
1636
|
-
},
|
|
1637
|
-
/**
|
|
1638
|
-
* POST request
|
|
1639
|
-
*/
|
|
1640
|
-
async post(endpoint, data) {
|
|
1641
|
-
const response = await fetch(`${API_BASE_URL}${endpoint}`, {
|
|
1642
|
-
method: "POST",
|
|
1643
|
-
headers: getHeaders(),
|
|
1644
|
-
body: data ? JSON.stringify(data) : void 0
|
|
1645
|
-
});
|
|
1646
|
-
return handleResponse(response);
|
|
1647
|
-
},
|
|
1648
|
-
/**
|
|
1649
|
-
* PUT request
|
|
1650
|
-
*/
|
|
1651
|
-
async put(endpoint, data) {
|
|
1652
|
-
const response = await fetch(`${API_BASE_URL}${endpoint}`, {
|
|
1653
|
-
method: "PUT",
|
|
1654
|
-
headers: getHeaders(),
|
|
1655
|
-
body: data ? JSON.stringify(data) : void 0
|
|
1656
|
-
});
|
|
1657
|
-
return handleResponse(response);
|
|
1658
|
-
},
|
|
1659
|
-
/**
|
|
1660
|
-
* PATCH request
|
|
1661
|
-
*/
|
|
1662
|
-
async patch(endpoint, data) {
|
|
1663
|
-
const response = await fetch(`${API_BASE_URL}${endpoint}`, {
|
|
1664
|
-
method: "PATCH",
|
|
1665
|
-
headers: getHeaders(),
|
|
1666
|
-
body: data ? JSON.stringify(data) : void 0
|
|
1667
|
-
});
|
|
1668
|
-
return handleResponse(response);
|
|
1669
|
-
},
|
|
1670
|
-
/**
|
|
1671
|
-
* DELETE request
|
|
1672
|
-
*/
|
|
1673
|
-
async delete(endpoint) {
|
|
1674
|
-
const response = await fetch(`${API_BASE_URL}${endpoint}`, {
|
|
1675
|
-
method: "DELETE",
|
|
1676
|
-
headers: getHeaders()
|
|
1677
|
-
});
|
|
1678
|
-
return handleResponse(response);
|
|
1679
|
-
}
|
|
1680
|
-
};
|
|
1681
|
-
var ENTITY_EVENTS = {
|
|
1682
|
-
CREATE: "ENTITY_CREATE",
|
|
1683
|
-
UPDATE: "ENTITY_UPDATE",
|
|
1684
|
-
DELETE: "ENTITY_DELETE"
|
|
1685
|
-
};
|
|
1686
|
-
async function sendOrbitalEvent(orbitalName, eventPayload) {
|
|
1687
|
-
const response = await apiClient.post(
|
|
1688
|
-
`/orbitals/${orbitalName}/events`,
|
|
1689
|
-
eventPayload
|
|
1690
|
-
);
|
|
1691
|
-
return response;
|
|
1692
|
-
}
|
|
1693
|
-
function useOrbitalMutations(entityName, orbitalName, options) {
|
|
1694
|
-
const queryClient = reactQuery.useQueryClient();
|
|
1695
|
-
const events = {
|
|
1696
|
-
create: options?.events?.create || ENTITY_EVENTS.CREATE,
|
|
1697
|
-
update: options?.events?.update || ENTITY_EVENTS.UPDATE,
|
|
1698
|
-
delete: options?.events?.delete || ENTITY_EVENTS.DELETE
|
|
1699
|
-
};
|
|
1700
|
-
const log2 = (message, data) => {
|
|
1701
|
-
if (options?.debug) {
|
|
1702
|
-
console.log(`[useOrbitalMutations:${orbitalName}] ${message}`, data ?? "");
|
|
1703
|
-
}
|
|
1704
|
-
};
|
|
1705
|
-
const createMutation = reactQuery.useMutation({
|
|
1706
|
-
mutationFn: async (data) => {
|
|
1707
|
-
log2("Creating entity", data);
|
|
1708
|
-
return sendOrbitalEvent(orbitalName, {
|
|
1709
|
-
event: events.create,
|
|
1710
|
-
payload: { data, entityType: entityName }
|
|
1711
|
-
});
|
|
1712
|
-
},
|
|
1713
|
-
onSuccess: (response) => {
|
|
1714
|
-
log2("Create succeeded", response);
|
|
1715
|
-
queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
|
|
1716
|
-
},
|
|
1717
|
-
onError: (error) => {
|
|
1718
|
-
console.error(`[useOrbitalMutations] Create failed:`, error);
|
|
1719
|
-
}
|
|
1720
|
-
});
|
|
1721
|
-
const updateMutation = reactQuery.useMutation({
|
|
1722
|
-
mutationFn: async ({
|
|
1723
|
-
id,
|
|
1724
|
-
data
|
|
1725
|
-
}) => {
|
|
1726
|
-
log2(`Updating entity ${id}`, data);
|
|
1727
|
-
return sendOrbitalEvent(orbitalName, {
|
|
1728
|
-
event: events.update,
|
|
1729
|
-
entityId: id,
|
|
1730
|
-
payload: { data, entityType: entityName }
|
|
1731
|
-
});
|
|
1732
|
-
},
|
|
1733
|
-
onSuccess: (response, variables) => {
|
|
1734
|
-
log2("Update succeeded", response);
|
|
1735
|
-
queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
|
|
1736
|
-
queryClient.invalidateQueries({
|
|
1737
|
-
queryKey: entityDataKeys.detail(entityName, variables.id)
|
|
1738
|
-
});
|
|
1739
|
-
},
|
|
1740
|
-
onError: (error) => {
|
|
1741
|
-
console.error(`[useOrbitalMutations] Update failed:`, error);
|
|
1742
|
-
}
|
|
1743
|
-
});
|
|
1744
|
-
const deleteMutation = reactQuery.useMutation({
|
|
1745
|
-
mutationFn: async (id) => {
|
|
1746
|
-
log2(`Deleting entity ${id}`);
|
|
1747
|
-
return sendOrbitalEvent(orbitalName, {
|
|
1748
|
-
event: events.delete,
|
|
1749
|
-
entityId: id,
|
|
1750
|
-
payload: { entityType: entityName }
|
|
1751
|
-
});
|
|
1752
|
-
},
|
|
1753
|
-
onSuccess: (response, id) => {
|
|
1754
|
-
log2("Delete succeeded", response);
|
|
1755
|
-
queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
|
|
1756
|
-
queryClient.removeQueries({ queryKey: entityDataKeys.detail(entityName, id) });
|
|
1757
|
-
},
|
|
1758
|
-
onError: (error) => {
|
|
1759
|
-
console.error(`[useOrbitalMutations] Delete failed:`, error);
|
|
1760
|
-
}
|
|
1761
|
-
});
|
|
1762
|
-
return {
|
|
1763
|
-
// Async functions
|
|
1764
|
-
createEntity: async (data) => {
|
|
1765
|
-
return createMutation.mutateAsync(data);
|
|
1766
|
-
},
|
|
1767
|
-
updateEntity: async (id, data) => {
|
|
1768
|
-
if (!id) {
|
|
1769
|
-
console.warn("[useOrbitalMutations] Cannot update without ID");
|
|
1770
|
-
return;
|
|
1771
|
-
}
|
|
1772
|
-
return updateMutation.mutateAsync({ id, data });
|
|
1773
|
-
},
|
|
1774
|
-
deleteEntity: async (id) => {
|
|
1775
|
-
if (!id) {
|
|
1776
|
-
console.warn("[useOrbitalMutations] Cannot delete without ID");
|
|
1777
|
-
return;
|
|
1778
|
-
}
|
|
1779
|
-
return deleteMutation.mutateAsync(id);
|
|
1780
|
-
},
|
|
1781
|
-
// Mutation objects for fine-grained control
|
|
1782
|
-
createMutation,
|
|
1783
|
-
updateMutation,
|
|
1784
|
-
deleteMutation,
|
|
1785
|
-
// Aggregate states
|
|
1786
|
-
isCreating: createMutation.isPending,
|
|
1787
|
-
isUpdating: updateMutation.isPending,
|
|
1788
|
-
isDeleting: deleteMutation.isPending,
|
|
1789
|
-
isMutating: createMutation.isPending || updateMutation.isPending || deleteMutation.isPending,
|
|
1790
|
-
// Errors
|
|
1791
|
-
createError: createMutation.error,
|
|
1792
|
-
updateError: updateMutation.error,
|
|
1793
|
-
deleteError: deleteMutation.error
|
|
1794
|
-
};
|
|
1795
|
-
}
|
|
1796
|
-
function useSendOrbitalEvent(orbitalName) {
|
|
1797
|
-
const mutation = reactQuery.useMutation({
|
|
1798
|
-
mutationFn: async (payload) => {
|
|
1799
|
-
return sendOrbitalEvent(orbitalName, payload);
|
|
1800
|
-
}
|
|
1801
|
-
});
|
|
1802
|
-
return {
|
|
1803
|
-
sendEvent: async (event, payload, entityId) => {
|
|
1804
|
-
return mutation.mutateAsync({ event, payload, entityId });
|
|
1805
|
-
},
|
|
1806
|
-
isPending: mutation.isPending,
|
|
1807
|
-
error: mutation.error,
|
|
1808
|
-
data: mutation.data
|
|
1809
|
-
};
|
|
1810
|
-
}
|
|
1811
|
-
|
|
1812
|
-
// hooks/useEntityMutations.ts
|
|
1813
|
-
function entityToCollection(entityName) {
|
|
1814
|
-
return entityName.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase() + "-list";
|
|
1815
|
-
}
|
|
1816
|
-
function useCreateEntity(entityName) {
|
|
1817
|
-
const queryClient = reactQuery.useQueryClient();
|
|
1818
|
-
const collection = entityToCollection(entityName);
|
|
1819
|
-
return reactQuery.useMutation({
|
|
1820
|
-
mutationFn: async (data) => {
|
|
1821
|
-
console.log(`[useCreateEntity] Creating ${entityName}:`, data);
|
|
1822
|
-
const response = await apiClient.post(
|
|
1823
|
-
`/${collection}`,
|
|
1824
|
-
data
|
|
1825
|
-
);
|
|
1826
|
-
return response.data;
|
|
1827
|
-
},
|
|
1828
|
-
onSuccess: () => {
|
|
1829
|
-
queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
|
|
1830
|
-
},
|
|
1831
|
-
onError: (error) => {
|
|
1832
|
-
console.error(`[useCreateEntity] Failed to create ${entityName}:`, error);
|
|
1833
|
-
}
|
|
1834
|
-
});
|
|
1835
|
-
}
|
|
1836
|
-
function useUpdateEntity(entityName) {
|
|
1837
|
-
const queryClient = reactQuery.useQueryClient();
|
|
1838
|
-
const collection = entityToCollection(entityName);
|
|
1839
|
-
return reactQuery.useMutation({
|
|
1840
|
-
mutationFn: async ({ id, data }) => {
|
|
1841
|
-
console.log(`[useUpdateEntity] Updating ${entityName} ${id}:`, data);
|
|
1842
|
-
const response = await apiClient.patch(
|
|
1843
|
-
`/${collection}/${id}`,
|
|
1844
|
-
data
|
|
1845
|
-
);
|
|
1846
|
-
return response.data;
|
|
1847
|
-
},
|
|
1848
|
-
onSuccess: (_, variables) => {
|
|
1849
|
-
queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
|
|
1850
|
-
queryClient.invalidateQueries({ queryKey: entityDataKeys.detail(entityName, variables.id) });
|
|
1851
|
-
},
|
|
1852
|
-
onError: (error) => {
|
|
1853
|
-
console.error(`[useUpdateEntity] Failed to update ${entityName}:`, error);
|
|
1854
|
-
}
|
|
1855
|
-
});
|
|
1856
|
-
}
|
|
1857
|
-
function useDeleteEntity(entityName) {
|
|
1858
|
-
const queryClient = reactQuery.useQueryClient();
|
|
1859
|
-
const collection = entityToCollection(entityName);
|
|
1860
|
-
return reactQuery.useMutation({
|
|
1861
|
-
mutationFn: async (id) => {
|
|
1862
|
-
console.log(`[useDeleteEntity] Deleting ${entityName} ${id}`);
|
|
1863
|
-
await apiClient.delete(`/${collection}/${id}`);
|
|
1864
|
-
return { id };
|
|
1865
|
-
},
|
|
1866
|
-
onSuccess: (_, id) => {
|
|
1867
|
-
queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
|
|
1868
|
-
queryClient.removeQueries({ queryKey: entityDataKeys.detail(entityName, id) });
|
|
1869
|
-
},
|
|
1870
|
-
onError: (error) => {
|
|
1871
|
-
console.error(`[useDeleteEntity] Failed to delete ${entityName}:`, error);
|
|
1872
|
-
}
|
|
1873
|
-
});
|
|
1874
|
-
}
|
|
1875
|
-
async function sendOrbitalMutation(orbitalName, event, entityId, payload) {
|
|
1876
|
-
const response = await apiClient.post(
|
|
1877
|
-
`/orbitals/${orbitalName}/events`,
|
|
1878
|
-
{ event, entityId, payload }
|
|
1879
|
-
);
|
|
1880
|
-
return response;
|
|
1881
|
-
}
|
|
1882
|
-
function useEntityMutations(entityName, options) {
|
|
1883
|
-
const queryClient = reactQuery.useQueryClient();
|
|
1884
|
-
const useOrbitalRoute = !!options?.orbitalName;
|
|
1885
|
-
const events = {
|
|
1886
|
-
create: options?.events?.create || ENTITY_EVENTS.CREATE,
|
|
1887
|
-
update: options?.events?.update || ENTITY_EVENTS.UPDATE,
|
|
1888
|
-
delete: options?.events?.delete || ENTITY_EVENTS.DELETE
|
|
1889
|
-
};
|
|
1890
|
-
const createMutation = useCreateEntity(entityName);
|
|
1891
|
-
const updateMutation = useUpdateEntity(entityName);
|
|
1892
|
-
const deleteMutation = useDeleteEntity(entityName);
|
|
1893
|
-
const orbitalCreateMutation = reactQuery.useMutation({
|
|
1894
|
-
mutationFn: async (data) => {
|
|
1895
|
-
return sendOrbitalMutation(options.orbitalName, events.create, void 0, {
|
|
1896
|
-
data,
|
|
1897
|
-
entityType: entityName
|
|
1898
|
-
});
|
|
1899
|
-
},
|
|
1900
|
-
onSuccess: () => {
|
|
1901
|
-
queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
|
|
1902
|
-
}
|
|
1903
|
-
});
|
|
1904
|
-
const orbitalUpdateMutation = reactQuery.useMutation({
|
|
1905
|
-
mutationFn: async ({ id, data }) => {
|
|
1906
|
-
return sendOrbitalMutation(options.orbitalName, events.update, id, {
|
|
1907
|
-
data,
|
|
1908
|
-
entityType: entityName
|
|
1909
|
-
});
|
|
1910
|
-
},
|
|
1911
|
-
onSuccess: (_, variables) => {
|
|
1912
|
-
queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
|
|
1913
|
-
queryClient.invalidateQueries({
|
|
1914
|
-
queryKey: entityDataKeys.detail(entityName, variables.id)
|
|
1915
|
-
});
|
|
1916
|
-
}
|
|
1917
|
-
});
|
|
1918
|
-
const orbitalDeleteMutation = reactQuery.useMutation({
|
|
1919
|
-
mutationFn: async (id) => {
|
|
1920
|
-
return sendOrbitalMutation(options.orbitalName, events.delete, id, {
|
|
1921
|
-
entityType: entityName
|
|
1922
|
-
});
|
|
1923
|
-
},
|
|
1924
|
-
onSuccess: (_, id) => {
|
|
1925
|
-
queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
|
|
1926
|
-
queryClient.removeQueries({ queryKey: entityDataKeys.detail(entityName, id) });
|
|
1927
|
-
}
|
|
1928
|
-
});
|
|
1929
|
-
const activeMutations = {
|
|
1930
|
-
create: useOrbitalRoute ? orbitalCreateMutation : createMutation,
|
|
1931
|
-
update: useOrbitalRoute ? orbitalUpdateMutation : updateMutation,
|
|
1932
|
-
delete: useOrbitalRoute ? orbitalDeleteMutation : deleteMutation
|
|
1933
|
-
};
|
|
1934
|
-
return {
|
|
1935
|
-
// Async functions that can be called directly
|
|
1936
|
-
// Accepts either (data) or (entityName, data) for compiler compatibility
|
|
1937
|
-
createEntity: async (entityOrData, data) => {
|
|
1938
|
-
const actualData = typeof entityOrData === "string" ? data : entityOrData;
|
|
1939
|
-
if (!actualData) {
|
|
1940
|
-
console.warn("[useEntityMutations] Cannot create entity without data");
|
|
1941
|
-
return;
|
|
1942
|
-
}
|
|
1943
|
-
return activeMutations.create.mutateAsync(actualData);
|
|
1944
|
-
},
|
|
1945
|
-
updateEntity: async (id, data) => {
|
|
1946
|
-
if (!id) {
|
|
1947
|
-
console.warn("[useEntityMutations] Cannot update entity without ID");
|
|
1948
|
-
return;
|
|
1949
|
-
}
|
|
1950
|
-
return activeMutations.update.mutateAsync({ id, data });
|
|
1951
|
-
},
|
|
1952
|
-
deleteEntity: async (id) => {
|
|
1953
|
-
if (!id) {
|
|
1954
|
-
console.warn("[useEntityMutations] Cannot delete entity without ID");
|
|
1955
|
-
return;
|
|
1956
|
-
}
|
|
1957
|
-
return activeMutations.delete.mutateAsync(id);
|
|
1958
|
-
},
|
|
1959
|
-
// Mutation states for UI feedback
|
|
1960
|
-
isCreating: activeMutations.create.isPending,
|
|
1961
|
-
isUpdating: activeMutations.update.isPending,
|
|
1962
|
-
isDeleting: activeMutations.delete.isPending,
|
|
1963
|
-
createError: activeMutations.create.error,
|
|
1964
|
-
updateError: activeMutations.update.error,
|
|
1965
|
-
deleteError: activeMutations.delete.error
|
|
1966
|
-
};
|
|
1967
|
-
}
|
|
1968
|
-
|
|
1969
1381
|
// stores/entityStore.ts
|
|
1970
1382
|
var entities = /* @__PURE__ */ new Map();
|
|
1971
1383
|
var listeners = /* @__PURE__ */ new Set();
|
|
@@ -2029,7 +1441,7 @@ function getSnapshot() {
|
|
|
2029
1441
|
|
|
2030
1442
|
// hooks/useEntities.ts
|
|
2031
1443
|
function useEntities() {
|
|
2032
|
-
const entities2 =
|
|
1444
|
+
const entities2 = react.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
2033
1445
|
return {
|
|
2034
1446
|
entities: entities2,
|
|
2035
1447
|
getEntity,
|
|
@@ -2043,35 +1455,35 @@ function useEntities() {
|
|
|
2043
1455
|
clearEntities
|
|
2044
1456
|
};
|
|
2045
1457
|
}
|
|
2046
|
-
function
|
|
2047
|
-
const entities2 =
|
|
1458
|
+
function useEntity(id) {
|
|
1459
|
+
const entities2 = react.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
2048
1460
|
return entities2.get(id);
|
|
2049
1461
|
}
|
|
2050
1462
|
function useEntitiesByType(type) {
|
|
2051
|
-
const entities2 =
|
|
1463
|
+
const entities2 = react.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
2052
1464
|
return [...entities2.values()].filter((e) => e.type === type);
|
|
2053
1465
|
}
|
|
2054
1466
|
function useSingletonEntity(type) {
|
|
2055
|
-
const entities2 =
|
|
1467
|
+
const entities2 = react.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
2056
1468
|
return [...entities2.values()].find((e) => e.type === type);
|
|
2057
1469
|
}
|
|
2058
1470
|
function usePlayer() {
|
|
2059
1471
|
const player = useSingletonEntity("Player");
|
|
2060
|
-
const update =
|
|
1472
|
+
const update = react.useCallback((updates) => {
|
|
2061
1473
|
if (player) updateEntity(player.id, updates);
|
|
2062
1474
|
}, [player?.id]);
|
|
2063
1475
|
return { player, updatePlayer: update };
|
|
2064
1476
|
}
|
|
2065
1477
|
function usePhysics() {
|
|
2066
1478
|
const physics = useSingletonEntity("Physics");
|
|
2067
|
-
const update =
|
|
1479
|
+
const update = react.useCallback((updates) => {
|
|
2068
1480
|
if (physics) updateEntity(physics.id, updates);
|
|
2069
1481
|
}, [physics?.id]);
|
|
2070
1482
|
return { physics, updatePhysics: update };
|
|
2071
1483
|
}
|
|
2072
1484
|
function useInput() {
|
|
2073
1485
|
const input = useSingletonEntity("Input");
|
|
2074
|
-
const update =
|
|
1486
|
+
const update = react.useCallback((updates) => {
|
|
2075
1487
|
if (input) updateEntity(input.id, updates);
|
|
2076
1488
|
}, [input?.id]);
|
|
2077
1489
|
return { input, updateInput: update };
|
|
@@ -2186,7 +1598,7 @@ var en_default = {
|
|
|
2186
1598
|
// hooks/useTranslate.ts
|
|
2187
1599
|
var { $meta: _meta, ...coreMessages } = en_default;
|
|
2188
1600
|
var coreLocale = coreMessages;
|
|
2189
|
-
var I18nContext =
|
|
1601
|
+
var I18nContext = react.createContext({
|
|
2190
1602
|
locale: "en",
|
|
2191
1603
|
direction: "ltr",
|
|
2192
1604
|
t: (key) => coreLocale[key] ?? key
|
|
@@ -2195,7 +1607,7 @@ var I18nContext = React.createContext({
|
|
|
2195
1607
|
I18nContext.displayName = "I18nContext";
|
|
2196
1608
|
var I18nProvider = I18nContext.Provider;
|
|
2197
1609
|
function useTranslate() {
|
|
2198
|
-
return
|
|
1610
|
+
return react.useContext(I18nContext);
|
|
2199
1611
|
}
|
|
2200
1612
|
function createTranslate(messages) {
|
|
2201
1613
|
return (key, params) => {
|
|
@@ -2208,26 +1620,6 @@ function createTranslate(messages) {
|
|
|
2208
1620
|
return msg;
|
|
2209
1621
|
};
|
|
2210
1622
|
}
|
|
2211
|
-
function useResolvedEntity(entity, data) {
|
|
2212
|
-
const shouldFetch = !data && !!entity;
|
|
2213
|
-
const fetched = useEntityList(entity, { skip: !shouldFetch });
|
|
2214
|
-
return React.useMemo(() => {
|
|
2215
|
-
if (data) {
|
|
2216
|
-
return {
|
|
2217
|
-
data,
|
|
2218
|
-
isLocal: true,
|
|
2219
|
-
isLoading: false,
|
|
2220
|
-
error: null
|
|
2221
|
-
};
|
|
2222
|
-
}
|
|
2223
|
-
return {
|
|
2224
|
-
data: fetched.data,
|
|
2225
|
-
isLocal: false,
|
|
2226
|
-
isLoading: fetched.isLoading,
|
|
2227
|
-
error: fetched.error
|
|
2228
|
-
};
|
|
2229
|
-
}, [data, fetched.data, fetched.isLoading, fetched.error]);
|
|
2230
|
-
}
|
|
2231
1623
|
|
|
2232
1624
|
// hooks/useAuthContext.ts
|
|
2233
1625
|
function useAuthContext() {
|
|
@@ -2240,14 +1632,14 @@ function useAuthContext() {
|
|
|
2240
1632
|
}
|
|
2241
1633
|
function useSwipeGesture(callbacks, options = {}) {
|
|
2242
1634
|
const { threshold = 50, velocityThreshold = 0.3, preventDefault = false } = options;
|
|
2243
|
-
const startX =
|
|
2244
|
-
const startY =
|
|
2245
|
-
const startTime =
|
|
2246
|
-
const currentX =
|
|
2247
|
-
const tracking =
|
|
2248
|
-
const offsetXRef =
|
|
2249
|
-
const isSwipingRef =
|
|
2250
|
-
const onPointerDown =
|
|
1635
|
+
const startX = react.useRef(0);
|
|
1636
|
+
const startY = react.useRef(0);
|
|
1637
|
+
const startTime = react.useRef(0);
|
|
1638
|
+
const currentX = react.useRef(0);
|
|
1639
|
+
const tracking = react.useRef(false);
|
|
1640
|
+
const offsetXRef = react.useRef(0);
|
|
1641
|
+
const isSwipingRef = react.useRef(false);
|
|
1642
|
+
const onPointerDown = react.useCallback((e) => {
|
|
2251
1643
|
startX.current = e.clientX;
|
|
2252
1644
|
startY.current = e.clientY;
|
|
2253
1645
|
currentX.current = e.clientX;
|
|
@@ -2257,7 +1649,7 @@ function useSwipeGesture(callbacks, options = {}) {
|
|
|
2257
1649
|
offsetXRef.current = 0;
|
|
2258
1650
|
e.target.setPointerCapture?.(e.pointerId);
|
|
2259
1651
|
}, []);
|
|
2260
|
-
const onPointerMove =
|
|
1652
|
+
const onPointerMove = react.useCallback((e) => {
|
|
2261
1653
|
if (!tracking.current) return;
|
|
2262
1654
|
if (preventDefault) e.preventDefault();
|
|
2263
1655
|
currentX.current = e.clientX;
|
|
@@ -2268,7 +1660,7 @@ function useSwipeGesture(callbacks, options = {}) {
|
|
|
2268
1660
|
offsetXRef.current = dx;
|
|
2269
1661
|
}
|
|
2270
1662
|
}, [preventDefault]);
|
|
2271
|
-
const onPointerUp =
|
|
1663
|
+
const onPointerUp = react.useCallback((e) => {
|
|
2272
1664
|
if (!tracking.current) return;
|
|
2273
1665
|
tracking.current = false;
|
|
2274
1666
|
const dx = e.clientX - startX.current;
|
|
@@ -2286,7 +1678,7 @@ function useSwipeGesture(callbacks, options = {}) {
|
|
|
2286
1678
|
else if (dy > threshold) callbacks.onSwipeDown?.();
|
|
2287
1679
|
}
|
|
2288
1680
|
}, [threshold, velocityThreshold, callbacks]);
|
|
2289
|
-
const onPointerCancel =
|
|
1681
|
+
const onPointerCancel = react.useCallback(() => {
|
|
2290
1682
|
tracking.current = false;
|
|
2291
1683
|
offsetXRef.current = 0;
|
|
2292
1684
|
isSwipingRef.current = false;
|
|
@@ -2302,18 +1694,18 @@ function useSwipeGesture(callbacks, options = {}) {
|
|
|
2302
1694
|
}
|
|
2303
1695
|
function useLongPress(onLongPress, options = {}) {
|
|
2304
1696
|
const { duration = 500, moveThreshold = 10 } = options;
|
|
2305
|
-
const timerRef =
|
|
2306
|
-
const startPos =
|
|
2307
|
-
const isPressedRef =
|
|
2308
|
-
const firedRef =
|
|
2309
|
-
const cancel =
|
|
1697
|
+
const timerRef = react.useRef(null);
|
|
1698
|
+
const startPos = react.useRef({ x: 0, y: 0 });
|
|
1699
|
+
const isPressedRef = react.useRef(false);
|
|
1700
|
+
const firedRef = react.useRef(false);
|
|
1701
|
+
const cancel = react.useCallback(() => {
|
|
2310
1702
|
if (timerRef.current) {
|
|
2311
1703
|
clearTimeout(timerRef.current);
|
|
2312
1704
|
timerRef.current = null;
|
|
2313
1705
|
}
|
|
2314
1706
|
isPressedRef.current = false;
|
|
2315
1707
|
}, []);
|
|
2316
|
-
const onPointerDown =
|
|
1708
|
+
const onPointerDown = react.useCallback((e) => {
|
|
2317
1709
|
firedRef.current = false;
|
|
2318
1710
|
startPos.current = { x: e.clientX, y: e.clientY };
|
|
2319
1711
|
isPressedRef.current = true;
|
|
@@ -2323,7 +1715,7 @@ function useLongPress(onLongPress, options = {}) {
|
|
|
2323
1715
|
onLongPress();
|
|
2324
1716
|
}, duration);
|
|
2325
1717
|
}, [duration, onLongPress]);
|
|
2326
|
-
const onPointerMove =
|
|
1718
|
+
const onPointerMove = react.useCallback((e) => {
|
|
2327
1719
|
if (!isPressedRef.current) return;
|
|
2328
1720
|
const dx = e.clientX - startPos.current.x;
|
|
2329
1721
|
const dy = e.clientY - startPos.current.y;
|
|
@@ -2331,10 +1723,10 @@ function useLongPress(onLongPress, options = {}) {
|
|
|
2331
1723
|
cancel();
|
|
2332
1724
|
}
|
|
2333
1725
|
}, [moveThreshold, cancel]);
|
|
2334
|
-
const onPointerUp =
|
|
1726
|
+
const onPointerUp = react.useCallback(() => {
|
|
2335
1727
|
cancel();
|
|
2336
1728
|
}, [cancel]);
|
|
2337
|
-
const onPointerCancel =
|
|
1729
|
+
const onPointerCancel = react.useCallback(() => {
|
|
2338
1730
|
cancel();
|
|
2339
1731
|
}, [cancel]);
|
|
2340
1732
|
return {
|
|
@@ -2346,22 +1738,22 @@ function useLongPress(onLongPress, options = {}) {
|
|
|
2346
1738
|
};
|
|
2347
1739
|
}
|
|
2348
1740
|
function useDragReorder(initialItems, onReorder) {
|
|
2349
|
-
const [items, setItems] =
|
|
2350
|
-
const [dragIndex, setDragIndex] =
|
|
2351
|
-
const [dragOverIndex, setDragOverIndex] =
|
|
2352
|
-
const itemsRef =
|
|
1741
|
+
const [items, setItems] = react.useState(initialItems);
|
|
1742
|
+
const [dragIndex, setDragIndex] = react.useState(-1);
|
|
1743
|
+
const [dragOverIndex, setDragOverIndex] = react.useState(-1);
|
|
1744
|
+
const itemsRef = react.useRef(initialItems);
|
|
2353
1745
|
if (initialItems !== itemsRef.current) {
|
|
2354
1746
|
itemsRef.current = initialItems;
|
|
2355
1747
|
setItems(initialItems);
|
|
2356
1748
|
}
|
|
2357
1749
|
const isDragging = dragIndex >= 0;
|
|
2358
|
-
const handleDragStart =
|
|
1750
|
+
const handleDragStart = react.useCallback((index) => (e) => {
|
|
2359
1751
|
e.preventDefault();
|
|
2360
1752
|
setDragIndex(index);
|
|
2361
1753
|
setDragOverIndex(index);
|
|
2362
1754
|
e.target.setPointerCapture?.(e.pointerId);
|
|
2363
1755
|
}, []);
|
|
2364
|
-
const handleDragMove =
|
|
1756
|
+
const handleDragMove = react.useCallback((index) => (e) => {
|
|
2365
1757
|
if (dragIndex < 0) return;
|
|
2366
1758
|
const target = document.elementFromPoint(e.clientX, e.clientY);
|
|
2367
1759
|
if (!target) return;
|
|
@@ -2376,7 +1768,7 @@ function useDragReorder(initialItems, onReorder) {
|
|
|
2376
1768
|
}
|
|
2377
1769
|
}
|
|
2378
1770
|
}, [dragIndex, dragOverIndex]);
|
|
2379
|
-
const handleDragEnd =
|
|
1771
|
+
const handleDragEnd = react.useCallback(() => {
|
|
2380
1772
|
if (dragIndex >= 0 && dragOverIndex >= 0 && dragIndex !== dragOverIndex) {
|
|
2381
1773
|
const newItems = [...items];
|
|
2382
1774
|
const [movedItem] = newItems.splice(dragIndex, 1);
|
|
@@ -2387,13 +1779,13 @@ function useDragReorder(initialItems, onReorder) {
|
|
|
2387
1779
|
setDragIndex(-1);
|
|
2388
1780
|
setDragOverIndex(-1);
|
|
2389
1781
|
}, [dragIndex, dragOverIndex, items, onReorder]);
|
|
2390
|
-
const getDragHandleProps =
|
|
1782
|
+
const getDragHandleProps = react.useCallback((index) => ({
|
|
2391
1783
|
onPointerDown: handleDragStart(index),
|
|
2392
1784
|
style: { cursor: "grab", touchAction: "none" },
|
|
2393
1785
|
"aria-grabbed": dragIndex === index,
|
|
2394
1786
|
role: "button"
|
|
2395
1787
|
}), [handleDragStart, dragIndex]);
|
|
2396
|
-
const getItemProps =
|
|
1788
|
+
const getItemProps = react.useCallback((index) => ({
|
|
2397
1789
|
onPointerMove: handleDragMove(index),
|
|
2398
1790
|
onPointerUp: handleDragEnd,
|
|
2399
1791
|
"aria-dropeffect": "move",
|
|
@@ -2415,19 +1807,19 @@ function useDragReorder(initialItems, onReorder) {
|
|
|
2415
1807
|
}
|
|
2416
1808
|
function useInfiniteScroll(onLoadMore, options = {}) {
|
|
2417
1809
|
const { rootMargin = "200px", hasMore = true, isLoading = false } = options;
|
|
2418
|
-
const observerRef =
|
|
2419
|
-
const callbackRef =
|
|
1810
|
+
const observerRef = react.useRef(null);
|
|
1811
|
+
const callbackRef = react.useRef(onLoadMore);
|
|
2420
1812
|
callbackRef.current = onLoadMore;
|
|
2421
|
-
const hasMoreRef =
|
|
1813
|
+
const hasMoreRef = react.useRef(hasMore);
|
|
2422
1814
|
hasMoreRef.current = hasMore;
|
|
2423
|
-
const isLoadingRef =
|
|
1815
|
+
const isLoadingRef = react.useRef(isLoading);
|
|
2424
1816
|
isLoadingRef.current = isLoading;
|
|
2425
|
-
|
|
1817
|
+
react.useEffect(() => {
|
|
2426
1818
|
return () => {
|
|
2427
1819
|
observerRef.current?.disconnect();
|
|
2428
1820
|
};
|
|
2429
1821
|
}, []);
|
|
2430
|
-
const sentinelRef =
|
|
1822
|
+
const sentinelRef = react.useCallback((node) => {
|
|
2431
1823
|
observerRef.current?.disconnect();
|
|
2432
1824
|
if (!node) return;
|
|
2433
1825
|
observerRef.current = new IntersectionObserver(
|
|
@@ -2445,12 +1837,12 @@ function useInfiniteScroll(onLoadMore, options = {}) {
|
|
|
2445
1837
|
}
|
|
2446
1838
|
function usePullToRefresh(onRefresh, options = {}) {
|
|
2447
1839
|
const { threshold = 60, maxPull = 120 } = options;
|
|
2448
|
-
const [pullDistance, setPullDistance] =
|
|
2449
|
-
const [isPulling, setIsPulling] =
|
|
2450
|
-
const [isRefreshing, setIsRefreshing] =
|
|
2451
|
-
const startY =
|
|
2452
|
-
const scrollTopRef =
|
|
2453
|
-
const onTouchStart =
|
|
1840
|
+
const [pullDistance, setPullDistance] = react.useState(0);
|
|
1841
|
+
const [isPulling, setIsPulling] = react.useState(false);
|
|
1842
|
+
const [isRefreshing, setIsRefreshing] = react.useState(false);
|
|
1843
|
+
const startY = react.useRef(0);
|
|
1844
|
+
const scrollTopRef = react.useRef(0);
|
|
1845
|
+
const onTouchStart = react.useCallback((e) => {
|
|
2454
1846
|
const container = e.currentTarget;
|
|
2455
1847
|
scrollTopRef.current = container.scrollTop;
|
|
2456
1848
|
if (scrollTopRef.current <= 0) {
|
|
@@ -2458,7 +1850,7 @@ function usePullToRefresh(onRefresh, options = {}) {
|
|
|
2458
1850
|
setIsPulling(true);
|
|
2459
1851
|
}
|
|
2460
1852
|
}, []);
|
|
2461
|
-
const onTouchMove =
|
|
1853
|
+
const onTouchMove = react.useCallback((e) => {
|
|
2462
1854
|
if (!isPulling || isRefreshing) return;
|
|
2463
1855
|
const container = e.currentTarget;
|
|
2464
1856
|
if (container.scrollTop > 0) {
|
|
@@ -2471,7 +1863,7 @@ function usePullToRefresh(onRefresh, options = {}) {
|
|
|
2471
1863
|
setPullDistance(distance);
|
|
2472
1864
|
}
|
|
2473
1865
|
}, [isPulling, isRefreshing, maxPull]);
|
|
2474
|
-
const onTouchEnd =
|
|
1866
|
+
const onTouchEnd = react.useCallback(() => {
|
|
2475
1867
|
if (!isPulling) return;
|
|
2476
1868
|
setIsPulling(false);
|
|
2477
1869
|
if (pullDistance >= threshold && !isRefreshing) {
|
|
@@ -2482,7 +1874,7 @@ function usePullToRefresh(onRefresh, options = {}) {
|
|
|
2482
1874
|
setPullDistance(0);
|
|
2483
1875
|
}
|
|
2484
1876
|
}, [isPulling, pullDistance, threshold, isRefreshing, onRefresh]);
|
|
2485
|
-
const endRefresh =
|
|
1877
|
+
const endRefresh = react.useCallback(() => {
|
|
2486
1878
|
setIsRefreshing(false);
|
|
2487
1879
|
setPullDistance(0);
|
|
2488
1880
|
}, []);
|
|
@@ -2510,18 +1902,18 @@ function getDistance(touches) {
|
|
|
2510
1902
|
}
|
|
2511
1903
|
function usePinchZoom(options = {}) {
|
|
2512
1904
|
const { minScale = 0.5, maxScale = 4 } = options;
|
|
2513
|
-
const [scale, setScale] =
|
|
2514
|
-
const [isPinching, setIsPinching] =
|
|
2515
|
-
const initialDistance =
|
|
2516
|
-
const initialScale =
|
|
2517
|
-
const onTouchStart =
|
|
1905
|
+
const [scale, setScale] = react.useState(1);
|
|
1906
|
+
const [isPinching, setIsPinching] = react.useState(false);
|
|
1907
|
+
const initialDistance = react.useRef(0);
|
|
1908
|
+
const initialScale = react.useRef(1);
|
|
1909
|
+
const onTouchStart = react.useCallback((e) => {
|
|
2518
1910
|
if (e.touches.length === 2) {
|
|
2519
1911
|
initialDistance.current = getDistance(e.touches);
|
|
2520
1912
|
initialScale.current = scale;
|
|
2521
1913
|
setIsPinching(true);
|
|
2522
1914
|
}
|
|
2523
1915
|
}, [scale]);
|
|
2524
|
-
const onTouchMove =
|
|
1916
|
+
const onTouchMove = react.useCallback((e) => {
|
|
2525
1917
|
if (e.touches.length !== 2 || !isPinching) return;
|
|
2526
1918
|
e.preventDefault();
|
|
2527
1919
|
const currentDistance = getDistance(e.touches);
|
|
@@ -2529,10 +1921,10 @@ function usePinchZoom(options = {}) {
|
|
|
2529
1921
|
const newScale = Math.min(maxScale, Math.max(minScale, initialScale.current * ratio));
|
|
2530
1922
|
setScale(newScale);
|
|
2531
1923
|
}, [isPinching, minScale, maxScale]);
|
|
2532
|
-
const onTouchEnd =
|
|
1924
|
+
const onTouchEnd = react.useCallback(() => {
|
|
2533
1925
|
setIsPinching(false);
|
|
2534
1926
|
}, []);
|
|
2535
|
-
const resetZoom =
|
|
1927
|
+
const resetZoom = react.useCallback(() => {
|
|
2536
1928
|
setScale(1);
|
|
2537
1929
|
}, []);
|
|
2538
1930
|
return {
|
|
@@ -2548,9 +1940,9 @@ function usePinchZoom(options = {}) {
|
|
|
2548
1940
|
}
|
|
2549
1941
|
var ALMADAR_DND_MIME = "application/x-almadar-dnd";
|
|
2550
1942
|
function useDraggable({ payload, disabled = false }) {
|
|
2551
|
-
const [isDragging, setIsDragging] =
|
|
1943
|
+
const [isDragging, setIsDragging] = react.useState(false);
|
|
2552
1944
|
const eventBus = useEventBus();
|
|
2553
|
-
const handleDragStart =
|
|
1945
|
+
const handleDragStart = react.useCallback(
|
|
2554
1946
|
(e) => {
|
|
2555
1947
|
if (disabled) {
|
|
2556
1948
|
e.preventDefault();
|
|
@@ -2563,14 +1955,14 @@ function useDraggable({ payload, disabled = false }) {
|
|
|
2563
1955
|
},
|
|
2564
1956
|
[disabled, payload, eventBus]
|
|
2565
1957
|
);
|
|
2566
|
-
const handleDragEnd =
|
|
1958
|
+
const handleDragEnd = react.useCallback(
|
|
2567
1959
|
(e) => {
|
|
2568
1960
|
setIsDragging(false);
|
|
2569
1961
|
eventBus.emit("UI:DRAG_END", { kind: payload.kind, data: payload.data });
|
|
2570
1962
|
},
|
|
2571
1963
|
[payload, eventBus]
|
|
2572
1964
|
);
|
|
2573
|
-
const dragProps =
|
|
1965
|
+
const dragProps = react.useMemo(
|
|
2574
1966
|
() => ({
|
|
2575
1967
|
draggable: !disabled,
|
|
2576
1968
|
onDragStart: handleDragStart,
|
|
@@ -2596,9 +1988,9 @@ function hasAlmadarPayload(e) {
|
|
|
2596
1988
|
return e.dataTransfer.types.includes(ALMADAR_DND_MIME);
|
|
2597
1989
|
}
|
|
2598
1990
|
function useDropZone({ accepts, onDrop, disabled = false }) {
|
|
2599
|
-
const [isOver, setIsOver] =
|
|
1991
|
+
const [isOver, setIsOver] = react.useState(false);
|
|
2600
1992
|
const eventBus = useEventBus();
|
|
2601
|
-
const handleDragOver =
|
|
1993
|
+
const handleDragOver = react.useCallback(
|
|
2602
1994
|
(e) => {
|
|
2603
1995
|
if (disabled) return;
|
|
2604
1996
|
if (!hasAlmadarPayload(e)) return;
|
|
@@ -2608,13 +2000,13 @@ function useDropZone({ accepts, onDrop, disabled = false }) {
|
|
|
2608
2000
|
},
|
|
2609
2001
|
[disabled]
|
|
2610
2002
|
);
|
|
2611
|
-
const handleDragLeave =
|
|
2003
|
+
const handleDragLeave = react.useCallback(
|
|
2612
2004
|
(e) => {
|
|
2613
2005
|
setIsOver(false);
|
|
2614
2006
|
},
|
|
2615
2007
|
[]
|
|
2616
2008
|
);
|
|
2617
|
-
const handleDrop =
|
|
2009
|
+
const handleDrop = react.useCallback(
|
|
2618
2010
|
(e) => {
|
|
2619
2011
|
e.preventDefault();
|
|
2620
2012
|
setIsOver(false);
|
|
@@ -2628,7 +2020,7 @@ function useDropZone({ accepts, onDrop, disabled = false }) {
|
|
|
2628
2020
|
},
|
|
2629
2021
|
[disabled, accepts, onDrop, eventBus]
|
|
2630
2022
|
);
|
|
2631
|
-
const dropProps =
|
|
2023
|
+
const dropProps = react.useMemo(
|
|
2632
2024
|
() => ({
|
|
2633
2025
|
onDragOver: handleDragOver,
|
|
2634
2026
|
onDragLeave: handleDragLeave,
|
|
@@ -2668,7 +2060,7 @@ function useGitHubStatus() {
|
|
|
2668
2060
|
});
|
|
2669
2061
|
}
|
|
2670
2062
|
function useConnectGitHub() {
|
|
2671
|
-
const connectGitHub =
|
|
2063
|
+
const connectGitHub = react.useCallback(() => {
|
|
2672
2064
|
const userId = getUserId();
|
|
2673
2065
|
const state = btoa(JSON.stringify({ userId, returnUrl: window.location.href }));
|
|
2674
2066
|
window.location.href = `${API_BASE}/api/github/oauth/authorize?state=${state}`;
|
|
@@ -2716,12 +2108,9 @@ function useGitHubBranches(owner, repo, enabled = true) {
|
|
|
2716
2108
|
|
|
2717
2109
|
exports.ALMADAR_DND_MIME = ALMADAR_DND_MIME;
|
|
2718
2110
|
exports.DEFAULT_SLOTS = DEFAULT_SLOTS;
|
|
2719
|
-
exports.ENTITY_EVENTS = ENTITY_EVENTS;
|
|
2720
|
-
exports.EntityDataProvider = EntityDataProvider;
|
|
2721
2111
|
exports.I18nProvider = I18nProvider;
|
|
2722
2112
|
exports.clearEntities = clearEntities;
|
|
2723
2113
|
exports.createTranslate = createTranslate;
|
|
2724
|
-
exports.entityDataKeys = entityDataKeys;
|
|
2725
2114
|
exports.getAllEntities = getAllEntities;
|
|
2726
2115
|
exports.getByType = getByType;
|
|
2727
2116
|
exports.getEntity = getEntity;
|
|
@@ -2735,9 +2124,7 @@ exports.useAgentChat = useAgentChat;
|
|
|
2735
2124
|
exports.useAuthContext = useAuthContext;
|
|
2736
2125
|
exports.useCompile = useCompile;
|
|
2737
2126
|
exports.useConnectGitHub = useConnectGitHub;
|
|
2738
|
-
exports.useCreateEntity = useCreateEntity;
|
|
2739
2127
|
exports.useDeepAgentGeneration = useDeepAgentGeneration;
|
|
2740
|
-
exports.useDeleteEntity = useDeleteEntity;
|
|
2741
2128
|
exports.useDisconnectGitHub = useDisconnectGitHub;
|
|
2742
2129
|
exports.useDragReorder = useDragReorder;
|
|
2743
2130
|
exports.useDraggable = useDraggable;
|
|
@@ -2745,14 +2132,7 @@ exports.useDropZone = useDropZone;
|
|
|
2745
2132
|
exports.useEmitEvent = useEmitEvent;
|
|
2746
2133
|
exports.useEntities = useEntities;
|
|
2747
2134
|
exports.useEntitiesByType = useEntitiesByType;
|
|
2748
|
-
exports.
|
|
2749
|
-
exports.useEntityById = useEntity2;
|
|
2750
|
-
exports.useEntityDataAdapter = useEntityDataAdapter;
|
|
2751
|
-
exports.useEntityDetail = useEntityDetail;
|
|
2752
|
-
exports.useEntityList = useEntityList;
|
|
2753
|
-
exports.useEntityListSuspense = useEntityListSuspense;
|
|
2754
|
-
exports.useEntityMutations = useEntityMutations;
|
|
2755
|
-
exports.useEntitySuspense = useEntitySuspense;
|
|
2135
|
+
exports.useEntityById = useEntity;
|
|
2756
2136
|
exports.useEventBus = useEventBus;
|
|
2757
2137
|
exports.useEventListener = useEventListener;
|
|
2758
2138
|
exports.useExtensions = useExtensions;
|
|
@@ -2766,20 +2146,16 @@ exports.useInfiniteScroll = useInfiniteScroll;
|
|
|
2766
2146
|
exports.useInput = useInput;
|
|
2767
2147
|
exports.useLongPress = useLongPress;
|
|
2768
2148
|
exports.useOrbitalHistory = useOrbitalHistory;
|
|
2769
|
-
exports.useOrbitalMutations = useOrbitalMutations;
|
|
2770
2149
|
exports.usePhysics = usePhysics;
|
|
2771
2150
|
exports.usePinchZoom = usePinchZoom;
|
|
2772
2151
|
exports.usePlayer = usePlayer;
|
|
2773
2152
|
exports.usePreview = usePreview;
|
|
2774
2153
|
exports.usePullToRefresh = usePullToRefresh;
|
|
2775
2154
|
exports.useQuerySingleton = useQuerySingleton;
|
|
2776
|
-
exports.useResolvedEntity = useResolvedEntity;
|
|
2777
2155
|
exports.useSelectedEntity = useSelectedEntity;
|
|
2778
|
-
exports.useSendOrbitalEvent = useSendOrbitalEvent;
|
|
2779
2156
|
exports.useSingletonEntity = useSingletonEntity;
|
|
2780
2157
|
exports.useSwipeGesture = useSwipeGesture;
|
|
2781
2158
|
exports.useTranslate = useTranslate;
|
|
2782
2159
|
exports.useUIEvents = useUIEvents;
|
|
2783
2160
|
exports.useUISlotManager = useUISlotManager;
|
|
2784
|
-
exports.useUpdateEntity = useUpdateEntity;
|
|
2785
2161
|
exports.useValidation = useValidation;
|