@almadar/ui 2.48.4 → 2.48.5
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 +117 -25
- package/dist/avl/index.js +117 -25
- package/dist/components/index.cjs +37 -177
- package/dist/components/index.js +36 -176
- package/dist/components/organisms/game/three/index.cjs +5 -14
- package/dist/components/organisms/game/three/index.js +5 -14
- package/dist/docs/index.cjs +5 -14
- package/dist/docs/index.js +5 -14
- package/dist/hooks/index.cjs +233 -246
- package/dist/hooks/index.js +8 -21
- package/dist/lib/index.cjs +5 -14
- package/dist/lib/index.js +5 -14
- package/dist/marketing/index.cjs +5 -14
- package/dist/marketing/index.js +5 -14
- package/dist/providers/index.cjs +5 -14
- package/dist/providers/index.js +5 -14
- package/dist/runtime/OrbPreview.d.ts +25 -5
- package/dist/runtime/index.cjs +1173 -1783
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +417 -1030
- package/dist/runtime/prepareSchemaForPreview.d.ts +71 -0
- package/package.json +1 -1
package/dist/hooks/index.cjs
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React = require('react');
|
|
4
4
|
var providers = require('@almadar/ui/providers');
|
|
5
|
-
require('react/jsx-runtime');
|
|
6
5
|
var reactQuery = require('@tanstack/react-query');
|
|
7
6
|
|
|
8
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
8
|
|
|
10
|
-
var
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
11
10
|
|
|
12
11
|
function useOrbitalHistory(options) {
|
|
13
12
|
const { appId, authToken, userId, onHistoryChange, onRevertSuccess } = options;
|
|
14
|
-
const getHeaders2 =
|
|
13
|
+
const getHeaders2 = React.useCallback(() => {
|
|
15
14
|
const headers = {
|
|
16
15
|
"Content-Type": "application/json"
|
|
17
16
|
};
|
|
@@ -23,11 +22,11 @@ function useOrbitalHistory(options) {
|
|
|
23
22
|
}
|
|
24
23
|
return headers;
|
|
25
24
|
}, [authToken, userId]);
|
|
26
|
-
const [timeline, setTimeline] =
|
|
27
|
-
const [currentVersion, setCurrentVersion] =
|
|
28
|
-
const [isLoading, setIsLoading] =
|
|
29
|
-
const [error, setError] =
|
|
30
|
-
const refresh =
|
|
25
|
+
const [timeline, setTimeline] = React.useState([]);
|
|
26
|
+
const [currentVersion, setCurrentVersion] = React.useState(1);
|
|
27
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
28
|
+
const [error, setError] = React.useState(null);
|
|
29
|
+
const refresh = React.useCallback(async () => {
|
|
31
30
|
if (!appId) return;
|
|
32
31
|
setIsLoading(true);
|
|
33
32
|
setError(null);
|
|
@@ -76,7 +75,7 @@ function useOrbitalHistory(options) {
|
|
|
76
75
|
setIsLoading(false);
|
|
77
76
|
}
|
|
78
77
|
}, [appId, getHeaders2]);
|
|
79
|
-
const revertToSnapshot =
|
|
78
|
+
const revertToSnapshot = React.useCallback(async (snapshotId) => {
|
|
80
79
|
if (!appId) {
|
|
81
80
|
return { success: false, error: "No app ID provided" };
|
|
82
81
|
}
|
|
@@ -110,12 +109,12 @@ function useOrbitalHistory(options) {
|
|
|
110
109
|
};
|
|
111
110
|
}
|
|
112
111
|
}, [appId, getHeaders2, refresh, onRevertSuccess]);
|
|
113
|
-
|
|
112
|
+
React.useEffect(() => {
|
|
114
113
|
if (appId && authToken && userId) {
|
|
115
114
|
refresh();
|
|
116
115
|
}
|
|
117
116
|
}, [appId, authToken, userId]);
|
|
118
|
-
|
|
117
|
+
React.useEffect(() => {
|
|
119
118
|
onHistoryChange?.(timeline);
|
|
120
119
|
}, [timeline]);
|
|
121
120
|
return {
|
|
@@ -128,15 +127,15 @@ function useOrbitalHistory(options) {
|
|
|
128
127
|
};
|
|
129
128
|
}
|
|
130
129
|
function useFileSystem() {
|
|
131
|
-
const [status, setStatus] =
|
|
132
|
-
const [error, setError] =
|
|
133
|
-
const [isLoading, setIsLoading] =
|
|
134
|
-
const [files, setFiles] =
|
|
135
|
-
const [selectedFile, setSelectedFile] =
|
|
136
|
-
const [selectedPath, setSelectedPath] =
|
|
137
|
-
const [previewUrl, setPreviewUrl] =
|
|
138
|
-
const [fileContents, setFileContents] =
|
|
139
|
-
const boot =
|
|
130
|
+
const [status, setStatus] = React.useState("idle");
|
|
131
|
+
const [error, setError] = React.useState(null);
|
|
132
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
133
|
+
const [files, setFiles] = React.useState([]);
|
|
134
|
+
const [selectedFile, setSelectedFile] = React.useState(null);
|
|
135
|
+
const [selectedPath, setSelectedPath] = React.useState(null);
|
|
136
|
+
const [previewUrl, setPreviewUrl] = React.useState(null);
|
|
137
|
+
const [fileContents, setFileContents] = React.useState(/* @__PURE__ */ new Map());
|
|
138
|
+
const boot = React.useCallback(async () => {
|
|
140
139
|
setStatus("booting");
|
|
141
140
|
setError(null);
|
|
142
141
|
setIsLoading(true);
|
|
@@ -151,7 +150,7 @@ function useFileSystem() {
|
|
|
151
150
|
setIsLoading(false);
|
|
152
151
|
}
|
|
153
152
|
}, []);
|
|
154
|
-
const mountFiles =
|
|
153
|
+
const mountFiles = React.useCallback(async (filesToMount) => {
|
|
155
154
|
setIsLoading(true);
|
|
156
155
|
try {
|
|
157
156
|
let filesArray;
|
|
@@ -209,17 +208,17 @@ function useFileSystem() {
|
|
|
209
208
|
setIsLoading(false);
|
|
210
209
|
}
|
|
211
210
|
}, []);
|
|
212
|
-
const readFile =
|
|
211
|
+
const readFile = React.useCallback(async (path) => {
|
|
213
212
|
return fileContents.get(path) || "";
|
|
214
213
|
}, [fileContents]);
|
|
215
|
-
const writeFile =
|
|
214
|
+
const writeFile = React.useCallback(async (path, content) => {
|
|
216
215
|
setFileContents((prev) => {
|
|
217
216
|
const next = new Map(prev);
|
|
218
217
|
next.set(path, content);
|
|
219
218
|
return next;
|
|
220
219
|
});
|
|
221
220
|
}, []);
|
|
222
|
-
const selectFile =
|
|
221
|
+
const selectFile = React.useCallback(async (path) => {
|
|
223
222
|
const content = fileContents.get(path) || "";
|
|
224
223
|
const ext = path.split(".").pop()?.toLowerCase() || "";
|
|
225
224
|
const languageMap = {
|
|
@@ -241,7 +240,7 @@ function useFileSystem() {
|
|
|
241
240
|
isDirty: false
|
|
242
241
|
});
|
|
243
242
|
}, [fileContents]);
|
|
244
|
-
const updateContent =
|
|
243
|
+
const updateContent = React.useCallback((pathOrContent, contentArg) => {
|
|
245
244
|
const path = contentArg !== void 0 ? pathOrContent : selectedPath;
|
|
246
245
|
const content = contentArg !== void 0 ? contentArg : pathOrContent;
|
|
247
246
|
if (!path) {
|
|
@@ -257,17 +256,17 @@ function useFileSystem() {
|
|
|
257
256
|
setSelectedFile((prev) => prev ? { ...prev, content, isDirty: true } : null);
|
|
258
257
|
}
|
|
259
258
|
}, [selectedPath]);
|
|
260
|
-
const updateSelectedContent =
|
|
259
|
+
const updateSelectedContent = React.useCallback((content) => {
|
|
261
260
|
setSelectedFile((prev) => prev ? { ...prev, content, isDirty: true } : null);
|
|
262
261
|
}, []);
|
|
263
|
-
const refreshTree =
|
|
262
|
+
const refreshTree = React.useCallback(async () => {
|
|
264
263
|
console.log("[useFileSystem] Refreshing tree");
|
|
265
264
|
}, []);
|
|
266
|
-
const runCommand =
|
|
265
|
+
const runCommand = React.useCallback(async (command) => {
|
|
267
266
|
console.log("[useFileSystem] Running command:", command);
|
|
268
267
|
return { exitCode: 0, output: "" };
|
|
269
268
|
}, []);
|
|
270
|
-
const startDevServer =
|
|
269
|
+
const startDevServer = React.useCallback(async () => {
|
|
271
270
|
console.log("[useFileSystem] Starting dev server");
|
|
272
271
|
setPreviewUrl("http://localhost:5173");
|
|
273
272
|
}, []);
|
|
@@ -304,14 +303,14 @@ var defaultManifest = {
|
|
|
304
303
|
};
|
|
305
304
|
function useExtensions(options) {
|
|
306
305
|
const { appId, loadOnMount = true } = options;
|
|
307
|
-
const [extensions, setExtensions] =
|
|
308
|
-
const [manifest] =
|
|
309
|
-
const [isLoading, setIsLoading] =
|
|
310
|
-
const [error, setError] =
|
|
311
|
-
const loadExtension =
|
|
306
|
+
const [extensions, setExtensions] = React.useState([]);
|
|
307
|
+
const [manifest] = React.useState(defaultManifest);
|
|
308
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
309
|
+
const [error, setError] = React.useState(null);
|
|
310
|
+
const loadExtension = React.useCallback(async (extensionId) => {
|
|
312
311
|
console.log("[useExtensions] Loading extension:", extensionId);
|
|
313
312
|
}, []);
|
|
314
|
-
const loadExtensions =
|
|
313
|
+
const loadExtensions = React.useCallback(async () => {
|
|
315
314
|
setIsLoading(true);
|
|
316
315
|
setError(null);
|
|
317
316
|
try {
|
|
@@ -330,7 +329,7 @@ function useExtensions(options) {
|
|
|
330
329
|
setIsLoading(false);
|
|
331
330
|
}
|
|
332
331
|
}, []);
|
|
333
|
-
const getExtensionForFile =
|
|
332
|
+
const getExtensionForFile = React.useCallback((filename) => {
|
|
334
333
|
const ext = filename.split(".").pop()?.toLowerCase();
|
|
335
334
|
if (!ext) return null;
|
|
336
335
|
const languageMap = {
|
|
@@ -348,7 +347,7 @@ function useExtensions(options) {
|
|
|
348
347
|
if (!language) return null;
|
|
349
348
|
return extensions.find((e) => e.language === language) || null;
|
|
350
349
|
}, [extensions]);
|
|
351
|
-
|
|
350
|
+
React.useEffect(() => {
|
|
352
351
|
if (!appId || !loadOnMount) return;
|
|
353
352
|
const loadExtensions2 = async () => {
|
|
354
353
|
setIsLoading(true);
|
|
@@ -383,11 +382,11 @@ function useExtensions(options) {
|
|
|
383
382
|
}
|
|
384
383
|
function useFileEditor(options) {
|
|
385
384
|
const { extensions, fileSystem, onSchemaUpdate } = options;
|
|
386
|
-
const [openFiles, setOpenFiles] =
|
|
387
|
-
const [activeFilePath, setActiveFilePath] =
|
|
388
|
-
const [isSaving, setIsSaving] =
|
|
385
|
+
const [openFiles, setOpenFiles] = React.useState([]);
|
|
386
|
+
const [activeFilePath, setActiveFilePath] = React.useState(null);
|
|
387
|
+
const [isSaving, setIsSaving] = React.useState(false);
|
|
389
388
|
const activeFile = openFiles.find((f) => f.path === activeFilePath) || null;
|
|
390
|
-
const openFile =
|
|
389
|
+
const openFile = React.useCallback(async (path) => {
|
|
391
390
|
const existing = openFiles.find((f) => f.path === path);
|
|
392
391
|
if (existing) {
|
|
393
392
|
setActiveFilePath(path);
|
|
@@ -408,24 +407,24 @@ function useFileEditor(options) {
|
|
|
408
407
|
console.error("[useFileEditor] Failed to open file:", err);
|
|
409
408
|
}
|
|
410
409
|
}, [openFiles, fileSystem, extensions]);
|
|
411
|
-
const closeFile =
|
|
410
|
+
const closeFile = React.useCallback((path) => {
|
|
412
411
|
setOpenFiles((prev) => prev.filter((f) => f.path !== path));
|
|
413
412
|
if (activeFilePath === path) {
|
|
414
413
|
const remaining = openFiles.filter((f) => f.path !== path);
|
|
415
414
|
setActiveFilePath(remaining.length > 0 ? remaining[0].path : null);
|
|
416
415
|
}
|
|
417
416
|
}, [activeFilePath, openFiles]);
|
|
418
|
-
const setActiveFile =
|
|
417
|
+
const setActiveFile = React.useCallback((path) => {
|
|
419
418
|
setActiveFilePath(path);
|
|
420
419
|
}, []);
|
|
421
|
-
const updateFileContent =
|
|
420
|
+
const updateFileContent = React.useCallback((path, content) => {
|
|
422
421
|
setOpenFiles(
|
|
423
422
|
(prev) => prev.map(
|
|
424
423
|
(f) => f.path === path ? { ...f, content, isDirty: true } : f
|
|
425
424
|
)
|
|
426
425
|
);
|
|
427
426
|
}, []);
|
|
428
|
-
const handleFileEdit =
|
|
427
|
+
const handleFileEdit = React.useCallback(async (path, content) => {
|
|
429
428
|
try {
|
|
430
429
|
await fileSystem.writeFile(path, content);
|
|
431
430
|
let action = "saved";
|
|
@@ -447,7 +446,7 @@ function useFileEditor(options) {
|
|
|
447
446
|
};
|
|
448
447
|
}
|
|
449
448
|
}, [fileSystem, onSchemaUpdate]);
|
|
450
|
-
const saveFile =
|
|
449
|
+
const saveFile = React.useCallback(async (path) => {
|
|
451
450
|
const file = openFiles.find((f) => f.path === path);
|
|
452
451
|
if (!file) return;
|
|
453
452
|
setIsSaving(true);
|
|
@@ -471,7 +470,7 @@ function useFileEditor(options) {
|
|
|
471
470
|
setIsSaving(false);
|
|
472
471
|
}
|
|
473
472
|
}, [openFiles, fileSystem, onSchemaUpdate]);
|
|
474
|
-
const saveAllFiles =
|
|
473
|
+
const saveAllFiles = React.useCallback(async () => {
|
|
475
474
|
setIsSaving(true);
|
|
476
475
|
try {
|
|
477
476
|
const dirtyFiles = openFiles.filter((f) => f.isDirty);
|
|
@@ -496,11 +495,11 @@ function useFileEditor(options) {
|
|
|
496
495
|
};
|
|
497
496
|
}
|
|
498
497
|
function useCompile() {
|
|
499
|
-
const [isCompiling, setIsCompiling] =
|
|
500
|
-
const [stage, setStage] =
|
|
501
|
-
const [lastResult, setLastResult] =
|
|
502
|
-
const [error, setError] =
|
|
503
|
-
const compileSchema =
|
|
498
|
+
const [isCompiling, setIsCompiling] = React.useState(false);
|
|
499
|
+
const [stage, setStage] = React.useState("idle");
|
|
500
|
+
const [lastResult, setLastResult] = React.useState(null);
|
|
501
|
+
const [error, setError] = React.useState(null);
|
|
502
|
+
const compileSchema = React.useCallback(async (schema) => {
|
|
504
503
|
setIsCompiling(true);
|
|
505
504
|
setStage("compiling");
|
|
506
505
|
setError(null);
|
|
@@ -532,18 +531,18 @@ function useCompile() {
|
|
|
532
531
|
};
|
|
533
532
|
}
|
|
534
533
|
function usePreview(options) {
|
|
535
|
-
const [previewUrl, setPreviewUrl] =
|
|
536
|
-
const [isLoading, setIsLoading] =
|
|
537
|
-
const [error, setError] =
|
|
538
|
-
const [loadError, setLoadError] =
|
|
539
|
-
const [app, setApp] =
|
|
540
|
-
const [isFullscreen, setIsFullscreen] =
|
|
541
|
-
const [isExecutingEvent, setIsExecutingEvent] =
|
|
542
|
-
const [errorToast, setErrorToast] =
|
|
543
|
-
const [currentStateName, setCurrentStateName] =
|
|
544
|
-
const [notificationsList, setNotificationsList] =
|
|
545
|
-
const [isPanelOpen, setIsPanelOpen] =
|
|
546
|
-
const notifications =
|
|
534
|
+
const [previewUrl, setPreviewUrl] = React.useState(null);
|
|
535
|
+
const [isLoading, setIsLoading] = React.useState(!!options?.appId);
|
|
536
|
+
const [error, setError] = React.useState(null);
|
|
537
|
+
const [loadError, setLoadError] = React.useState(null);
|
|
538
|
+
const [app, setApp] = React.useState(null);
|
|
539
|
+
const [isFullscreen, setIsFullscreen] = React.useState(false);
|
|
540
|
+
const [isExecutingEvent, setIsExecutingEvent] = React.useState(false);
|
|
541
|
+
const [errorToast, setErrorToast] = React.useState(null);
|
|
542
|
+
const [currentStateName, setCurrentStateName] = React.useState(null);
|
|
543
|
+
const [notificationsList, setNotificationsList] = React.useState([]);
|
|
544
|
+
const [isPanelOpen, setIsPanelOpen] = React.useState(false);
|
|
545
|
+
const notifications = React.useMemo(() => ({
|
|
547
546
|
notifications: notificationsList,
|
|
548
547
|
isPanelOpen,
|
|
549
548
|
closePanel: () => setIsPanelOpen(false),
|
|
@@ -557,7 +556,7 @@ function usePreview(options) {
|
|
|
557
556
|
},
|
|
558
557
|
clearAll: () => setNotificationsList([])
|
|
559
558
|
}), [notificationsList, isPanelOpen]);
|
|
560
|
-
|
|
559
|
+
React.useEffect(() => {
|
|
561
560
|
const appId = options?.appId;
|
|
562
561
|
if (!appId) {
|
|
563
562
|
setApp(null);
|
|
@@ -568,10 +567,10 @@ function usePreview(options) {
|
|
|
568
567
|
setPreviewUrl(`/api/orbitals/${appId}`);
|
|
569
568
|
setIsLoading(false);
|
|
570
569
|
}, [options?.appId]);
|
|
571
|
-
const startPreview =
|
|
570
|
+
const startPreview = React.useCallback(async () => {
|
|
572
571
|
console.log("[usePreview] startPreview called");
|
|
573
572
|
}, []);
|
|
574
|
-
const stopPreview =
|
|
573
|
+
const stopPreview = React.useCallback(async () => {
|
|
575
574
|
setIsLoading(true);
|
|
576
575
|
try {
|
|
577
576
|
console.log("[usePreview] Stopping preview server...");
|
|
@@ -581,16 +580,16 @@ function usePreview(options) {
|
|
|
581
580
|
setIsLoading(false);
|
|
582
581
|
}
|
|
583
582
|
}, []);
|
|
584
|
-
const refresh =
|
|
583
|
+
const refresh = React.useCallback(async () => {
|
|
585
584
|
if (!previewUrl) return;
|
|
586
585
|
console.log("[usePreview] Refreshing preview...");
|
|
587
586
|
setPreviewUrl(`${previewUrl.split("?")[0]}?t=${Date.now()}`);
|
|
588
587
|
}, [previewUrl]);
|
|
589
|
-
const handleRefresh =
|
|
588
|
+
const handleRefresh = React.useCallback(async () => {
|
|
590
589
|
console.log("[usePreview] Handle refresh...");
|
|
591
590
|
await refresh();
|
|
592
591
|
}, [refresh]);
|
|
593
|
-
const handleReset =
|
|
592
|
+
const handleReset = React.useCallback(async () => {
|
|
594
593
|
console.log("[usePreview] Resetting preview...");
|
|
595
594
|
setError(null);
|
|
596
595
|
setLoadError(null);
|
|
@@ -598,10 +597,10 @@ function usePreview(options) {
|
|
|
598
597
|
setIsExecutingEvent(false);
|
|
599
598
|
setCurrentStateName(null);
|
|
600
599
|
}, []);
|
|
601
|
-
const toggleFullscreen =
|
|
600
|
+
const toggleFullscreen = React.useCallback(() => {
|
|
602
601
|
setIsFullscreen((prev) => !prev);
|
|
603
602
|
}, []);
|
|
604
|
-
const dismissErrorToast =
|
|
603
|
+
const dismissErrorToast = React.useCallback(() => {
|
|
605
604
|
setErrorToast(null);
|
|
606
605
|
}, []);
|
|
607
606
|
return {
|
|
@@ -626,16 +625,16 @@ function usePreview(options) {
|
|
|
626
625
|
};
|
|
627
626
|
}
|
|
628
627
|
function useAgentChat(options) {
|
|
629
|
-
const [messages, setMessages] =
|
|
630
|
-
const [status, setStatus] =
|
|
631
|
-
const [activities, setActivities] =
|
|
632
|
-
const [todos, setTodos] =
|
|
633
|
-
const [schemaDiffs, setSchemaDiffs] =
|
|
634
|
-
const [isLoading, setIsLoading] =
|
|
635
|
-
const [error, setError] =
|
|
636
|
-
const [threadId] =
|
|
637
|
-
const [interrupt, setInterrupt] =
|
|
638
|
-
const sendMessage =
|
|
628
|
+
const [messages, setMessages] = React.useState([]);
|
|
629
|
+
const [status, setStatus] = React.useState("idle");
|
|
630
|
+
const [activities, setActivities] = React.useState([]);
|
|
631
|
+
const [todos, setTodos] = React.useState([]);
|
|
632
|
+
const [schemaDiffs, setSchemaDiffs] = React.useState([]);
|
|
633
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
634
|
+
const [error, setError] = React.useState(null);
|
|
635
|
+
const [threadId] = React.useState(null);
|
|
636
|
+
const [interrupt, setInterrupt] = React.useState(null);
|
|
637
|
+
const sendMessage = React.useCallback(async (content) => {
|
|
639
638
|
setIsLoading(true);
|
|
640
639
|
setStatus("running");
|
|
641
640
|
setError(null);
|
|
@@ -664,7 +663,7 @@ function useAgentChat(options) {
|
|
|
664
663
|
setIsLoading(false);
|
|
665
664
|
}
|
|
666
665
|
}, [options]);
|
|
667
|
-
const startGeneration =
|
|
666
|
+
const startGeneration = React.useCallback(async (skill, prompt, genOptions) => {
|
|
668
667
|
setStatus("running");
|
|
669
668
|
setIsLoading(true);
|
|
670
669
|
setError(null);
|
|
@@ -681,22 +680,22 @@ function useAgentChat(options) {
|
|
|
681
680
|
setIsLoading(false);
|
|
682
681
|
}
|
|
683
682
|
}, [options]);
|
|
684
|
-
const continueConversation =
|
|
683
|
+
const continueConversation = React.useCallback(async (message) => {
|
|
685
684
|
console.log("[useAgentChat] Continue conversation", message);
|
|
686
685
|
}, []);
|
|
687
|
-
const resumeWithDecision =
|
|
686
|
+
const resumeWithDecision = React.useCallback(async (decisions) => {
|
|
688
687
|
console.log("[useAgentChat] Resume with decision:", decisions);
|
|
689
688
|
setInterrupt(null);
|
|
690
689
|
}, []);
|
|
691
|
-
const cancel =
|
|
690
|
+
const cancel = React.useCallback(() => {
|
|
692
691
|
setStatus("idle");
|
|
693
692
|
setIsLoading(false);
|
|
694
693
|
setInterrupt(null);
|
|
695
694
|
}, []);
|
|
696
|
-
const clearMessages =
|
|
695
|
+
const clearMessages = React.useCallback(() => {
|
|
697
696
|
setMessages([]);
|
|
698
697
|
}, []);
|
|
699
|
-
const clearHistory =
|
|
698
|
+
const clearHistory = React.useCallback(() => {
|
|
700
699
|
setMessages([]);
|
|
701
700
|
setActivities([]);
|
|
702
701
|
setTodos([]);
|
|
@@ -723,13 +722,13 @@ function useAgentChat(options) {
|
|
|
723
722
|
};
|
|
724
723
|
}
|
|
725
724
|
function useValidation() {
|
|
726
|
-
const [result, setResult] =
|
|
727
|
-
const [isValidating, setIsValidating] =
|
|
728
|
-
const [error, setError] =
|
|
729
|
-
const [stage, setStage] =
|
|
730
|
-
const [isFixing, setIsFixing] =
|
|
731
|
-
const [progressMessage, setProgressMessage] =
|
|
732
|
-
const validate =
|
|
725
|
+
const [result, setResult] = React.useState(null);
|
|
726
|
+
const [isValidating, setIsValidating] = React.useState(false);
|
|
727
|
+
const [error, setError] = React.useState(null);
|
|
728
|
+
const [stage, setStage] = React.useState("idle");
|
|
729
|
+
const [isFixing, setIsFixing] = React.useState(false);
|
|
730
|
+
const [progressMessage, setProgressMessage] = React.useState(null);
|
|
731
|
+
const validate = React.useCallback(async (appId) => {
|
|
733
732
|
setIsValidating(true);
|
|
734
733
|
setError(null);
|
|
735
734
|
setStage("validating");
|
|
@@ -761,11 +760,11 @@ function useValidation() {
|
|
|
761
760
|
setIsValidating(false);
|
|
762
761
|
}
|
|
763
762
|
}, []);
|
|
764
|
-
const clearResult =
|
|
763
|
+
const clearResult = React.useCallback(() => {
|
|
765
764
|
setResult(null);
|
|
766
765
|
setError(null);
|
|
767
766
|
}, []);
|
|
768
|
-
const reset =
|
|
767
|
+
const reset = React.useCallback(() => {
|
|
769
768
|
setResult(null);
|
|
770
769
|
setError(null);
|
|
771
770
|
setStage("idle");
|
|
@@ -789,15 +788,15 @@ function useValidation() {
|
|
|
789
788
|
};
|
|
790
789
|
}
|
|
791
790
|
function useDeepAgentGeneration() {
|
|
792
|
-
const [requests, setRequests] =
|
|
793
|
-
const [currentRequest, setCurrentRequest] =
|
|
794
|
-
const [isGenerating, setIsGenerating] =
|
|
795
|
-
const [isLoading, setIsLoading] =
|
|
796
|
-
const [isComplete, setIsComplete] =
|
|
797
|
-
const [progress, setProgress] =
|
|
798
|
-
const [error, setError] =
|
|
799
|
-
const [interrupt, setInterrupt] =
|
|
800
|
-
const generate =
|
|
791
|
+
const [requests, setRequests] = React.useState([]);
|
|
792
|
+
const [currentRequest, setCurrentRequest] = React.useState(null);
|
|
793
|
+
const [isGenerating, setIsGenerating] = React.useState(false);
|
|
794
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
795
|
+
const [isComplete, setIsComplete] = React.useState(false);
|
|
796
|
+
const [progress, setProgress] = React.useState({ stage: "idle", percent: 0, message: "" });
|
|
797
|
+
const [error, setError] = React.useState(null);
|
|
798
|
+
const [interrupt, setInterrupt] = React.useState(null);
|
|
799
|
+
const generate = React.useCallback(async (prompt) => {
|
|
801
800
|
setIsGenerating(true);
|
|
802
801
|
setIsLoading(true);
|
|
803
802
|
setIsComplete(false);
|
|
@@ -830,11 +829,11 @@ function useDeepAgentGeneration() {
|
|
|
830
829
|
setIsLoading(false);
|
|
831
830
|
}
|
|
832
831
|
}, []);
|
|
833
|
-
const startGeneration =
|
|
832
|
+
const startGeneration = React.useCallback(async (skill, prompt, _options) => {
|
|
834
833
|
console.log("[useDeepAgentGeneration] Starting generation with skill:", skill);
|
|
835
834
|
await generate(prompt);
|
|
836
835
|
}, [generate]);
|
|
837
|
-
const cancelGeneration =
|
|
836
|
+
const cancelGeneration = React.useCallback(() => {
|
|
838
837
|
if (currentRequest) {
|
|
839
838
|
currentRequest.status = "failed";
|
|
840
839
|
currentRequest.error = "Cancelled by user";
|
|
@@ -845,14 +844,14 @@ function useDeepAgentGeneration() {
|
|
|
845
844
|
setIsComplete(false);
|
|
846
845
|
setProgress({ stage: "idle", percent: 0, message: "" });
|
|
847
846
|
}, [currentRequest]);
|
|
848
|
-
const clearRequests =
|
|
847
|
+
const clearRequests = React.useCallback(() => {
|
|
849
848
|
setRequests([]);
|
|
850
849
|
setCurrentRequest(null);
|
|
851
850
|
setError(null);
|
|
852
851
|
setProgress({ stage: "idle", percent: 0, message: "" });
|
|
853
852
|
setIsComplete(false);
|
|
854
853
|
}, []);
|
|
855
|
-
const submitInterruptDecisions =
|
|
854
|
+
const submitInterruptDecisions = React.useCallback((decisions) => {
|
|
856
855
|
console.log("[useDeepAgentGeneration] Submitting interrupt decisions:", decisions);
|
|
857
856
|
setInterrupt(null);
|
|
858
857
|
}, []);
|
|
@@ -876,22 +875,13 @@ function useDeepAgentGeneration() {
|
|
|
876
875
|
// lib/logger.ts
|
|
877
876
|
var LEVEL_PRIORITY = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3 };
|
|
878
877
|
var ENV = typeof process !== "undefined" && process.env ? process.env : {};
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
try {
|
|
882
|
-
const meta = (0, eval)('typeof import.meta !== "undefined" && import.meta');
|
|
883
|
-
return meta ? meta.env?.[key] : void 0;
|
|
884
|
-
} catch {
|
|
885
|
-
return void 0;
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
function envGet(key, viteKey) {
|
|
889
|
-
return ENV[key] ?? (viteKey ? getViteEnv(viteKey) : void 0) ?? VITE_ENV[viteKey ?? key];
|
|
878
|
+
function envGet(key) {
|
|
879
|
+
return ENV[key] ?? ENV[`VITE_${key}`];
|
|
890
880
|
}
|
|
891
|
-
var NODE_ENV = envGet("NODE_ENV"
|
|
892
|
-
var CONFIGURED_LEVEL = (envGet("LOG_LEVEL"
|
|
881
|
+
var NODE_ENV = envGet("NODE_ENV") ?? "development";
|
|
882
|
+
var CONFIGURED_LEVEL = (envGet("LOG_LEVEL") ?? (NODE_ENV === "production" ? "info" : "debug")).toUpperCase();
|
|
893
883
|
var MIN_PRIORITY = LEVEL_PRIORITY[CONFIGURED_LEVEL] ?? 0;
|
|
894
|
-
var DEBUG_FILTER = (envGet("ALMADAR_DEBUG"
|
|
884
|
+
var DEBUG_FILTER = (envGet("ALMADAR_DEBUG") ?? "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
895
885
|
function matchesNamespace(namespace) {
|
|
896
886
|
if (DEBUG_FILTER.length === 0) return true;
|
|
897
887
|
return DEBUG_FILTER.some((pattern) => {
|
|
@@ -1003,14 +993,14 @@ var fallbackEventBus = {
|
|
|
1003
993
|
}
|
|
1004
994
|
};
|
|
1005
995
|
function useEventBus() {
|
|
1006
|
-
const context =
|
|
996
|
+
const context = React.useContext(providers.EventBusContext);
|
|
1007
997
|
return context ?? getGlobalEventBus() ?? fallbackEventBus;
|
|
1008
998
|
}
|
|
1009
999
|
function useEventListener(event, handler) {
|
|
1010
1000
|
const eventBus = useEventBus();
|
|
1011
|
-
const handlerRef =
|
|
1001
|
+
const handlerRef = React.useRef(handler);
|
|
1012
1002
|
handlerRef.current = handler;
|
|
1013
|
-
|
|
1003
|
+
React.useEffect(() => {
|
|
1014
1004
|
const wrappedHandler = (evt) => {
|
|
1015
1005
|
handlerRef.current(evt);
|
|
1016
1006
|
};
|
|
@@ -1022,7 +1012,7 @@ function useEventListener(event, handler) {
|
|
|
1022
1012
|
}
|
|
1023
1013
|
function useEmitEvent() {
|
|
1024
1014
|
const eventBus = useEventBus();
|
|
1025
|
-
return
|
|
1015
|
+
return React.useCallback(
|
|
1026
1016
|
(type, payload) => {
|
|
1027
1017
|
eventBus.emit(type, payload);
|
|
1028
1018
|
},
|
|
@@ -1048,16 +1038,16 @@ function generateId() {
|
|
|
1048
1038
|
return `slot-content-${++idCounter}-${Date.now()}`;
|
|
1049
1039
|
}
|
|
1050
1040
|
function useUISlotManager() {
|
|
1051
|
-
const [slots, setSlots] =
|
|
1052
|
-
const subscribersRef =
|
|
1053
|
-
const timersRef =
|
|
1054
|
-
|
|
1041
|
+
const [slots, setSlots] = React.useState(DEFAULT_SLOTS);
|
|
1042
|
+
const subscribersRef = React.useRef(/* @__PURE__ */ new Set());
|
|
1043
|
+
const timersRef = React.useRef(/* @__PURE__ */ new Map());
|
|
1044
|
+
React.useEffect(() => {
|
|
1055
1045
|
return () => {
|
|
1056
1046
|
timersRef.current.forEach((timer) => clearTimeout(timer));
|
|
1057
1047
|
timersRef.current.clear();
|
|
1058
1048
|
};
|
|
1059
1049
|
}, []);
|
|
1060
|
-
const notifySubscribers =
|
|
1050
|
+
const notifySubscribers = React.useCallback((slot, content) => {
|
|
1061
1051
|
subscribersRef.current.forEach((callback) => {
|
|
1062
1052
|
try {
|
|
1063
1053
|
callback(slot, content);
|
|
@@ -1066,7 +1056,7 @@ function useUISlotManager() {
|
|
|
1066
1056
|
}
|
|
1067
1057
|
});
|
|
1068
1058
|
}, []);
|
|
1069
|
-
const render =
|
|
1059
|
+
const render = React.useCallback((config) => {
|
|
1070
1060
|
const id = generateId();
|
|
1071
1061
|
const content = {
|
|
1072
1062
|
id,
|
|
@@ -1105,7 +1095,7 @@ function useUISlotManager() {
|
|
|
1105
1095
|
});
|
|
1106
1096
|
return id;
|
|
1107
1097
|
}, [notifySubscribers]);
|
|
1108
|
-
const clear =
|
|
1098
|
+
const clear = React.useCallback((slot) => {
|
|
1109
1099
|
setSlots((prev) => {
|
|
1110
1100
|
const content = prev[slot];
|
|
1111
1101
|
if (content) {
|
|
@@ -1120,7 +1110,7 @@ function useUISlotManager() {
|
|
|
1120
1110
|
return { ...prev, [slot]: null };
|
|
1121
1111
|
});
|
|
1122
1112
|
}, [notifySubscribers]);
|
|
1123
|
-
const clearById =
|
|
1113
|
+
const clearById = React.useCallback((id) => {
|
|
1124
1114
|
setSlots((prev) => {
|
|
1125
1115
|
const entry = Object.entries(prev).find(([, content]) => content?.id === id);
|
|
1126
1116
|
if (entry) {
|
|
@@ -1137,7 +1127,7 @@ function useUISlotManager() {
|
|
|
1137
1127
|
return prev;
|
|
1138
1128
|
});
|
|
1139
1129
|
}, [notifySubscribers]);
|
|
1140
|
-
const clearAll =
|
|
1130
|
+
const clearAll = React.useCallback(() => {
|
|
1141
1131
|
timersRef.current.forEach((timer) => clearTimeout(timer));
|
|
1142
1132
|
timersRef.current.clear();
|
|
1143
1133
|
setSlots((prev) => {
|
|
@@ -1150,16 +1140,16 @@ function useUISlotManager() {
|
|
|
1150
1140
|
return DEFAULT_SLOTS;
|
|
1151
1141
|
});
|
|
1152
1142
|
}, [notifySubscribers]);
|
|
1153
|
-
const subscribe2 =
|
|
1143
|
+
const subscribe2 = React.useCallback((callback) => {
|
|
1154
1144
|
subscribersRef.current.add(callback);
|
|
1155
1145
|
return () => {
|
|
1156
1146
|
subscribersRef.current.delete(callback);
|
|
1157
1147
|
};
|
|
1158
1148
|
}, []);
|
|
1159
|
-
const hasContent =
|
|
1149
|
+
const hasContent = React.useCallback((slot) => {
|
|
1160
1150
|
return slots[slot] !== null;
|
|
1161
1151
|
}, [slots]);
|
|
1162
|
-
const getContent =
|
|
1152
|
+
const getContent = React.useCallback((slot) => {
|
|
1163
1153
|
return slots[slot];
|
|
1164
1154
|
}, [slots]);
|
|
1165
1155
|
return {
|
|
@@ -1173,20 +1163,17 @@ function useUISlotManager() {
|
|
|
1173
1163
|
getContent
|
|
1174
1164
|
};
|
|
1175
1165
|
}
|
|
1176
|
-
var SelectionContext = React2.createContext(null);
|
|
1177
|
-
|
|
1178
|
-
// hooks/useUIEvents.ts
|
|
1179
1166
|
var UI_PREFIX = "UI:";
|
|
1180
1167
|
function useUIEvents(dispatch, validEvents, eventBusInstance) {
|
|
1181
1168
|
const defaultEventBus = useEventBus();
|
|
1182
1169
|
const eventBus = eventBusInstance ?? defaultEventBus;
|
|
1183
1170
|
const validEventsKey = validEvents ? validEvents.slice().sort().join(",") : "";
|
|
1184
|
-
const stableValidEvents =
|
|
1171
|
+
const stableValidEvents = React.useMemo(
|
|
1185
1172
|
() => validEvents,
|
|
1186
1173
|
[validEventsKey]
|
|
1187
1174
|
// intentional — validEventsKey is the stable dep, not validEvents array ref
|
|
1188
1175
|
);
|
|
1189
|
-
|
|
1176
|
+
React.useEffect(() => {
|
|
1190
1177
|
const unsubscribes = [];
|
|
1191
1178
|
if (stableValidEvents) {
|
|
1192
1179
|
for (const smEvent of stableValidEvents) {
|
|
@@ -1221,9 +1208,9 @@ function useSelectedEntity(eventBusInstance) {
|
|
|
1221
1208
|
const defaultEventBus = useEventBus();
|
|
1222
1209
|
const eventBus = eventBusInstance ?? defaultEventBus;
|
|
1223
1210
|
const selectionContext = useSelectionContext();
|
|
1224
|
-
const [localSelected, setLocalSelected] =
|
|
1211
|
+
const [localSelected, setLocalSelected] = React.useState(null);
|
|
1225
1212
|
const usingContext = selectionContext !== null;
|
|
1226
|
-
|
|
1213
|
+
React.useEffect(() => {
|
|
1227
1214
|
if (usingContext) return;
|
|
1228
1215
|
const handleSelect = (event) => {
|
|
1229
1216
|
const row = event.payload?.row;
|
|
@@ -1253,22 +1240,22 @@ function useSelectedEntity(eventBusInstance) {
|
|
|
1253
1240
|
return [localSelected, setLocalSelected];
|
|
1254
1241
|
}
|
|
1255
1242
|
function useSelectionContext() {
|
|
1256
|
-
const context =
|
|
1243
|
+
const context = React.useContext(providers.SelectionContext);
|
|
1257
1244
|
return context;
|
|
1258
1245
|
}
|
|
1259
|
-
var EntityDataContext =
|
|
1246
|
+
var EntityDataContext = React.createContext(null);
|
|
1260
1247
|
function EntityDataProvider({
|
|
1261
1248
|
adapter,
|
|
1262
1249
|
children
|
|
1263
1250
|
}) {
|
|
1264
|
-
return
|
|
1251
|
+
return React__default.default.createElement(
|
|
1265
1252
|
EntityDataContext.Provider,
|
|
1266
1253
|
{ value: adapter },
|
|
1267
1254
|
children
|
|
1268
1255
|
);
|
|
1269
1256
|
}
|
|
1270
1257
|
function useEntityDataAdapter() {
|
|
1271
|
-
return
|
|
1258
|
+
return React.useContext(EntityDataContext);
|
|
1272
1259
|
}
|
|
1273
1260
|
var entityDataKeys = {
|
|
1274
1261
|
all: ["entities"],
|
|
@@ -1279,15 +1266,15 @@ var entityDataKeys = {
|
|
|
1279
1266
|
};
|
|
1280
1267
|
function useEntityList(entity, options = {}) {
|
|
1281
1268
|
const { skip = false } = options;
|
|
1282
|
-
const adapter =
|
|
1283
|
-
const adapterData =
|
|
1269
|
+
const adapter = React.useContext(EntityDataContext);
|
|
1270
|
+
const adapterData = React.useMemo(() => {
|
|
1284
1271
|
if (!adapter || !entity || skip) return [];
|
|
1285
1272
|
return adapter.getData(entity);
|
|
1286
1273
|
}, [adapter, entity, skip, adapter?.isLoading]);
|
|
1287
|
-
const [stubData, setStubData] =
|
|
1288
|
-
const [stubLoading, setStubLoading] =
|
|
1289
|
-
const [stubError, setStubError] =
|
|
1290
|
-
|
|
1274
|
+
const [stubData, setStubData] = React.useState([]);
|
|
1275
|
+
const [stubLoading, setStubLoading] = React.useState(!skip && !!entity && !adapter);
|
|
1276
|
+
const [stubError, setStubError] = React.useState(null);
|
|
1277
|
+
React.useEffect(() => {
|
|
1291
1278
|
if (adapter || skip || !entity) {
|
|
1292
1279
|
setStubLoading(false);
|
|
1293
1280
|
return;
|
|
@@ -1312,15 +1299,15 @@ function useEntityList(entity, options = {}) {
|
|
|
1312
1299
|
} };
|
|
1313
1300
|
}
|
|
1314
1301
|
function useEntity(entity, id) {
|
|
1315
|
-
const adapter =
|
|
1316
|
-
const adapterData =
|
|
1302
|
+
const adapter = React.useContext(EntityDataContext);
|
|
1303
|
+
const adapterData = React.useMemo(() => {
|
|
1317
1304
|
if (!adapter || !entity || !id) return null;
|
|
1318
1305
|
return adapter.getById(entity, id) ?? null;
|
|
1319
1306
|
}, [adapter, entity, id, adapter?.isLoading]);
|
|
1320
|
-
const [stubData, setStubData] =
|
|
1321
|
-
const [stubLoading, setStubLoading] =
|
|
1322
|
-
const [stubError, setStubError] =
|
|
1323
|
-
|
|
1307
|
+
const [stubData, setStubData] = React.useState(null);
|
|
1308
|
+
const [stubLoading, setStubLoading] = React.useState(!!entity && !!id && !adapter);
|
|
1309
|
+
const [stubError, setStubError] = React.useState(null);
|
|
1310
|
+
React.useEffect(() => {
|
|
1324
1311
|
if (adapter || !entity || !id) {
|
|
1325
1312
|
setStubLoading(false);
|
|
1326
1313
|
return;
|
|
@@ -1351,7 +1338,7 @@ function getSuspenseCacheKey(entity, type, id) {
|
|
|
1351
1338
|
return id ? `${type}:${entity}:${id}` : `${type}:${entity}`;
|
|
1352
1339
|
}
|
|
1353
1340
|
function useEntityListSuspense(entity) {
|
|
1354
|
-
const adapter =
|
|
1341
|
+
const adapter = React.useContext(EntityDataContext);
|
|
1355
1342
|
if (adapter) {
|
|
1356
1343
|
if (adapter.isLoading) {
|
|
1357
1344
|
const cacheKey2 = getSuspenseCacheKey(entity, "list");
|
|
@@ -1405,7 +1392,7 @@ function useEntityListSuspense(entity) {
|
|
|
1405
1392
|
} };
|
|
1406
1393
|
}
|
|
1407
1394
|
function useEntitySuspense(entity, id) {
|
|
1408
|
-
const adapter =
|
|
1395
|
+
const adapter = React.useContext(EntityDataContext);
|
|
1409
1396
|
if (adapter) {
|
|
1410
1397
|
if (adapter.isLoading) {
|
|
1411
1398
|
const cacheKey2 = getSuspenseCacheKey(entity, "detail", id);
|
|
@@ -1472,35 +1459,35 @@ function getOrCreateStore(query) {
|
|
|
1472
1459
|
return queryStores.get(query);
|
|
1473
1460
|
}
|
|
1474
1461
|
function useQuerySingleton(query) {
|
|
1475
|
-
const [, forceUpdate] =
|
|
1462
|
+
const [, forceUpdate] = React.useState({});
|
|
1476
1463
|
if (!query) {
|
|
1477
1464
|
return null;
|
|
1478
1465
|
}
|
|
1479
|
-
const store =
|
|
1480
|
-
|
|
1466
|
+
const store = React.useMemo(() => getOrCreateStore(query), [query]);
|
|
1467
|
+
React.useMemo(() => {
|
|
1481
1468
|
const listener = () => forceUpdate({});
|
|
1482
1469
|
store.listeners.add(listener);
|
|
1483
1470
|
return () => {
|
|
1484
1471
|
store.listeners.delete(listener);
|
|
1485
1472
|
};
|
|
1486
1473
|
}, [store]);
|
|
1487
|
-
const notifyListeners =
|
|
1474
|
+
const notifyListeners = React.useCallback(() => {
|
|
1488
1475
|
store.listeners.forEach((listener) => listener());
|
|
1489
1476
|
}, [store]);
|
|
1490
|
-
const setSearch =
|
|
1477
|
+
const setSearch = React.useCallback((value) => {
|
|
1491
1478
|
store.search = value;
|
|
1492
1479
|
notifyListeners();
|
|
1493
1480
|
}, [store, notifyListeners]);
|
|
1494
|
-
const setFilter =
|
|
1481
|
+
const setFilter = React.useCallback((key, value) => {
|
|
1495
1482
|
store.filters = { ...store.filters, [key]: value };
|
|
1496
1483
|
notifyListeners();
|
|
1497
1484
|
}, [store, notifyListeners]);
|
|
1498
|
-
const clearFilters =
|
|
1485
|
+
const clearFilters = React.useCallback(() => {
|
|
1499
1486
|
store.filters = {};
|
|
1500
1487
|
store.search = "";
|
|
1501
1488
|
notifyListeners();
|
|
1502
1489
|
}, [store, notifyListeners]);
|
|
1503
|
-
const setSort =
|
|
1490
|
+
const setSort = React.useCallback((field, direction) => {
|
|
1504
1491
|
store.sortField = field;
|
|
1505
1492
|
store.sortDirection = direction;
|
|
1506
1493
|
notifyListeners();
|
|
@@ -1967,7 +1954,7 @@ function getSnapshot() {
|
|
|
1967
1954
|
|
|
1968
1955
|
// hooks/useEntities.ts
|
|
1969
1956
|
function useEntities() {
|
|
1970
|
-
const entities2 =
|
|
1957
|
+
const entities2 = React.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
1971
1958
|
return {
|
|
1972
1959
|
entities: entities2,
|
|
1973
1960
|
getEntity,
|
|
@@ -1982,34 +1969,34 @@ function useEntities() {
|
|
|
1982
1969
|
};
|
|
1983
1970
|
}
|
|
1984
1971
|
function useEntity2(id) {
|
|
1985
|
-
const entities2 =
|
|
1972
|
+
const entities2 = React.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
1986
1973
|
return entities2.get(id);
|
|
1987
1974
|
}
|
|
1988
1975
|
function useEntitiesByType(type) {
|
|
1989
|
-
const entities2 =
|
|
1976
|
+
const entities2 = React.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
1990
1977
|
return [...entities2.values()].filter((e) => e.type === type);
|
|
1991
1978
|
}
|
|
1992
1979
|
function useSingletonEntity(type) {
|
|
1993
|
-
const entities2 =
|
|
1980
|
+
const entities2 = React.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
1994
1981
|
return [...entities2.values()].find((e) => e.type === type);
|
|
1995
1982
|
}
|
|
1996
1983
|
function usePlayer() {
|
|
1997
1984
|
const player = useSingletonEntity("Player");
|
|
1998
|
-
const update =
|
|
1985
|
+
const update = React.useCallback((updates) => {
|
|
1999
1986
|
if (player) updateEntity(player.id, updates);
|
|
2000
1987
|
}, [player?.id]);
|
|
2001
1988
|
return { player, updatePlayer: update };
|
|
2002
1989
|
}
|
|
2003
1990
|
function usePhysics() {
|
|
2004
1991
|
const physics = useSingletonEntity("Physics");
|
|
2005
|
-
const update =
|
|
1992
|
+
const update = React.useCallback((updates) => {
|
|
2006
1993
|
if (physics) updateEntity(physics.id, updates);
|
|
2007
1994
|
}, [physics?.id]);
|
|
2008
1995
|
return { physics, updatePhysics: update };
|
|
2009
1996
|
}
|
|
2010
1997
|
function useInput() {
|
|
2011
1998
|
const input = useSingletonEntity("Input");
|
|
2012
|
-
const update =
|
|
1999
|
+
const update = React.useCallback((updates) => {
|
|
2013
2000
|
if (input) updateEntity(input.id, updates);
|
|
2014
2001
|
}, [input?.id]);
|
|
2015
2002
|
return { input, updateInput: update };
|
|
@@ -2124,7 +2111,7 @@ var en_default = {
|
|
|
2124
2111
|
// hooks/useTranslate.ts
|
|
2125
2112
|
var { $meta: _meta, ...coreMessages } = en_default;
|
|
2126
2113
|
var coreLocale = coreMessages;
|
|
2127
|
-
var I18nContext =
|
|
2114
|
+
var I18nContext = React.createContext({
|
|
2128
2115
|
locale: "en",
|
|
2129
2116
|
direction: "ltr",
|
|
2130
2117
|
t: (key) => coreLocale[key] ?? key
|
|
@@ -2133,7 +2120,7 @@ var I18nContext = React2.createContext({
|
|
|
2133
2120
|
I18nContext.displayName = "I18nContext";
|
|
2134
2121
|
var I18nProvider = I18nContext.Provider;
|
|
2135
2122
|
function useTranslate() {
|
|
2136
|
-
return
|
|
2123
|
+
return React.useContext(I18nContext);
|
|
2137
2124
|
}
|
|
2138
2125
|
function createTranslate(messages) {
|
|
2139
2126
|
return (key, params) => {
|
|
@@ -2149,7 +2136,7 @@ function createTranslate(messages) {
|
|
|
2149
2136
|
function useResolvedEntity(entity, data) {
|
|
2150
2137
|
const shouldFetch = !data && !!entity;
|
|
2151
2138
|
const fetched = useEntityList(entity, { skip: !shouldFetch });
|
|
2152
|
-
return
|
|
2139
|
+
return React.useMemo(() => {
|
|
2153
2140
|
if (data) {
|
|
2154
2141
|
return {
|
|
2155
2142
|
data,
|
|
@@ -2178,14 +2165,14 @@ function useAuthContext() {
|
|
|
2178
2165
|
}
|
|
2179
2166
|
function useSwipeGesture(callbacks, options = {}) {
|
|
2180
2167
|
const { threshold = 50, velocityThreshold = 0.3, preventDefault = false } = options;
|
|
2181
|
-
const startX =
|
|
2182
|
-
const startY =
|
|
2183
|
-
const startTime =
|
|
2184
|
-
const currentX =
|
|
2185
|
-
const tracking =
|
|
2186
|
-
const offsetXRef =
|
|
2187
|
-
const isSwipingRef =
|
|
2188
|
-
const onPointerDown =
|
|
2168
|
+
const startX = React.useRef(0);
|
|
2169
|
+
const startY = React.useRef(0);
|
|
2170
|
+
const startTime = React.useRef(0);
|
|
2171
|
+
const currentX = React.useRef(0);
|
|
2172
|
+
const tracking = React.useRef(false);
|
|
2173
|
+
const offsetXRef = React.useRef(0);
|
|
2174
|
+
const isSwipingRef = React.useRef(false);
|
|
2175
|
+
const onPointerDown = React.useCallback((e) => {
|
|
2189
2176
|
startX.current = e.clientX;
|
|
2190
2177
|
startY.current = e.clientY;
|
|
2191
2178
|
currentX.current = e.clientX;
|
|
@@ -2195,7 +2182,7 @@ function useSwipeGesture(callbacks, options = {}) {
|
|
|
2195
2182
|
offsetXRef.current = 0;
|
|
2196
2183
|
e.target.setPointerCapture?.(e.pointerId);
|
|
2197
2184
|
}, []);
|
|
2198
|
-
const onPointerMove =
|
|
2185
|
+
const onPointerMove = React.useCallback((e) => {
|
|
2199
2186
|
if (!tracking.current) return;
|
|
2200
2187
|
if (preventDefault) e.preventDefault();
|
|
2201
2188
|
currentX.current = e.clientX;
|
|
@@ -2206,7 +2193,7 @@ function useSwipeGesture(callbacks, options = {}) {
|
|
|
2206
2193
|
offsetXRef.current = dx;
|
|
2207
2194
|
}
|
|
2208
2195
|
}, [preventDefault]);
|
|
2209
|
-
const onPointerUp =
|
|
2196
|
+
const onPointerUp = React.useCallback((e) => {
|
|
2210
2197
|
if (!tracking.current) return;
|
|
2211
2198
|
tracking.current = false;
|
|
2212
2199
|
const dx = e.clientX - startX.current;
|
|
@@ -2224,7 +2211,7 @@ function useSwipeGesture(callbacks, options = {}) {
|
|
|
2224
2211
|
else if (dy > threshold) callbacks.onSwipeDown?.();
|
|
2225
2212
|
}
|
|
2226
2213
|
}, [threshold, velocityThreshold, callbacks]);
|
|
2227
|
-
const onPointerCancel =
|
|
2214
|
+
const onPointerCancel = React.useCallback(() => {
|
|
2228
2215
|
tracking.current = false;
|
|
2229
2216
|
offsetXRef.current = 0;
|
|
2230
2217
|
isSwipingRef.current = false;
|
|
@@ -2240,18 +2227,18 @@ function useSwipeGesture(callbacks, options = {}) {
|
|
|
2240
2227
|
}
|
|
2241
2228
|
function useLongPress(onLongPress, options = {}) {
|
|
2242
2229
|
const { duration = 500, moveThreshold = 10 } = options;
|
|
2243
|
-
const timerRef =
|
|
2244
|
-
const startPos =
|
|
2245
|
-
const isPressedRef =
|
|
2246
|
-
const firedRef =
|
|
2247
|
-
const cancel =
|
|
2230
|
+
const timerRef = React.useRef(null);
|
|
2231
|
+
const startPos = React.useRef({ x: 0, y: 0 });
|
|
2232
|
+
const isPressedRef = React.useRef(false);
|
|
2233
|
+
const firedRef = React.useRef(false);
|
|
2234
|
+
const cancel = React.useCallback(() => {
|
|
2248
2235
|
if (timerRef.current) {
|
|
2249
2236
|
clearTimeout(timerRef.current);
|
|
2250
2237
|
timerRef.current = null;
|
|
2251
2238
|
}
|
|
2252
2239
|
isPressedRef.current = false;
|
|
2253
2240
|
}, []);
|
|
2254
|
-
const onPointerDown =
|
|
2241
|
+
const onPointerDown = React.useCallback((e) => {
|
|
2255
2242
|
firedRef.current = false;
|
|
2256
2243
|
startPos.current = { x: e.clientX, y: e.clientY };
|
|
2257
2244
|
isPressedRef.current = true;
|
|
@@ -2261,7 +2248,7 @@ function useLongPress(onLongPress, options = {}) {
|
|
|
2261
2248
|
onLongPress();
|
|
2262
2249
|
}, duration);
|
|
2263
2250
|
}, [duration, onLongPress]);
|
|
2264
|
-
const onPointerMove =
|
|
2251
|
+
const onPointerMove = React.useCallback((e) => {
|
|
2265
2252
|
if (!isPressedRef.current) return;
|
|
2266
2253
|
const dx = e.clientX - startPos.current.x;
|
|
2267
2254
|
const dy = e.clientY - startPos.current.y;
|
|
@@ -2269,10 +2256,10 @@ function useLongPress(onLongPress, options = {}) {
|
|
|
2269
2256
|
cancel();
|
|
2270
2257
|
}
|
|
2271
2258
|
}, [moveThreshold, cancel]);
|
|
2272
|
-
const onPointerUp =
|
|
2259
|
+
const onPointerUp = React.useCallback(() => {
|
|
2273
2260
|
cancel();
|
|
2274
2261
|
}, [cancel]);
|
|
2275
|
-
const onPointerCancel =
|
|
2262
|
+
const onPointerCancel = React.useCallback(() => {
|
|
2276
2263
|
cancel();
|
|
2277
2264
|
}, [cancel]);
|
|
2278
2265
|
return {
|
|
@@ -2284,22 +2271,22 @@ function useLongPress(onLongPress, options = {}) {
|
|
|
2284
2271
|
};
|
|
2285
2272
|
}
|
|
2286
2273
|
function useDragReorder(initialItems, onReorder) {
|
|
2287
|
-
const [items, setItems] =
|
|
2288
|
-
const [dragIndex, setDragIndex] =
|
|
2289
|
-
const [dragOverIndex, setDragOverIndex] =
|
|
2290
|
-
const itemsRef =
|
|
2274
|
+
const [items, setItems] = React.useState(initialItems);
|
|
2275
|
+
const [dragIndex, setDragIndex] = React.useState(-1);
|
|
2276
|
+
const [dragOverIndex, setDragOverIndex] = React.useState(-1);
|
|
2277
|
+
const itemsRef = React.useRef(initialItems);
|
|
2291
2278
|
if (initialItems !== itemsRef.current) {
|
|
2292
2279
|
itemsRef.current = initialItems;
|
|
2293
2280
|
setItems(initialItems);
|
|
2294
2281
|
}
|
|
2295
2282
|
const isDragging = dragIndex >= 0;
|
|
2296
|
-
const handleDragStart =
|
|
2283
|
+
const handleDragStart = React.useCallback((index) => (e) => {
|
|
2297
2284
|
e.preventDefault();
|
|
2298
2285
|
setDragIndex(index);
|
|
2299
2286
|
setDragOverIndex(index);
|
|
2300
2287
|
e.target.setPointerCapture?.(e.pointerId);
|
|
2301
2288
|
}, []);
|
|
2302
|
-
const handleDragMove =
|
|
2289
|
+
const handleDragMove = React.useCallback((index) => (e) => {
|
|
2303
2290
|
if (dragIndex < 0) return;
|
|
2304
2291
|
const target = document.elementFromPoint(e.clientX, e.clientY);
|
|
2305
2292
|
if (!target) return;
|
|
@@ -2314,7 +2301,7 @@ function useDragReorder(initialItems, onReorder) {
|
|
|
2314
2301
|
}
|
|
2315
2302
|
}
|
|
2316
2303
|
}, [dragIndex, dragOverIndex]);
|
|
2317
|
-
const handleDragEnd =
|
|
2304
|
+
const handleDragEnd = React.useCallback(() => {
|
|
2318
2305
|
if (dragIndex >= 0 && dragOverIndex >= 0 && dragIndex !== dragOverIndex) {
|
|
2319
2306
|
const newItems = [...items];
|
|
2320
2307
|
const [movedItem] = newItems.splice(dragIndex, 1);
|
|
@@ -2325,13 +2312,13 @@ function useDragReorder(initialItems, onReorder) {
|
|
|
2325
2312
|
setDragIndex(-1);
|
|
2326
2313
|
setDragOverIndex(-1);
|
|
2327
2314
|
}, [dragIndex, dragOverIndex, items, onReorder]);
|
|
2328
|
-
const getDragHandleProps =
|
|
2315
|
+
const getDragHandleProps = React.useCallback((index) => ({
|
|
2329
2316
|
onPointerDown: handleDragStart(index),
|
|
2330
2317
|
style: { cursor: "grab", touchAction: "none" },
|
|
2331
2318
|
"aria-grabbed": dragIndex === index,
|
|
2332
2319
|
role: "button"
|
|
2333
2320
|
}), [handleDragStart, dragIndex]);
|
|
2334
|
-
const getItemProps =
|
|
2321
|
+
const getItemProps = React.useCallback((index) => ({
|
|
2335
2322
|
onPointerMove: handleDragMove(index),
|
|
2336
2323
|
onPointerUp: handleDragEnd,
|
|
2337
2324
|
"aria-dropeffect": "move",
|
|
@@ -2353,19 +2340,19 @@ function useDragReorder(initialItems, onReorder) {
|
|
|
2353
2340
|
}
|
|
2354
2341
|
function useInfiniteScroll(onLoadMore, options = {}) {
|
|
2355
2342
|
const { rootMargin = "200px", hasMore = true, isLoading = false } = options;
|
|
2356
|
-
const observerRef =
|
|
2357
|
-
const callbackRef =
|
|
2343
|
+
const observerRef = React.useRef(null);
|
|
2344
|
+
const callbackRef = React.useRef(onLoadMore);
|
|
2358
2345
|
callbackRef.current = onLoadMore;
|
|
2359
|
-
const hasMoreRef =
|
|
2346
|
+
const hasMoreRef = React.useRef(hasMore);
|
|
2360
2347
|
hasMoreRef.current = hasMore;
|
|
2361
|
-
const isLoadingRef =
|
|
2348
|
+
const isLoadingRef = React.useRef(isLoading);
|
|
2362
2349
|
isLoadingRef.current = isLoading;
|
|
2363
|
-
|
|
2350
|
+
React.useEffect(() => {
|
|
2364
2351
|
return () => {
|
|
2365
2352
|
observerRef.current?.disconnect();
|
|
2366
2353
|
};
|
|
2367
2354
|
}, []);
|
|
2368
|
-
const sentinelRef =
|
|
2355
|
+
const sentinelRef = React.useCallback((node) => {
|
|
2369
2356
|
observerRef.current?.disconnect();
|
|
2370
2357
|
if (!node) return;
|
|
2371
2358
|
observerRef.current = new IntersectionObserver(
|
|
@@ -2383,12 +2370,12 @@ function useInfiniteScroll(onLoadMore, options = {}) {
|
|
|
2383
2370
|
}
|
|
2384
2371
|
function usePullToRefresh(onRefresh, options = {}) {
|
|
2385
2372
|
const { threshold = 60, maxPull = 120 } = options;
|
|
2386
|
-
const [pullDistance, setPullDistance] =
|
|
2387
|
-
const [isPulling, setIsPulling] =
|
|
2388
|
-
const [isRefreshing, setIsRefreshing] =
|
|
2389
|
-
const startY =
|
|
2390
|
-
const scrollTopRef =
|
|
2391
|
-
const onTouchStart =
|
|
2373
|
+
const [pullDistance, setPullDistance] = React.useState(0);
|
|
2374
|
+
const [isPulling, setIsPulling] = React.useState(false);
|
|
2375
|
+
const [isRefreshing, setIsRefreshing] = React.useState(false);
|
|
2376
|
+
const startY = React.useRef(0);
|
|
2377
|
+
const scrollTopRef = React.useRef(0);
|
|
2378
|
+
const onTouchStart = React.useCallback((e) => {
|
|
2392
2379
|
const container = e.currentTarget;
|
|
2393
2380
|
scrollTopRef.current = container.scrollTop;
|
|
2394
2381
|
if (scrollTopRef.current <= 0) {
|
|
@@ -2396,7 +2383,7 @@ function usePullToRefresh(onRefresh, options = {}) {
|
|
|
2396
2383
|
setIsPulling(true);
|
|
2397
2384
|
}
|
|
2398
2385
|
}, []);
|
|
2399
|
-
const onTouchMove =
|
|
2386
|
+
const onTouchMove = React.useCallback((e) => {
|
|
2400
2387
|
if (!isPulling || isRefreshing) return;
|
|
2401
2388
|
const container = e.currentTarget;
|
|
2402
2389
|
if (container.scrollTop > 0) {
|
|
@@ -2409,7 +2396,7 @@ function usePullToRefresh(onRefresh, options = {}) {
|
|
|
2409
2396
|
setPullDistance(distance);
|
|
2410
2397
|
}
|
|
2411
2398
|
}, [isPulling, isRefreshing, maxPull]);
|
|
2412
|
-
const onTouchEnd =
|
|
2399
|
+
const onTouchEnd = React.useCallback(() => {
|
|
2413
2400
|
if (!isPulling) return;
|
|
2414
2401
|
setIsPulling(false);
|
|
2415
2402
|
if (pullDistance >= threshold && !isRefreshing) {
|
|
@@ -2420,7 +2407,7 @@ function usePullToRefresh(onRefresh, options = {}) {
|
|
|
2420
2407
|
setPullDistance(0);
|
|
2421
2408
|
}
|
|
2422
2409
|
}, [isPulling, pullDistance, threshold, isRefreshing, onRefresh]);
|
|
2423
|
-
const endRefresh =
|
|
2410
|
+
const endRefresh = React.useCallback(() => {
|
|
2424
2411
|
setIsRefreshing(false);
|
|
2425
2412
|
setPullDistance(0);
|
|
2426
2413
|
}, []);
|
|
@@ -2448,18 +2435,18 @@ function getDistance(touches) {
|
|
|
2448
2435
|
}
|
|
2449
2436
|
function usePinchZoom(options = {}) {
|
|
2450
2437
|
const { minScale = 0.5, maxScale = 4 } = options;
|
|
2451
|
-
const [scale, setScale] =
|
|
2452
|
-
const [isPinching, setIsPinching] =
|
|
2453
|
-
const initialDistance =
|
|
2454
|
-
const initialScale =
|
|
2455
|
-
const onTouchStart =
|
|
2438
|
+
const [scale, setScale] = React.useState(1);
|
|
2439
|
+
const [isPinching, setIsPinching] = React.useState(false);
|
|
2440
|
+
const initialDistance = React.useRef(0);
|
|
2441
|
+
const initialScale = React.useRef(1);
|
|
2442
|
+
const onTouchStart = React.useCallback((e) => {
|
|
2456
2443
|
if (e.touches.length === 2) {
|
|
2457
2444
|
initialDistance.current = getDistance(e.touches);
|
|
2458
2445
|
initialScale.current = scale;
|
|
2459
2446
|
setIsPinching(true);
|
|
2460
2447
|
}
|
|
2461
2448
|
}, [scale]);
|
|
2462
|
-
const onTouchMove =
|
|
2449
|
+
const onTouchMove = React.useCallback((e) => {
|
|
2463
2450
|
if (e.touches.length !== 2 || !isPinching) return;
|
|
2464
2451
|
e.preventDefault();
|
|
2465
2452
|
const currentDistance = getDistance(e.touches);
|
|
@@ -2467,10 +2454,10 @@ function usePinchZoom(options = {}) {
|
|
|
2467
2454
|
const newScale = Math.min(maxScale, Math.max(minScale, initialScale.current * ratio));
|
|
2468
2455
|
setScale(newScale);
|
|
2469
2456
|
}, [isPinching, minScale, maxScale]);
|
|
2470
|
-
const onTouchEnd =
|
|
2457
|
+
const onTouchEnd = React.useCallback(() => {
|
|
2471
2458
|
setIsPinching(false);
|
|
2472
2459
|
}, []);
|
|
2473
|
-
const resetZoom =
|
|
2460
|
+
const resetZoom = React.useCallback(() => {
|
|
2474
2461
|
setScale(1);
|
|
2475
2462
|
}, []);
|
|
2476
2463
|
return {
|
|
@@ -2486,9 +2473,9 @@ function usePinchZoom(options = {}) {
|
|
|
2486
2473
|
}
|
|
2487
2474
|
var ALMADAR_DND_MIME = "application/x-almadar-dnd";
|
|
2488
2475
|
function useDraggable({ payload, disabled = false }) {
|
|
2489
|
-
const [isDragging, setIsDragging] =
|
|
2476
|
+
const [isDragging, setIsDragging] = React.useState(false);
|
|
2490
2477
|
const eventBus = useEventBus();
|
|
2491
|
-
const handleDragStart =
|
|
2478
|
+
const handleDragStart = React.useCallback(
|
|
2492
2479
|
(e) => {
|
|
2493
2480
|
if (disabled) {
|
|
2494
2481
|
e.preventDefault();
|
|
@@ -2501,14 +2488,14 @@ function useDraggable({ payload, disabled = false }) {
|
|
|
2501
2488
|
},
|
|
2502
2489
|
[disabled, payload, eventBus]
|
|
2503
2490
|
);
|
|
2504
|
-
const handleDragEnd =
|
|
2491
|
+
const handleDragEnd = React.useCallback(
|
|
2505
2492
|
(e) => {
|
|
2506
2493
|
setIsDragging(false);
|
|
2507
2494
|
eventBus.emit("UI:DRAG_END", { kind: payload.kind, data: payload.data });
|
|
2508
2495
|
},
|
|
2509
2496
|
[payload, eventBus]
|
|
2510
2497
|
);
|
|
2511
|
-
const dragProps =
|
|
2498
|
+
const dragProps = React.useMemo(
|
|
2512
2499
|
() => ({
|
|
2513
2500
|
draggable: !disabled,
|
|
2514
2501
|
onDragStart: handleDragStart,
|
|
@@ -2534,9 +2521,9 @@ function hasAlmadarPayload(e) {
|
|
|
2534
2521
|
return e.dataTransfer.types.includes(ALMADAR_DND_MIME);
|
|
2535
2522
|
}
|
|
2536
2523
|
function useDropZone({ accepts, onDrop, disabled = false }) {
|
|
2537
|
-
const [isOver, setIsOver] =
|
|
2524
|
+
const [isOver, setIsOver] = React.useState(false);
|
|
2538
2525
|
const eventBus = useEventBus();
|
|
2539
|
-
const handleDragOver =
|
|
2526
|
+
const handleDragOver = React.useCallback(
|
|
2540
2527
|
(e) => {
|
|
2541
2528
|
if (disabled) return;
|
|
2542
2529
|
if (!hasAlmadarPayload(e)) return;
|
|
@@ -2546,13 +2533,13 @@ function useDropZone({ accepts, onDrop, disabled = false }) {
|
|
|
2546
2533
|
},
|
|
2547
2534
|
[disabled]
|
|
2548
2535
|
);
|
|
2549
|
-
const handleDragLeave =
|
|
2536
|
+
const handleDragLeave = React.useCallback(
|
|
2550
2537
|
(e) => {
|
|
2551
2538
|
setIsOver(false);
|
|
2552
2539
|
},
|
|
2553
2540
|
[]
|
|
2554
2541
|
);
|
|
2555
|
-
const handleDrop =
|
|
2542
|
+
const handleDrop = React.useCallback(
|
|
2556
2543
|
(e) => {
|
|
2557
2544
|
e.preventDefault();
|
|
2558
2545
|
setIsOver(false);
|
|
@@ -2566,7 +2553,7 @@ function useDropZone({ accepts, onDrop, disabled = false }) {
|
|
|
2566
2553
|
},
|
|
2567
2554
|
[disabled, accepts, onDrop, eventBus]
|
|
2568
2555
|
);
|
|
2569
|
-
const dropProps =
|
|
2556
|
+
const dropProps = React.useMemo(
|
|
2570
2557
|
() => ({
|
|
2571
2558
|
onDragOver: handleDragOver,
|
|
2572
2559
|
onDragLeave: handleDragLeave,
|
|
@@ -2606,7 +2593,7 @@ function useGitHubStatus() {
|
|
|
2606
2593
|
});
|
|
2607
2594
|
}
|
|
2608
2595
|
function useConnectGitHub() {
|
|
2609
|
-
const connectGitHub =
|
|
2596
|
+
const connectGitHub = React.useCallback(() => {
|
|
2610
2597
|
const userId = getUserId();
|
|
2611
2598
|
const state = btoa(JSON.stringify({ userId, returnUrl: window.location.href }));
|
|
2612
2599
|
window.location.href = `${API_BASE}/api/github/oauth/authorize?state=${state}`;
|