@almadar/ui 4.44.1 → 4.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/avl/index.cjs +170 -141
- package/dist/avl/index.js +171 -142
- package/dist/components/index.cjs +103 -62
- package/dist/components/index.js +104 -63
- package/dist/components/organisms/game/three/index.cjs +18 -15
- package/dist/components/organisms/game/three/index.js +18 -15
- package/dist/context/index.cjs +17 -12
- package/dist/context/index.js +17 -12
- package/dist/docs/index.cjs +2 -2
- package/dist/docs/index.js +2 -2
- package/dist/hooks/index.cjs +52 -40
- package/dist/hooks/index.js +52 -40
- package/dist/lib/debug.d.ts +15 -22
- package/dist/lib/index.cjs +61 -47
- package/dist/lib/index.js +62 -48
- package/dist/marketing/index.cjs +2 -2
- package/dist/marketing/index.js +2 -2
- package/dist/providers/EventBusProvider.d.ts +6 -2
- package/dist/providers/index.cjs +111 -88
- package/dist/providers/index.js +111 -88
- package/dist/renderer/index.cjs +57 -56
- package/dist/renderer/index.js +57 -56
- package/dist/runtime/index.cjs +101 -73
- package/dist/runtime/index.js +102 -74
- package/package.json +3 -3
package/dist/hooks/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createContext, useCallback, useState, useEffect, useMemo, useContext, useRef, useSyncExternalStore } from 'react';
|
|
2
|
-
import { EventBusContext, useTraitScope } from '@almadar/ui/providers';
|
|
3
2
|
import { createLogger } from '@almadar/logger';
|
|
3
|
+
import { EventBusContext, useTraitScope } from '@almadar/ui/providers';
|
|
4
4
|
import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
|
|
5
5
|
|
|
6
|
+
var log = createLogger("almadar:ui:orbital-history");
|
|
6
7
|
function useOrbitalHistory(options) {
|
|
7
8
|
const { appId, authToken, userId, onHistoryChange, onRevertSuccess } = options;
|
|
8
9
|
const getHeaders = useCallback(() => {
|
|
@@ -64,7 +65,7 @@ function useOrbitalHistory(options) {
|
|
|
64
65
|
setCurrentVersion(mergedTimeline[0].version);
|
|
65
66
|
}
|
|
66
67
|
} catch (err) {
|
|
67
|
-
|
|
68
|
+
log.error("Failed to load history", { error: err instanceof Error ? err : String(err) });
|
|
68
69
|
setError(err instanceof Error ? err.message : "Failed to load history");
|
|
69
70
|
} finally {
|
|
70
71
|
setIsLoading(false);
|
|
@@ -97,7 +98,7 @@ function useOrbitalHistory(options) {
|
|
|
97
98
|
error: data.error || "Unknown error during revert"
|
|
98
99
|
};
|
|
99
100
|
} catch (err) {
|
|
100
|
-
|
|
101
|
+
log.error("Failed to revert", { error: err instanceof Error ? err : String(err) });
|
|
101
102
|
return {
|
|
102
103
|
success: false,
|
|
103
104
|
error: err instanceof Error ? err.message : "Failed to revert"
|
|
@@ -121,6 +122,7 @@ function useOrbitalHistory(options) {
|
|
|
121
122
|
refresh
|
|
122
123
|
};
|
|
123
124
|
}
|
|
125
|
+
var log2 = createLogger("almadar:ui:filesystem");
|
|
124
126
|
function useFileSystem() {
|
|
125
127
|
const [status, setStatus] = useState("idle");
|
|
126
128
|
const [error, setError] = useState(null);
|
|
@@ -135,7 +137,7 @@ function useFileSystem() {
|
|
|
135
137
|
setError(null);
|
|
136
138
|
setIsLoading(true);
|
|
137
139
|
try {
|
|
138
|
-
|
|
140
|
+
log2.debug("Booting WebContainer");
|
|
139
141
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
140
142
|
setStatus("ready");
|
|
141
143
|
} catch (err) {
|
|
@@ -198,7 +200,7 @@ function useFileSystem() {
|
|
|
198
200
|
setFiles(newTree);
|
|
199
201
|
setStatus("running");
|
|
200
202
|
} catch (err) {
|
|
201
|
-
|
|
203
|
+
log2.error("Failed to mount files", { error: err instanceof Error ? err : String(err) });
|
|
202
204
|
} finally {
|
|
203
205
|
setIsLoading(false);
|
|
204
206
|
}
|
|
@@ -239,7 +241,7 @@ function useFileSystem() {
|
|
|
239
241
|
const path = contentArg !== void 0 ? pathOrContent : selectedPath;
|
|
240
242
|
const content = contentArg !== void 0 ? contentArg : pathOrContent;
|
|
241
243
|
if (!path) {
|
|
242
|
-
|
|
244
|
+
log2.warn("updateContent called without path and no file selected");
|
|
243
245
|
return;
|
|
244
246
|
}
|
|
245
247
|
setFileContents((prev) => {
|
|
@@ -255,14 +257,14 @@ function useFileSystem() {
|
|
|
255
257
|
setSelectedFile((prev) => prev ? { ...prev, content, isDirty: true } : null);
|
|
256
258
|
}, []);
|
|
257
259
|
const refreshTree = useCallback(async () => {
|
|
258
|
-
|
|
260
|
+
log2.debug("Refreshing tree");
|
|
259
261
|
}, []);
|
|
260
262
|
const runCommand = useCallback(async (command) => {
|
|
261
|
-
|
|
263
|
+
log2.debug("Running command", { command });
|
|
262
264
|
return { exitCode: 0, output: "" };
|
|
263
265
|
}, []);
|
|
264
266
|
const startDevServer = useCallback(async () => {
|
|
265
|
-
|
|
267
|
+
log2.debug("Starting dev server");
|
|
266
268
|
setPreviewUrl("http://localhost:5173");
|
|
267
269
|
}, []);
|
|
268
270
|
return {
|
|
@@ -285,6 +287,7 @@ function useFileSystem() {
|
|
|
285
287
|
startDevServer
|
|
286
288
|
};
|
|
287
289
|
}
|
|
290
|
+
var log3 = createLogger("almadar:ui:extensions");
|
|
288
291
|
var defaultManifest = {
|
|
289
292
|
languages: {
|
|
290
293
|
typescript: { extensions: [".ts", ".tsx"], icon: "ts", color: "#3178c6" },
|
|
@@ -303,7 +306,7 @@ function useExtensions(options) {
|
|
|
303
306
|
const [isLoading, setIsLoading] = useState(false);
|
|
304
307
|
const [error, setError] = useState(null);
|
|
305
308
|
const loadExtension = useCallback(async (extensionId) => {
|
|
306
|
-
|
|
309
|
+
log3.debug("Loading extension", { extensionId });
|
|
307
310
|
}, []);
|
|
308
311
|
const loadExtensions = useCallback(async () => {
|
|
309
312
|
setIsLoading(true);
|
|
@@ -375,6 +378,7 @@ function useExtensions(options) {
|
|
|
375
378
|
getExtensionForFile
|
|
376
379
|
};
|
|
377
380
|
}
|
|
381
|
+
var log4 = createLogger("almadar:ui:file-editor");
|
|
378
382
|
function useFileEditor(options) {
|
|
379
383
|
const { extensions, fileSystem, onSchemaUpdate } = options;
|
|
380
384
|
const [openFiles, setOpenFiles] = useState([]);
|
|
@@ -399,7 +403,7 @@ function useFileEditor(options) {
|
|
|
399
403
|
setOpenFiles((prev) => [...prev, newFile]);
|
|
400
404
|
setActiveFilePath(path);
|
|
401
405
|
} catch (err) {
|
|
402
|
-
|
|
406
|
+
log4.error("Failed to open file", { error: err instanceof Error ? err : String(err) });
|
|
403
407
|
}
|
|
404
408
|
}, [openFiles, fileSystem, extensions]);
|
|
405
409
|
const closeFile = useCallback((path) => {
|
|
@@ -460,7 +464,7 @@ function useFileEditor(options) {
|
|
|
460
464
|
}
|
|
461
465
|
}
|
|
462
466
|
} catch (err) {
|
|
463
|
-
|
|
467
|
+
log4.error("Failed to save file", { error: err instanceof Error ? err : String(err) });
|
|
464
468
|
} finally {
|
|
465
469
|
setIsSaving(false);
|
|
466
470
|
}
|
|
@@ -489,6 +493,7 @@ function useFileEditor(options) {
|
|
|
489
493
|
saveAllFiles
|
|
490
494
|
};
|
|
491
495
|
}
|
|
496
|
+
var log5 = createLogger("almadar:ui:compile");
|
|
492
497
|
function useCompile() {
|
|
493
498
|
const [isCompiling, setIsCompiling] = useState(false);
|
|
494
499
|
const [stage, setStage] = useState("idle");
|
|
@@ -499,7 +504,7 @@ function useCompile() {
|
|
|
499
504
|
setStage("compiling");
|
|
500
505
|
setError(null);
|
|
501
506
|
try {
|
|
502
|
-
|
|
507
|
+
log5.debug("Compiling schema", { name: schema.name });
|
|
503
508
|
const result = {
|
|
504
509
|
success: true,
|
|
505
510
|
files: []
|
|
@@ -525,6 +530,7 @@ function useCompile() {
|
|
|
525
530
|
compileSchema
|
|
526
531
|
};
|
|
527
532
|
}
|
|
533
|
+
var log6 = createLogger("almadar:ui:preview");
|
|
528
534
|
function usePreview(options) {
|
|
529
535
|
const [previewUrl, setPreviewUrl] = useState(null);
|
|
530
536
|
const [isLoading, setIsLoading] = useState(!!options?.appId);
|
|
@@ -558,17 +564,17 @@ function usePreview(options) {
|
|
|
558
564
|
setIsLoading(false);
|
|
559
565
|
return;
|
|
560
566
|
}
|
|
561
|
-
|
|
567
|
+
log6.debug("Setting up preview for app", { appId });
|
|
562
568
|
setPreviewUrl(`/api/orbitals/${appId}`);
|
|
563
569
|
setIsLoading(false);
|
|
564
570
|
}, [options?.appId]);
|
|
565
571
|
const startPreview = useCallback(async () => {
|
|
566
|
-
|
|
572
|
+
log6.debug("startPreview called");
|
|
567
573
|
}, []);
|
|
568
574
|
const stopPreview = useCallback(async () => {
|
|
569
575
|
setIsLoading(true);
|
|
570
576
|
try {
|
|
571
|
-
|
|
577
|
+
log6.debug("Stopping preview server");
|
|
572
578
|
setPreviewUrl(null);
|
|
573
579
|
setApp(null);
|
|
574
580
|
} finally {
|
|
@@ -577,15 +583,15 @@ function usePreview(options) {
|
|
|
577
583
|
}, []);
|
|
578
584
|
const refresh = useCallback(async () => {
|
|
579
585
|
if (!previewUrl) return;
|
|
580
|
-
|
|
586
|
+
log6.debug("Refreshing preview");
|
|
581
587
|
setPreviewUrl(`${previewUrl.split("?")[0]}?t=${Date.now()}`);
|
|
582
588
|
}, [previewUrl]);
|
|
583
589
|
const handleRefresh = useCallback(async () => {
|
|
584
|
-
|
|
590
|
+
log6.debug("Handle refresh");
|
|
585
591
|
await refresh();
|
|
586
592
|
}, [refresh]);
|
|
587
593
|
const handleReset = useCallback(async () => {
|
|
588
|
-
|
|
594
|
+
log6.debug("Resetting preview");
|
|
589
595
|
setError(null);
|
|
590
596
|
setLoadError(null);
|
|
591
597
|
setErrorToast(null);
|
|
@@ -619,6 +625,7 @@ function usePreview(options) {
|
|
|
619
625
|
dismissErrorToast
|
|
620
626
|
};
|
|
621
627
|
}
|
|
628
|
+
var log7 = createLogger("almadar:ui:agent-chat");
|
|
622
629
|
function useAgentChat(options) {
|
|
623
630
|
const [messages, setMessages] = useState([]);
|
|
624
631
|
const [status, setStatus] = useState("idle");
|
|
@@ -641,7 +648,7 @@ function useAgentChat(options) {
|
|
|
641
648
|
timestamp: Date.now()
|
|
642
649
|
};
|
|
643
650
|
setMessages((prev) => [...prev, userMessage]);
|
|
644
|
-
|
|
651
|
+
log7.debug("Sending message", { content });
|
|
645
652
|
const assistantMessage = {
|
|
646
653
|
id: (Date.now() + 1).toString(),
|
|
647
654
|
role: "assistant",
|
|
@@ -664,7 +671,7 @@ function useAgentChat(options) {
|
|
|
664
671
|
setError(null);
|
|
665
672
|
const skillName = Array.isArray(skill) ? skill[0] : skill;
|
|
666
673
|
try {
|
|
667
|
-
|
|
674
|
+
log7.debug("Starting generation", () => ({ skillName, prompt, genOptions: JSON.stringify(genOptions) }));
|
|
668
675
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
669
676
|
setStatus("complete");
|
|
670
677
|
options?.onComplete?.();
|
|
@@ -676,10 +683,10 @@ function useAgentChat(options) {
|
|
|
676
683
|
}
|
|
677
684
|
}, [options]);
|
|
678
685
|
const continueConversation = useCallback(async (message) => {
|
|
679
|
-
|
|
686
|
+
log7.debug("Continue conversation", { message: Array.isArray(message) ? message : [message] });
|
|
680
687
|
}, []);
|
|
681
688
|
const resumeWithDecision = useCallback(async (decisions) => {
|
|
682
|
-
|
|
689
|
+
log7.debug("Resume with decision", () => ({ decisions: JSON.stringify(decisions), count: decisions.length }));
|
|
683
690
|
setInterrupt(null);
|
|
684
691
|
}, []);
|
|
685
692
|
const cancel = useCallback(() => {
|
|
@@ -716,6 +723,7 @@ function useAgentChat(options) {
|
|
|
716
723
|
clearHistory
|
|
717
724
|
};
|
|
718
725
|
}
|
|
726
|
+
var log8 = createLogger("almadar:ui:validation");
|
|
719
727
|
function useValidation() {
|
|
720
728
|
const [result, setResult] = useState(null);
|
|
721
729
|
const [isValidating, setIsValidating] = useState(false);
|
|
@@ -729,7 +737,7 @@ function useValidation() {
|
|
|
729
737
|
setStage("validating");
|
|
730
738
|
setProgressMessage("Validating schema...");
|
|
731
739
|
try {
|
|
732
|
-
|
|
740
|
+
log8.debug("Validating app", { appId });
|
|
733
741
|
const validationResult = {
|
|
734
742
|
valid: true,
|
|
735
743
|
errors: [],
|
|
@@ -782,6 +790,7 @@ function useValidation() {
|
|
|
782
790
|
reset
|
|
783
791
|
};
|
|
784
792
|
}
|
|
793
|
+
var log9 = createLogger("almadar:ui:deep-agent");
|
|
785
794
|
function useDeepAgentGeneration() {
|
|
786
795
|
const [requests, setRequests] = useState([]);
|
|
787
796
|
const [currentRequest, setCurrentRequest] = useState(null);
|
|
@@ -805,7 +814,7 @@ function useDeepAgentGeneration() {
|
|
|
805
814
|
setCurrentRequest(request);
|
|
806
815
|
setRequests((prev) => [...prev, request]);
|
|
807
816
|
try {
|
|
808
|
-
|
|
817
|
+
log9.debug("Generating from prompt", { prompt });
|
|
809
818
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
810
819
|
request.status = "completed";
|
|
811
820
|
setCurrentRequest(request);
|
|
@@ -825,7 +834,7 @@ function useDeepAgentGeneration() {
|
|
|
825
834
|
}
|
|
826
835
|
}, []);
|
|
827
836
|
const startGeneration = useCallback(async (skill, prompt, _options) => {
|
|
828
|
-
|
|
837
|
+
log9.debug("Starting generation with skill", { skill });
|
|
829
838
|
await generate(prompt);
|
|
830
839
|
}, [generate]);
|
|
831
840
|
const cancelGeneration = useCallback(() => {
|
|
@@ -847,7 +856,7 @@ function useDeepAgentGeneration() {
|
|
|
847
856
|
setIsComplete(false);
|
|
848
857
|
}, []);
|
|
849
858
|
const submitInterruptDecisions = useCallback((decisions) => {
|
|
850
|
-
|
|
859
|
+
log9.debug("Submitting interrupt decisions", () => ({ decisions: JSON.stringify(decisions), count: decisions.length }));
|
|
851
860
|
setInterrupt(null);
|
|
852
861
|
}, []);
|
|
853
862
|
return {
|
|
@@ -866,7 +875,7 @@ function useDeepAgentGeneration() {
|
|
|
866
875
|
submitInterruptDecisions
|
|
867
876
|
};
|
|
868
877
|
}
|
|
869
|
-
var
|
|
878
|
+
var log10 = createLogger("almadar:eventbus");
|
|
870
879
|
var subLog = createLogger("almadar:eventbus:subscribe");
|
|
871
880
|
var scopeLog = createLogger("almadar:ui:trait-scope");
|
|
872
881
|
function getGlobalEventBus() {
|
|
@@ -886,13 +895,13 @@ var fallbackEventBus = {
|
|
|
886
895
|
source
|
|
887
896
|
};
|
|
888
897
|
const handlers = fallbackListeners.get(type);
|
|
889
|
-
|
|
898
|
+
log10.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
|
|
890
899
|
if (handlers) {
|
|
891
900
|
handlers.forEach((handler) => {
|
|
892
901
|
try {
|
|
893
902
|
handler(event);
|
|
894
903
|
} catch (error) {
|
|
895
|
-
|
|
904
|
+
log10.error("Error in listener", { type, error: error instanceof Error ? error : String(error) });
|
|
896
905
|
}
|
|
897
906
|
});
|
|
898
907
|
}
|
|
@@ -900,7 +909,7 @@ var fallbackEventBus = {
|
|
|
900
909
|
try {
|
|
901
910
|
handler(event);
|
|
902
911
|
} catch (error) {
|
|
903
|
-
|
|
912
|
+
log10.error("Error in onAny listener", { type, error: error instanceof Error ? error : String(error) });
|
|
904
913
|
}
|
|
905
914
|
});
|
|
906
915
|
},
|
|
@@ -1000,7 +1009,7 @@ function useEmitEvent() {
|
|
|
1000
1009
|
[eventBus]
|
|
1001
1010
|
);
|
|
1002
1011
|
}
|
|
1003
|
-
var
|
|
1012
|
+
var log11 = createLogger("almadar:ui:ui-slots");
|
|
1004
1013
|
var DEFAULT_SOURCE_KEY = "__default__";
|
|
1005
1014
|
var MULTI_SOURCE_STACK_TRAIT = "__multi_source_stack__";
|
|
1006
1015
|
var ALL_SLOTS = [
|
|
@@ -1082,7 +1091,7 @@ function useUISlotManager() {
|
|
|
1082
1091
|
try {
|
|
1083
1092
|
callback(slot, content);
|
|
1084
1093
|
} catch (error) {
|
|
1085
|
-
|
|
1094
|
+
log11.error("Subscriber error", { error: error instanceof Error ? error : String(error) });
|
|
1086
1095
|
}
|
|
1087
1096
|
});
|
|
1088
1097
|
}, []);
|
|
@@ -1094,7 +1103,7 @@ function useUISlotManager() {
|
|
|
1094
1103
|
try {
|
|
1095
1104
|
callback(content);
|
|
1096
1105
|
} catch (error) {
|
|
1097
|
-
|
|
1106
|
+
log11.error("Trait subscriber error", { traitName, error: error instanceof Error ? error : String(error) });
|
|
1098
1107
|
}
|
|
1099
1108
|
});
|
|
1100
1109
|
},
|
|
@@ -1145,9 +1154,12 @@ function useUISlotManager() {
|
|
|
1145
1154
|
const slotSources = prev[config.target] ?? {};
|
|
1146
1155
|
const existing = slotSources[sourceKey];
|
|
1147
1156
|
if (existing && existing.priority > content.priority) {
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1157
|
+
log11.warn("Slot already has higher priority content", {
|
|
1158
|
+
slot: config.target,
|
|
1159
|
+
sourceKey,
|
|
1160
|
+
existingPriority: existing.priority,
|
|
1161
|
+
newPriority: content.priority
|
|
1162
|
+
});
|
|
1151
1163
|
return prev;
|
|
1152
1164
|
}
|
|
1153
1165
|
const nextSources = {
|
|
@@ -1159,7 +1171,7 @@ function useUISlotManager() {
|
|
|
1159
1171
|
indexTraitRender(content.sourceTrait, content);
|
|
1160
1172
|
notifyTraitSubscribers(content.sourceTrait, content);
|
|
1161
1173
|
}
|
|
1162
|
-
|
|
1174
|
+
log11.info("slot:written", {
|
|
1163
1175
|
slot: config.target,
|
|
1164
1176
|
sourceKey,
|
|
1165
1177
|
sourceTrait: content.sourceTrait,
|
|
@@ -1204,7 +1216,7 @@ function useUISlotManager() {
|
|
|
1204
1216
|
setSources((prev) => {
|
|
1205
1217
|
const slotSources = prev[slot];
|
|
1206
1218
|
if (!slotSources || !(sourceKey in slotSources)) {
|
|
1207
|
-
|
|
1219
|
+
log11.debug("slot:clear-noop", { slot, sourceTrait, reason: !slotSources ? "no-slot" : "no-source" });
|
|
1208
1220
|
return prev;
|
|
1209
1221
|
}
|
|
1210
1222
|
const content = slotSources[sourceKey];
|
|
@@ -1220,7 +1232,7 @@ function useUISlotManager() {
|
|
|
1220
1232
|
}
|
|
1221
1233
|
const nextSources = { ...slotSources };
|
|
1222
1234
|
delete nextSources[sourceKey];
|
|
1223
|
-
|
|
1235
|
+
log11.info("slot:cleared", { slot, sourceTrait, lastPatternType: content.pattern });
|
|
1224
1236
|
notifySubscribers(slot, aggregateSlot(nextSources));
|
|
1225
1237
|
return { ...prev, [slot]: nextSources };
|
|
1226
1238
|
});
|
package/dist/lib/debug.d.ts
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Legacy debug helpers, now routed through `@almadar/logger`.
|
|
3
|
+
*
|
|
4
|
+
* The variadic `debug(...args)` shape is preserved for the many existing
|
|
5
|
+
* call sites (Form.tsx, RelationSelect.tsx, game helpers, etc.), but the
|
|
6
|
+
* gate is no longer a separate localStorage check — every helper here
|
|
7
|
+
* runs through the same priority/namespace gate the rest of the codebase
|
|
8
|
+
* uses. `setLogLevel('WARN')` silences them. `globalThis.__ALMADAR_DEBUG__`
|
|
9
|
+
* filters them by namespace.
|
|
10
|
+
*
|
|
11
|
+
* Namespace: `almadar:ui:debug` (plus per-area suffixes for input,
|
|
12
|
+
* collision, physics, game-state).
|
|
3
13
|
*/
|
|
4
14
|
export declare function isDebugEnabled(): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Variadic legacy debug. The first arg is the message; the rest is
|
|
17
|
+
* stringified into the LogData. Routes through the shared gate.
|
|
18
|
+
*/
|
|
5
19
|
export declare function debug(...args: unknown[]): void;
|
|
6
20
|
export declare function debugGroup(label: string): void;
|
|
7
21
|
export declare function debugGroupEnd(): void;
|
|
@@ -10,18 +24,7 @@ export declare function debugError(...args: unknown[]): void;
|
|
|
10
24
|
export declare function debugTable(data: unknown): void;
|
|
11
25
|
export declare function debugTime(label: string): void;
|
|
12
26
|
export declare function debugTimeEnd(label: string): void;
|
|
13
|
-
/**
|
|
14
|
-
* Debug input events (keyboard, mouse, touch)
|
|
15
|
-
* @param inputType - Type of input (e.g., 'keydown', 'keyup', 'mouse')
|
|
16
|
-
* @param data - Input data to log
|
|
17
|
-
*/
|
|
18
27
|
export declare function debugInput(inputType: string, data: unknown): void;
|
|
19
|
-
/**
|
|
20
|
-
* Debug collision events between entities
|
|
21
|
-
* @param entityA - First entity in collision
|
|
22
|
-
* @param entityB - Second entity in collision
|
|
23
|
-
* @param details - Additional collision details
|
|
24
|
-
*/
|
|
25
28
|
export declare function debugCollision(entityA: {
|
|
26
29
|
id?: string;
|
|
27
30
|
type?: string;
|
|
@@ -29,15 +32,5 @@ export declare function debugCollision(entityA: {
|
|
|
29
32
|
id?: string;
|
|
30
33
|
type?: string;
|
|
31
34
|
}, details?: unknown): void;
|
|
32
|
-
/**
|
|
33
|
-
* Debug physics updates (position, velocity)
|
|
34
|
-
* @param entityId - Entity identifier
|
|
35
|
-
* @param physics - Physics data to log
|
|
36
|
-
*/
|
|
37
35
|
export declare function debugPhysics(entityId: string, physics: unknown): void;
|
|
38
|
-
/**
|
|
39
|
-
* Debug game state changes
|
|
40
|
-
* @param stateName - Name of the state that changed
|
|
41
|
-
* @param value - New state value
|
|
42
|
-
*/
|
|
43
36
|
export declare function debugGameState(stateName: string, value: unknown): void;
|
package/dist/lib/index.cjs
CHANGED
|
@@ -102,75 +102,89 @@ var apiClient = {
|
|
|
102
102
|
return handleResponse(response);
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
var
|
|
105
|
+
var NAMESPACE = "almadar:ui:debug";
|
|
106
|
+
var log = logger.createLogger(NAMESPACE);
|
|
107
|
+
var inputLog = logger.createLogger("almadar:ui:debug:input");
|
|
108
|
+
var collisionLog = logger.createLogger("almadar:ui:debug:collision");
|
|
109
|
+
var physicsLog = logger.createLogger("almadar:ui:debug:physics");
|
|
110
|
+
var gameStateLog = logger.createLogger("almadar:ui:debug:game-state");
|
|
111
|
+
function gateEnabled(level, ns = NAMESPACE) {
|
|
112
|
+
return logger.isLogLevelEnabled(level, ns);
|
|
113
|
+
}
|
|
108
114
|
function isDebugEnabled() {
|
|
109
|
-
|
|
110
|
-
return typeof window !== "undefined" && window.__ALMADAR_DEBUG_VERIFY__ === true;
|
|
115
|
+
return gateEnabled("DEBUG");
|
|
111
116
|
}
|
|
112
117
|
function debug(...args) {
|
|
113
|
-
if (
|
|
114
|
-
|
|
118
|
+
if (!gateEnabled("DEBUG")) return;
|
|
119
|
+
const [first, ...rest] = args;
|
|
120
|
+
const message = typeof first === "string" ? first : "<debug>";
|
|
121
|
+
if (rest.length === 0 && typeof first === "string") {
|
|
122
|
+
log.debug(message);
|
|
123
|
+
} else {
|
|
124
|
+
log.debug(message, { args: rest.length > 0 ? formatArgs(rest) : formatArgs([first]) });
|
|
115
125
|
}
|
|
116
126
|
}
|
|
117
127
|
function debugGroup(label) {
|
|
118
|
-
if (
|
|
119
|
-
console.group(`[DEBUG] ${label}`);
|
|
120
|
-
}
|
|
128
|
+
if (gateEnabled("DEBUG")) console.group(`[${NAMESPACE}] ${label}`);
|
|
121
129
|
}
|
|
122
130
|
function debugGroupEnd() {
|
|
123
|
-
if (
|
|
124
|
-
console.groupEnd();
|
|
125
|
-
}
|
|
131
|
+
if (gateEnabled("DEBUG")) console.groupEnd();
|
|
126
132
|
}
|
|
127
133
|
function debugWarn(...args) {
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
|
|
134
|
+
if (!gateEnabled("WARN")) return;
|
|
135
|
+
const [first, ...rest] = args;
|
|
136
|
+
const message = typeof first === "string" ? first : "<warn>";
|
|
137
|
+
log.warn(message, rest.length > 0 ? { args: formatArgs(rest) } : void 0);
|
|
131
138
|
}
|
|
132
139
|
function debugError(...args) {
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
|
|
140
|
+
if (!gateEnabled("ERROR")) return;
|
|
141
|
+
const [first, ...rest] = args;
|
|
142
|
+
const message = typeof first === "string" ? first : "<error>";
|
|
143
|
+
log.error(message, rest.length > 0 ? { args: formatArgs(rest) } : void 0);
|
|
136
144
|
}
|
|
137
145
|
function debugTable(data) {
|
|
138
|
-
if (
|
|
139
|
-
console.table(data);
|
|
140
|
-
}
|
|
146
|
+
if (gateEnabled("DEBUG")) console.table(data);
|
|
141
147
|
}
|
|
142
148
|
function debugTime(label) {
|
|
143
|
-
if (
|
|
144
|
-
console.time(`[DEBUG] ${label}`);
|
|
145
|
-
}
|
|
149
|
+
if (gateEnabled("DEBUG")) console.time(`[${NAMESPACE}] ${label}`);
|
|
146
150
|
}
|
|
147
151
|
function debugTimeEnd(label) {
|
|
148
|
-
if (
|
|
149
|
-
console.timeEnd(`[DEBUG] ${label}`);
|
|
150
|
-
}
|
|
152
|
+
if (gateEnabled("DEBUG")) console.timeEnd(`[${NAMESPACE}] ${label}`);
|
|
151
153
|
}
|
|
152
154
|
function debugInput(inputType, data) {
|
|
153
|
-
|
|
154
|
-
console.log(`[DEBUG:INPUT] ${inputType}:`, data);
|
|
155
|
-
}
|
|
155
|
+
inputLog.debug(inputType, { data: formatArgs([data]) });
|
|
156
156
|
}
|
|
157
157
|
function debugCollision(entityA, entityB, details) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
158
|
+
collisionLog.debug("collision", () => ({
|
|
159
|
+
a: entityA.type ?? entityA.id ?? null,
|
|
160
|
+
b: entityB.type ?? entityB.id ?? null,
|
|
161
|
+
details: details === void 0 ? null : formatArgs([details])
|
|
162
|
+
}));
|
|
164
163
|
}
|
|
165
164
|
function debugPhysics(entityId, physics) {
|
|
166
|
-
|
|
167
|
-
console.log(`[DEBUG:PHYSICS] ${entityId}:`, physics);
|
|
168
|
-
}
|
|
165
|
+
physicsLog.debug("physics", { entityId, data: formatArgs([physics]) });
|
|
169
166
|
}
|
|
170
167
|
function debugGameState(stateName, value) {
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
gameStateLog.debug(stateName, { value: formatArgs([value]) });
|
|
169
|
+
}
|
|
170
|
+
function formatArgs(values) {
|
|
171
|
+
if (values.length === 1) return toLogMetaValue(values[0]);
|
|
172
|
+
return values.map(toLogMetaValue);
|
|
173
|
+
}
|
|
174
|
+
function toLogMetaValue(v) {
|
|
175
|
+
if (v === null || v === void 0) return v;
|
|
176
|
+
if (v instanceof Error) return v;
|
|
177
|
+
const t = typeof v;
|
|
178
|
+
if (t === "string" || t === "number" || t === "boolean") return v;
|
|
179
|
+
if (Array.isArray(v)) return v.map(toLogMetaValue);
|
|
180
|
+
if (t === "object") {
|
|
181
|
+
const out = {};
|
|
182
|
+
for (const [k, val] of Object.entries(v)) {
|
|
183
|
+
out[k] = toLogMetaValue(val);
|
|
184
|
+
}
|
|
185
|
+
return out;
|
|
173
186
|
}
|
|
187
|
+
return String(v);
|
|
174
188
|
}
|
|
175
189
|
|
|
176
190
|
// lib/debugUtils.ts
|
|
@@ -431,7 +445,7 @@ function clearTraits() {
|
|
|
431
445
|
traits.clear();
|
|
432
446
|
notifyListeners4();
|
|
433
447
|
}
|
|
434
|
-
var
|
|
448
|
+
var log2 = logger.createLogger("almadar:bridge");
|
|
435
449
|
var MAX_TRANSITIONS = 500;
|
|
436
450
|
function getState() {
|
|
437
451
|
if (typeof window !== "undefined") {
|
|
@@ -482,7 +496,7 @@ function recordTransition(trace) {
|
|
|
482
496
|
...trace,
|
|
483
497
|
id: `t-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
|
|
484
498
|
};
|
|
485
|
-
|
|
499
|
+
log2.debug("transition:recorded", { trait: trace.traitName, from: trace.from, to: trace.to, event: trace.event, effectCount: trace.effects.length });
|
|
486
500
|
getState().transitions.push(entry);
|
|
487
501
|
if (getState().transitions.length > MAX_TRANSITIONS) {
|
|
488
502
|
getState().transitions.shift();
|
|
@@ -599,7 +613,7 @@ function getTraitSnapshots() {
|
|
|
599
613
|
try {
|
|
600
614
|
snapshots.push(getter());
|
|
601
615
|
} catch (err) {
|
|
602
|
-
|
|
616
|
+
log2.error("traitSnapshot getter failed", { trait: traitName, err: String(err) });
|
|
603
617
|
}
|
|
604
618
|
}
|
|
605
619
|
return snapshots;
|
|
@@ -647,12 +661,12 @@ function waitForTransition(event, timeoutMs = 1e4) {
|
|
|
647
661
|
}
|
|
648
662
|
function bindEventBus(eventBus) {
|
|
649
663
|
if (typeof window === "undefined") return;
|
|
650
|
-
|
|
664
|
+
log2.info("bindEventBus", { hasOnAny: !!eventBus.onAny });
|
|
651
665
|
exposeOnWindow();
|
|
652
666
|
if (window.__orbitalVerification) {
|
|
653
667
|
window.__orbitalVerification.sendEvent = (event, payload, traitScope) => {
|
|
654
668
|
const prefixed = event.startsWith("UI:") ? event : traitScope ? `UI:${traitScope}.${event}` : `UI:${event}`;
|
|
655
|
-
|
|
669
|
+
log2.debug("sendEvent", { event: prefixed, traitScope, payloadKeys: payload ? Object.keys(payload) : [] });
|
|
656
670
|
eventBus.emit(prefixed, payload);
|
|
657
671
|
};
|
|
658
672
|
const eventLog = [];
|