@almadar/ui 2.46.1 → 2.47.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 +101 -7
- package/dist/avl/index.js +100 -7
- package/dist/components/index.cjs +98 -66
- package/dist/components/index.js +97 -66
- package/dist/components/organisms/game/three/index.cjs +65 -0
- package/dist/components/organisms/game/three/index.js +64 -0
- package/dist/docs/index.cjs +65 -0
- package/dist/docs/index.js +64 -0
- package/dist/hooks/index.cjs +87 -62
- package/dist/hooks/index.js +86 -62
- package/dist/lib/index.cjs +68 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +66 -1
- package/dist/lib/logger.d.ts +16 -0
- package/dist/marketing/index.cjs +65 -0
- package/dist/marketing/index.js +64 -0
- package/dist/providers/index.cjs +84 -2
- package/dist/providers/index.js +83 -2
- package/dist/runtime/index.cjs +89 -5
- package/dist/runtime/index.js +88 -5
- package/package.json +1 -1
|
@@ -39,6 +39,7 @@ var patterns = require('@almadar/patterns');
|
|
|
39
39
|
var reactRouterDom = require('react-router-dom');
|
|
40
40
|
var reactQuery = require('@tanstack/react-query');
|
|
41
41
|
|
|
42
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
42
43
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
43
44
|
|
|
44
45
|
function _interopNamespace(e) {
|
|
@@ -91,6 +92,67 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
91
92
|
function cn(...inputs) {
|
|
92
93
|
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
93
94
|
}
|
|
95
|
+
|
|
96
|
+
// lib/logger.ts
|
|
97
|
+
var LEVEL_PRIORITY = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3 };
|
|
98
|
+
var ENV = typeof process !== "undefined" && process.env ? process.env : {};
|
|
99
|
+
var VITE_ENV = typeof globalThis !== "undefined" && globalThis.__vite_env__ ? globalThis.__vite_env__ : {};
|
|
100
|
+
function getViteEnv(key) {
|
|
101
|
+
try {
|
|
102
|
+
const meta = ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)) });
|
|
103
|
+
return meta?.env?.[key];
|
|
104
|
+
} catch {
|
|
105
|
+
return void 0;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function envGet(key, viteKey) {
|
|
109
|
+
return ENV[key] ?? (viteKey ? getViteEnv(viteKey) : void 0) ?? VITE_ENV[viteKey ?? key];
|
|
110
|
+
}
|
|
111
|
+
var NODE_ENV = envGet("NODE_ENV", "VITE_NODE_ENV") ?? "development";
|
|
112
|
+
var CONFIGURED_LEVEL = (envGet("LOG_LEVEL", "VITE_LOG_LEVEL") ?? (NODE_ENV === "production" ? "info" : "debug")).toUpperCase();
|
|
113
|
+
var MIN_PRIORITY = LEVEL_PRIORITY[CONFIGURED_LEVEL] ?? 0;
|
|
114
|
+
var DEBUG_FILTER = (envGet("ALMADAR_DEBUG", "VITE_ALMADAR_DEBUG") ?? "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
115
|
+
function matchesNamespace(namespace) {
|
|
116
|
+
if (DEBUG_FILTER.length === 0) return true;
|
|
117
|
+
return DEBUG_FILTER.some((pattern) => {
|
|
118
|
+
if (pattern === "*" || pattern === "almadar:*") return true;
|
|
119
|
+
if (pattern.endsWith(":*")) return namespace.startsWith(pattern.slice(0, -1));
|
|
120
|
+
return namespace === pattern;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function createLogger(namespace) {
|
|
124
|
+
const nsAllowed = matchesNamespace(namespace);
|
|
125
|
+
const log3 = (level, message, data, correlationId) => {
|
|
126
|
+
if (LEVEL_PRIORITY[level] < MIN_PRIORITY) return;
|
|
127
|
+
if (level === "DEBUG" && !nsAllowed) return;
|
|
128
|
+
const prefix = `[${namespace}]`;
|
|
129
|
+
const logData = correlationId ? { ...data, cid: correlationId } : data;
|
|
130
|
+
switch (level) {
|
|
131
|
+
case "DEBUG":
|
|
132
|
+
console.debug(prefix, message, logData ?? "");
|
|
133
|
+
break;
|
|
134
|
+
case "INFO":
|
|
135
|
+
console.info(prefix, message, logData ?? "");
|
|
136
|
+
break;
|
|
137
|
+
case "WARN":
|
|
138
|
+
console.warn(prefix, message, logData ?? "");
|
|
139
|
+
break;
|
|
140
|
+
case "ERROR":
|
|
141
|
+
console.error(prefix, message, logData ?? "");
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
return {
|
|
146
|
+
debug: (msg, data, cid) => log3("DEBUG", msg, data, cid),
|
|
147
|
+
info: (msg, data, cid) => log3("INFO", msg, data, cid),
|
|
148
|
+
warn: (msg, data, cid) => log3("WARN", msg, data, cid),
|
|
149
|
+
error: (msg, data, cid) => log3("ERROR", msg, data, cid)
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// hooks/useEventBus.ts
|
|
154
|
+
var log = createLogger("almadar:eventbus");
|
|
155
|
+
var subLog = createLogger("almadar:eventbus:subscribe");
|
|
94
156
|
function getGlobalEventBus() {
|
|
95
157
|
if (typeof window !== "undefined") {
|
|
96
158
|
return window.__kflowEventBus ?? null;
|
|
@@ -107,6 +169,7 @@ var fallbackEventBus = {
|
|
|
107
169
|
timestamp: Date.now()
|
|
108
170
|
};
|
|
109
171
|
const handlers = fallbackListeners.get(type);
|
|
172
|
+
log.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
|
|
110
173
|
if (handlers) {
|
|
111
174
|
handlers.forEach((handler) => {
|
|
112
175
|
try {
|
|
@@ -129,6 +192,7 @@ var fallbackEventBus = {
|
|
|
129
192
|
fallbackListeners.set(type, /* @__PURE__ */ new Set());
|
|
130
193
|
}
|
|
131
194
|
fallbackListeners.get(type).add(listener);
|
|
195
|
+
subLog.debug("subscribe", { type, totalListeners: fallbackListeners.get(type).size });
|
|
132
196
|
return () => {
|
|
133
197
|
const handlers = fallbackListeners.get(type);
|
|
134
198
|
if (handlers) {
|
|
@@ -152,6 +216,7 @@ var fallbackEventBus = {
|
|
|
152
216
|
},
|
|
153
217
|
onAny: (listener) => {
|
|
154
218
|
fallbackAnyListeners.add(listener);
|
|
219
|
+
subLog.debug("subscribe:any", { totalAnyListeners: fallbackAnyListeners.size });
|
|
155
220
|
return () => {
|
|
156
221
|
fallbackAnyListeners.delete(listener);
|
|
157
222
|
};
|
|
@@ -11626,6 +11691,7 @@ function GameOverScreen({
|
|
|
11626
11691
|
GameOverScreen.displayName = "GameOverScreen";
|
|
11627
11692
|
|
|
11628
11693
|
// lib/verificationRegistry.ts
|
|
11694
|
+
createLogger("almadar:bridge");
|
|
11629
11695
|
function getState() {
|
|
11630
11696
|
if (typeof window !== "undefined") {
|
|
11631
11697
|
const w = window;
|
|
@@ -29152,6 +29218,7 @@ function calculateDamage(attack, defense, isDefending = false, criticalChance =
|
|
|
29152
29218
|
function generateCombatMessage(event) {
|
|
29153
29219
|
return event.message;
|
|
29154
29220
|
}
|
|
29221
|
+
var storeLog = createLogger("almadar:entity:store");
|
|
29155
29222
|
var store = /* @__PURE__ */ new Map();
|
|
29156
29223
|
var storeListeners = /* @__PURE__ */ new Set();
|
|
29157
29224
|
var watchCallbacks = /* @__PURE__ */ new Map();
|
|
@@ -29191,7 +29258,9 @@ function setAll(entityType, records) {
|
|
|
29191
29258
|
}
|
|
29192
29259
|
}
|
|
29193
29260
|
const prev = store.get(entityType);
|
|
29194
|
-
|
|
29261
|
+
const newVersion = (prev?.version ?? 0) + 1;
|
|
29262
|
+
store.set(entityType, { entities: entities2, ids, version: newVersion });
|
|
29263
|
+
storeLog.debug("setAll", { entityType, recordCount: records.length, version: newVersion });
|
|
29195
29264
|
notifyListeners(entityType, prev);
|
|
29196
29265
|
}
|
|
29197
29266
|
function upsertOne(entityType, record) {
|
|
@@ -29203,6 +29272,7 @@ function upsertOne(entityType, record) {
|
|
|
29203
29272
|
if (!snapshot.ids.includes(id)) snapshot.ids.push(id);
|
|
29204
29273
|
snapshot.version++;
|
|
29205
29274
|
store.set(entityType, snapshot);
|
|
29275
|
+
storeLog.debug("upsertOne", { entityType, id, version: snapshot.version });
|
|
29206
29276
|
notifyListeners(entityType, prev);
|
|
29207
29277
|
}
|
|
29208
29278
|
function addOne(entityType, record) {
|
|
@@ -29219,6 +29289,7 @@ function updateOne(entityType, id, changes) {
|
|
|
29219
29289
|
snapshot.entities.set(id, { ...snapshot.entities.get(id), ...changes });
|
|
29220
29290
|
snapshot.version++;
|
|
29221
29291
|
store.set(entityType, snapshot);
|
|
29292
|
+
storeLog.debug("updateOne", { entityType, id, changedFields: Object.keys(changes), version: snapshot.version });
|
|
29222
29293
|
notifyListeners(entityType, prev);
|
|
29223
29294
|
}
|
|
29224
29295
|
function removeOne(entityType, id) {
|
|
@@ -29232,6 +29303,7 @@ function removeOne(entityType, id) {
|
|
|
29232
29303
|
snapshot.entities.delete(id);
|
|
29233
29304
|
snapshot.version++;
|
|
29234
29305
|
store.set(entityType, snapshot);
|
|
29306
|
+
storeLog.debug("removeOne", { entityType, id, remainingCount: snapshot.ids.length, version: snapshot.version });
|
|
29235
29307
|
notifyListeners(entityType, prev);
|
|
29236
29308
|
}
|
|
29237
29309
|
function getSnapshot2(entityType) {
|
|
@@ -33386,7 +33458,7 @@ function getAllEvents(traits2) {
|
|
|
33386
33458
|
}
|
|
33387
33459
|
function EventDispatcherTab({ traits: traits2, schema }) {
|
|
33388
33460
|
const eventBus = useEventBus();
|
|
33389
|
-
const [
|
|
33461
|
+
const [log3, setLog] = React90__namespace.useState([]);
|
|
33390
33462
|
const prevStatesRef = React90__namespace.useRef(/* @__PURE__ */ new Map());
|
|
33391
33463
|
React90__namespace.useEffect(() => {
|
|
33392
33464
|
for (const trait of traits2) {
|
|
@@ -33450,9 +33522,9 @@ function EventDispatcherTab({ traits: traits2, schema }) {
|
|
|
33450
33522
|
/* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: "Other Events (not available from current state)" }),
|
|
33451
33523
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1", children: unavailableEvents.map((event) => /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "default", size: "sm", className: "opacity-50", children: event }, event)) })
|
|
33452
33524
|
] }),
|
|
33453
|
-
|
|
33525
|
+
log3.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
33454
33526
|
/* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: "Recent Transitions" }),
|
|
33455
|
-
/* @__PURE__ */ jsxRuntime.jsx(Stack, { gap: "xs", children:
|
|
33527
|
+
/* @__PURE__ */ jsxRuntime.jsx(Stack, { gap: "xs", children: log3.map((entry, i) => /* @__PURE__ */ jsxRuntime.jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
|
|
33456
33528
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-purple-400", children: entry.traitName }),
|
|
33457
33529
|
" ",
|
|
33458
33530
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-500", children: entry.from }),
|
|
@@ -36842,31 +36914,7 @@ function useUISlotManager() {
|
|
|
36842
36914
|
var SelectionContext = React90.createContext(null);
|
|
36843
36915
|
|
|
36844
36916
|
// hooks/useUIEvents.ts
|
|
36845
|
-
var
|
|
36846
|
-
// Form/CRUD events
|
|
36847
|
-
"UI:SAVE": "SAVE",
|
|
36848
|
-
"UI:CANCEL": "CANCEL",
|
|
36849
|
-
"UI:CLOSE": "CLOSE",
|
|
36850
|
-
"UI:VIEW": "VIEW",
|
|
36851
|
-
"UI:EDIT": "EDIT",
|
|
36852
|
-
"UI:DELETE": "DELETE",
|
|
36853
|
-
"UI:CREATE": "CREATE",
|
|
36854
|
-
"UI:SELECT": "SELECT",
|
|
36855
|
-
"UI:DESELECT": "DESELECT",
|
|
36856
|
-
"UI:SUBMIT": "SAVE",
|
|
36857
|
-
"UI:UPDATE_STATUS": "UPDATE_STATUS",
|
|
36858
|
-
"UI:SEARCH": "SEARCH",
|
|
36859
|
-
"UI:CLEAR_SEARCH": "CLEAR_SEARCH",
|
|
36860
|
-
"UI:ADD": "CREATE",
|
|
36861
|
-
// Game events (for closed circuit with GameMenu, GamePauseOverlay, GameOverScreen)
|
|
36862
|
-
"UI:PAUSE": "PAUSE",
|
|
36863
|
-
"UI:RESUME": "RESUME",
|
|
36864
|
-
"UI:RESTART": "RESTART",
|
|
36865
|
-
"UI:GAME_OVER": "GAME_OVER",
|
|
36866
|
-
"UI:START": "START",
|
|
36867
|
-
"UI:QUIT": "QUIT",
|
|
36868
|
-
"UI:INIT": "INIT"
|
|
36869
|
-
};
|
|
36917
|
+
var UI_PREFIX = "UI:";
|
|
36870
36918
|
function useUIEvents(dispatch, validEvents, eventBusInstance) {
|
|
36871
36919
|
const defaultEventBus = useEventBus();
|
|
36872
36920
|
const eventBus = eventBusInstance ?? defaultEventBus;
|
|
@@ -36878,15 +36926,18 @@ function useUIEvents(dispatch, validEvents, eventBusInstance) {
|
|
|
36878
36926
|
);
|
|
36879
36927
|
React90.useEffect(() => {
|
|
36880
36928
|
const unsubscribes = [];
|
|
36881
|
-
|
|
36882
|
-
const
|
|
36883
|
-
|
|
36929
|
+
if (stableValidEvents) {
|
|
36930
|
+
for (const smEvent of stableValidEvents) {
|
|
36931
|
+
const prefixedHandler = (event) => {
|
|
36884
36932
|
dispatch(smEvent, event.payload);
|
|
36885
|
-
}
|
|
36886
|
-
|
|
36887
|
-
|
|
36888
|
-
|
|
36889
|
-
|
|
36933
|
+
};
|
|
36934
|
+
unsubscribes.push(eventBus.on(`${UI_PREFIX}${smEvent}`, prefixedHandler));
|
|
36935
|
+
const directHandler = (event) => {
|
|
36936
|
+
dispatch(smEvent, event.payload);
|
|
36937
|
+
};
|
|
36938
|
+
unsubscribes.push(eventBus.on(smEvent, directHandler));
|
|
36939
|
+
}
|
|
36940
|
+
}
|
|
36890
36941
|
const genericHandler = (event) => {
|
|
36891
36942
|
const eventName = event.payload?.event;
|
|
36892
36943
|
if (eventName) {
|
|
@@ -36896,30 +36947,11 @@ function useUIEvents(dispatch, validEvents, eventBusInstance) {
|
|
|
36896
36947
|
}
|
|
36897
36948
|
}
|
|
36898
36949
|
};
|
|
36899
|
-
|
|
36900
|
-
unsubscribes.push(genericUnsubscribe);
|
|
36901
|
-
if (stableValidEvents) {
|
|
36902
|
-
stableValidEvents.forEach((smEvent) => {
|
|
36903
|
-
const uiPrefixedEvent = `UI:${smEvent}`;
|
|
36904
|
-
const alreadyMapped = Object.keys(UI_EVENT_MAP).includes(uiPrefixedEvent);
|
|
36905
|
-
if (!alreadyMapped) {
|
|
36906
|
-
const directHandler = (event) => {
|
|
36907
|
-
dispatch(smEvent, event.payload);
|
|
36908
|
-
};
|
|
36909
|
-
const unsubscribePrefixed = eventBus.on(
|
|
36910
|
-
uiPrefixedEvent,
|
|
36911
|
-
directHandler
|
|
36912
|
-
);
|
|
36913
|
-
unsubscribes.push(unsubscribePrefixed);
|
|
36914
|
-
const unsubscribeDirect = eventBus.on(smEvent, directHandler);
|
|
36915
|
-
unsubscribes.push(unsubscribeDirect);
|
|
36916
|
-
}
|
|
36917
|
-
});
|
|
36918
|
-
}
|
|
36950
|
+
unsubscribes.push(eventBus.on(`${UI_PREFIX}DISPATCH`, genericHandler));
|
|
36919
36951
|
return () => {
|
|
36920
|
-
|
|
36952
|
+
for (const unsub of unsubscribes) {
|
|
36921
36953
|
if (typeof unsub === "function") unsub();
|
|
36922
|
-
}
|
|
36954
|
+
}
|
|
36923
36955
|
};
|
|
36924
36956
|
}, [eventBus, dispatch, stableValidEvents]);
|
|
36925
36957
|
}
|
|
@@ -37275,21 +37307,21 @@ function useOrbitalMutations(entityName, orbitalName, options) {
|
|
|
37275
37307
|
update: options?.events?.update || ENTITY_EVENTS.UPDATE,
|
|
37276
37308
|
delete: options?.events?.delete || ENTITY_EVENTS.DELETE
|
|
37277
37309
|
};
|
|
37278
|
-
const
|
|
37310
|
+
const log3 = (message, data) => {
|
|
37279
37311
|
if (options?.debug) {
|
|
37280
37312
|
console.log(`[useOrbitalMutations:${orbitalName}] ${message}`, data ?? "");
|
|
37281
37313
|
}
|
|
37282
37314
|
};
|
|
37283
37315
|
const createMutation = reactQuery.useMutation({
|
|
37284
37316
|
mutationFn: async (data) => {
|
|
37285
|
-
|
|
37317
|
+
log3("Creating entity", data);
|
|
37286
37318
|
return sendOrbitalEvent(orbitalName, {
|
|
37287
37319
|
event: events2.create,
|
|
37288
37320
|
payload: { data, entityType: entityName }
|
|
37289
37321
|
});
|
|
37290
37322
|
},
|
|
37291
37323
|
onSuccess: (response) => {
|
|
37292
|
-
|
|
37324
|
+
log3("Create succeeded", response);
|
|
37293
37325
|
queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
|
|
37294
37326
|
},
|
|
37295
37327
|
onError: (error) => {
|
|
@@ -37301,7 +37333,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
|
|
|
37301
37333
|
id,
|
|
37302
37334
|
data
|
|
37303
37335
|
}) => {
|
|
37304
|
-
|
|
37336
|
+
log3(`Updating entity ${id}`, data);
|
|
37305
37337
|
return sendOrbitalEvent(orbitalName, {
|
|
37306
37338
|
event: events2.update,
|
|
37307
37339
|
entityId: id,
|
|
@@ -37309,7 +37341,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
|
|
|
37309
37341
|
});
|
|
37310
37342
|
},
|
|
37311
37343
|
onSuccess: (response, variables) => {
|
|
37312
|
-
|
|
37344
|
+
log3("Update succeeded", response);
|
|
37313
37345
|
queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
|
|
37314
37346
|
queryClient.invalidateQueries({
|
|
37315
37347
|
queryKey: entityDataKeys.detail(entityName, variables.id)
|
|
@@ -37321,7 +37353,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
|
|
|
37321
37353
|
});
|
|
37322
37354
|
const deleteMutation = reactQuery.useMutation({
|
|
37323
37355
|
mutationFn: async (id) => {
|
|
37324
|
-
|
|
37356
|
+
log3(`Deleting entity ${id}`);
|
|
37325
37357
|
return sendOrbitalEvent(orbitalName, {
|
|
37326
37358
|
event: events2.delete,
|
|
37327
37359
|
entityId: id,
|
|
@@ -37329,7 +37361,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
|
|
|
37329
37361
|
});
|
|
37330
37362
|
},
|
|
37331
37363
|
onSuccess: (response, id) => {
|
|
37332
|
-
|
|
37364
|
+
log3("Delete succeeded", response);
|
|
37333
37365
|
queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
|
|
37334
37366
|
queryClient.removeQueries({ queryKey: entityDataKeys.detail(entityName, id) });
|
|
37335
37367
|
},
|
package/dist/components/index.js
CHANGED
|
@@ -45,6 +45,67 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
45
45
|
function cn(...inputs) {
|
|
46
46
|
return twMerge(clsx(inputs));
|
|
47
47
|
}
|
|
48
|
+
|
|
49
|
+
// lib/logger.ts
|
|
50
|
+
var LEVEL_PRIORITY = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3 };
|
|
51
|
+
var ENV = typeof process !== "undefined" && process.env ? process.env : {};
|
|
52
|
+
var VITE_ENV = typeof globalThis !== "undefined" && globalThis.__vite_env__ ? globalThis.__vite_env__ : {};
|
|
53
|
+
function getViteEnv(key) {
|
|
54
|
+
try {
|
|
55
|
+
const meta = import.meta;
|
|
56
|
+
return meta?.env?.[key];
|
|
57
|
+
} catch {
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function envGet(key, viteKey) {
|
|
62
|
+
return ENV[key] ?? (viteKey ? getViteEnv(viteKey) : void 0) ?? VITE_ENV[viteKey ?? key];
|
|
63
|
+
}
|
|
64
|
+
var NODE_ENV = envGet("NODE_ENV", "VITE_NODE_ENV") ?? "development";
|
|
65
|
+
var CONFIGURED_LEVEL = (envGet("LOG_LEVEL", "VITE_LOG_LEVEL") ?? (NODE_ENV === "production" ? "info" : "debug")).toUpperCase();
|
|
66
|
+
var MIN_PRIORITY = LEVEL_PRIORITY[CONFIGURED_LEVEL] ?? 0;
|
|
67
|
+
var DEBUG_FILTER = (envGet("ALMADAR_DEBUG", "VITE_ALMADAR_DEBUG") ?? "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
68
|
+
function matchesNamespace(namespace) {
|
|
69
|
+
if (DEBUG_FILTER.length === 0) return true;
|
|
70
|
+
return DEBUG_FILTER.some((pattern) => {
|
|
71
|
+
if (pattern === "*" || pattern === "almadar:*") return true;
|
|
72
|
+
if (pattern.endsWith(":*")) return namespace.startsWith(pattern.slice(0, -1));
|
|
73
|
+
return namespace === pattern;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function createLogger(namespace) {
|
|
77
|
+
const nsAllowed = matchesNamespace(namespace);
|
|
78
|
+
const log3 = (level, message, data, correlationId) => {
|
|
79
|
+
if (LEVEL_PRIORITY[level] < MIN_PRIORITY) return;
|
|
80
|
+
if (level === "DEBUG" && !nsAllowed) return;
|
|
81
|
+
const prefix = `[${namespace}]`;
|
|
82
|
+
const logData = correlationId ? { ...data, cid: correlationId } : data;
|
|
83
|
+
switch (level) {
|
|
84
|
+
case "DEBUG":
|
|
85
|
+
console.debug(prefix, message, logData ?? "");
|
|
86
|
+
break;
|
|
87
|
+
case "INFO":
|
|
88
|
+
console.info(prefix, message, logData ?? "");
|
|
89
|
+
break;
|
|
90
|
+
case "WARN":
|
|
91
|
+
console.warn(prefix, message, logData ?? "");
|
|
92
|
+
break;
|
|
93
|
+
case "ERROR":
|
|
94
|
+
console.error(prefix, message, logData ?? "");
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
debug: (msg, data, cid) => log3("DEBUG", msg, data, cid),
|
|
100
|
+
info: (msg, data, cid) => log3("INFO", msg, data, cid),
|
|
101
|
+
warn: (msg, data, cid) => log3("WARN", msg, data, cid),
|
|
102
|
+
error: (msg, data, cid) => log3("ERROR", msg, data, cid)
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// hooks/useEventBus.ts
|
|
107
|
+
var log = createLogger("almadar:eventbus");
|
|
108
|
+
var subLog = createLogger("almadar:eventbus:subscribe");
|
|
48
109
|
function getGlobalEventBus() {
|
|
49
110
|
if (typeof window !== "undefined") {
|
|
50
111
|
return window.__kflowEventBus ?? null;
|
|
@@ -61,6 +122,7 @@ var fallbackEventBus = {
|
|
|
61
122
|
timestamp: Date.now()
|
|
62
123
|
};
|
|
63
124
|
const handlers = fallbackListeners.get(type);
|
|
125
|
+
log.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
|
|
64
126
|
if (handlers) {
|
|
65
127
|
handlers.forEach((handler) => {
|
|
66
128
|
try {
|
|
@@ -83,6 +145,7 @@ var fallbackEventBus = {
|
|
|
83
145
|
fallbackListeners.set(type, /* @__PURE__ */ new Set());
|
|
84
146
|
}
|
|
85
147
|
fallbackListeners.get(type).add(listener);
|
|
148
|
+
subLog.debug("subscribe", { type, totalListeners: fallbackListeners.get(type).size });
|
|
86
149
|
return () => {
|
|
87
150
|
const handlers = fallbackListeners.get(type);
|
|
88
151
|
if (handlers) {
|
|
@@ -106,6 +169,7 @@ var fallbackEventBus = {
|
|
|
106
169
|
},
|
|
107
170
|
onAny: (listener) => {
|
|
108
171
|
fallbackAnyListeners.add(listener);
|
|
172
|
+
subLog.debug("subscribe:any", { totalAnyListeners: fallbackAnyListeners.size });
|
|
109
173
|
return () => {
|
|
110
174
|
fallbackAnyListeners.delete(listener);
|
|
111
175
|
};
|
|
@@ -11580,6 +11644,7 @@ function GameOverScreen({
|
|
|
11580
11644
|
GameOverScreen.displayName = "GameOverScreen";
|
|
11581
11645
|
|
|
11582
11646
|
// lib/verificationRegistry.ts
|
|
11647
|
+
createLogger("almadar:bridge");
|
|
11583
11648
|
function getState() {
|
|
11584
11649
|
if (typeof window !== "undefined") {
|
|
11585
11650
|
const w = window;
|
|
@@ -29106,6 +29171,7 @@ function calculateDamage(attack, defense, isDefending = false, criticalChance =
|
|
|
29106
29171
|
function generateCombatMessage(event) {
|
|
29107
29172
|
return event.message;
|
|
29108
29173
|
}
|
|
29174
|
+
var storeLog = createLogger("almadar:entity:store");
|
|
29109
29175
|
var store = /* @__PURE__ */ new Map();
|
|
29110
29176
|
var storeListeners = /* @__PURE__ */ new Set();
|
|
29111
29177
|
var watchCallbacks = /* @__PURE__ */ new Map();
|
|
@@ -29145,7 +29211,9 @@ function setAll(entityType, records) {
|
|
|
29145
29211
|
}
|
|
29146
29212
|
}
|
|
29147
29213
|
const prev = store.get(entityType);
|
|
29148
|
-
|
|
29214
|
+
const newVersion = (prev?.version ?? 0) + 1;
|
|
29215
|
+
store.set(entityType, { entities: entities2, ids, version: newVersion });
|
|
29216
|
+
storeLog.debug("setAll", { entityType, recordCount: records.length, version: newVersion });
|
|
29149
29217
|
notifyListeners(entityType, prev);
|
|
29150
29218
|
}
|
|
29151
29219
|
function upsertOne(entityType, record) {
|
|
@@ -29157,6 +29225,7 @@ function upsertOne(entityType, record) {
|
|
|
29157
29225
|
if (!snapshot.ids.includes(id)) snapshot.ids.push(id);
|
|
29158
29226
|
snapshot.version++;
|
|
29159
29227
|
store.set(entityType, snapshot);
|
|
29228
|
+
storeLog.debug("upsertOne", { entityType, id, version: snapshot.version });
|
|
29160
29229
|
notifyListeners(entityType, prev);
|
|
29161
29230
|
}
|
|
29162
29231
|
function addOne(entityType, record) {
|
|
@@ -29173,6 +29242,7 @@ function updateOne(entityType, id, changes) {
|
|
|
29173
29242
|
snapshot.entities.set(id, { ...snapshot.entities.get(id), ...changes });
|
|
29174
29243
|
snapshot.version++;
|
|
29175
29244
|
store.set(entityType, snapshot);
|
|
29245
|
+
storeLog.debug("updateOne", { entityType, id, changedFields: Object.keys(changes), version: snapshot.version });
|
|
29176
29246
|
notifyListeners(entityType, prev);
|
|
29177
29247
|
}
|
|
29178
29248
|
function removeOne(entityType, id) {
|
|
@@ -29186,6 +29256,7 @@ function removeOne(entityType, id) {
|
|
|
29186
29256
|
snapshot.entities.delete(id);
|
|
29187
29257
|
snapshot.version++;
|
|
29188
29258
|
store.set(entityType, snapshot);
|
|
29259
|
+
storeLog.debug("removeOne", { entityType, id, remainingCount: snapshot.ids.length, version: snapshot.version });
|
|
29189
29260
|
notifyListeners(entityType, prev);
|
|
29190
29261
|
}
|
|
29191
29262
|
function getSnapshot2(entityType) {
|
|
@@ -33340,7 +33411,7 @@ function getAllEvents(traits2) {
|
|
|
33340
33411
|
}
|
|
33341
33412
|
function EventDispatcherTab({ traits: traits2, schema }) {
|
|
33342
33413
|
const eventBus = useEventBus();
|
|
33343
|
-
const [
|
|
33414
|
+
const [log3, setLog] = React90.useState([]);
|
|
33344
33415
|
const prevStatesRef = React90.useRef(/* @__PURE__ */ new Map());
|
|
33345
33416
|
React90.useEffect(() => {
|
|
33346
33417
|
for (const trait of traits2) {
|
|
@@ -33404,9 +33475,9 @@ function EventDispatcherTab({ traits: traits2, schema }) {
|
|
|
33404
33475
|
/* @__PURE__ */ jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: "Other Events (not available from current state)" }),
|
|
33405
33476
|
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: unavailableEvents.map((event) => /* @__PURE__ */ jsx(Badge, { variant: "default", size: "sm", className: "opacity-50", children: event }, event)) })
|
|
33406
33477
|
] }),
|
|
33407
|
-
|
|
33478
|
+
log3.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
|
|
33408
33479
|
/* @__PURE__ */ jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: "Recent Transitions" }),
|
|
33409
|
-
/* @__PURE__ */ jsx(Stack, { gap: "xs", children:
|
|
33480
|
+
/* @__PURE__ */ jsx(Stack, { gap: "xs", children: log3.map((entry, i) => /* @__PURE__ */ jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
|
|
33410
33481
|
/* @__PURE__ */ jsx("span", { className: "text-purple-400", children: entry.traitName }),
|
|
33411
33482
|
" ",
|
|
33412
33483
|
/* @__PURE__ */ jsx("span", { className: "text-gray-500", children: entry.from }),
|
|
@@ -36796,31 +36867,7 @@ function useUISlotManager() {
|
|
|
36796
36867
|
var SelectionContext = createContext(null);
|
|
36797
36868
|
|
|
36798
36869
|
// hooks/useUIEvents.ts
|
|
36799
|
-
var
|
|
36800
|
-
// Form/CRUD events
|
|
36801
|
-
"UI:SAVE": "SAVE",
|
|
36802
|
-
"UI:CANCEL": "CANCEL",
|
|
36803
|
-
"UI:CLOSE": "CLOSE",
|
|
36804
|
-
"UI:VIEW": "VIEW",
|
|
36805
|
-
"UI:EDIT": "EDIT",
|
|
36806
|
-
"UI:DELETE": "DELETE",
|
|
36807
|
-
"UI:CREATE": "CREATE",
|
|
36808
|
-
"UI:SELECT": "SELECT",
|
|
36809
|
-
"UI:DESELECT": "DESELECT",
|
|
36810
|
-
"UI:SUBMIT": "SAVE",
|
|
36811
|
-
"UI:UPDATE_STATUS": "UPDATE_STATUS",
|
|
36812
|
-
"UI:SEARCH": "SEARCH",
|
|
36813
|
-
"UI:CLEAR_SEARCH": "CLEAR_SEARCH",
|
|
36814
|
-
"UI:ADD": "CREATE",
|
|
36815
|
-
// Game events (for closed circuit with GameMenu, GamePauseOverlay, GameOverScreen)
|
|
36816
|
-
"UI:PAUSE": "PAUSE",
|
|
36817
|
-
"UI:RESUME": "RESUME",
|
|
36818
|
-
"UI:RESTART": "RESTART",
|
|
36819
|
-
"UI:GAME_OVER": "GAME_OVER",
|
|
36820
|
-
"UI:START": "START",
|
|
36821
|
-
"UI:QUIT": "QUIT",
|
|
36822
|
-
"UI:INIT": "INIT"
|
|
36823
|
-
};
|
|
36870
|
+
var UI_PREFIX = "UI:";
|
|
36824
36871
|
function useUIEvents(dispatch, validEvents, eventBusInstance) {
|
|
36825
36872
|
const defaultEventBus = useEventBus();
|
|
36826
36873
|
const eventBus = eventBusInstance ?? defaultEventBus;
|
|
@@ -36832,15 +36879,18 @@ function useUIEvents(dispatch, validEvents, eventBusInstance) {
|
|
|
36832
36879
|
);
|
|
36833
36880
|
useEffect(() => {
|
|
36834
36881
|
const unsubscribes = [];
|
|
36835
|
-
|
|
36836
|
-
const
|
|
36837
|
-
|
|
36882
|
+
if (stableValidEvents) {
|
|
36883
|
+
for (const smEvent of stableValidEvents) {
|
|
36884
|
+
const prefixedHandler = (event) => {
|
|
36838
36885
|
dispatch(smEvent, event.payload);
|
|
36839
|
-
}
|
|
36840
|
-
|
|
36841
|
-
|
|
36842
|
-
|
|
36843
|
-
|
|
36886
|
+
};
|
|
36887
|
+
unsubscribes.push(eventBus.on(`${UI_PREFIX}${smEvent}`, prefixedHandler));
|
|
36888
|
+
const directHandler = (event) => {
|
|
36889
|
+
dispatch(smEvent, event.payload);
|
|
36890
|
+
};
|
|
36891
|
+
unsubscribes.push(eventBus.on(smEvent, directHandler));
|
|
36892
|
+
}
|
|
36893
|
+
}
|
|
36844
36894
|
const genericHandler = (event) => {
|
|
36845
36895
|
const eventName = event.payload?.event;
|
|
36846
36896
|
if (eventName) {
|
|
@@ -36850,30 +36900,11 @@ function useUIEvents(dispatch, validEvents, eventBusInstance) {
|
|
|
36850
36900
|
}
|
|
36851
36901
|
}
|
|
36852
36902
|
};
|
|
36853
|
-
|
|
36854
|
-
unsubscribes.push(genericUnsubscribe);
|
|
36855
|
-
if (stableValidEvents) {
|
|
36856
|
-
stableValidEvents.forEach((smEvent) => {
|
|
36857
|
-
const uiPrefixedEvent = `UI:${smEvent}`;
|
|
36858
|
-
const alreadyMapped = Object.keys(UI_EVENT_MAP).includes(uiPrefixedEvent);
|
|
36859
|
-
if (!alreadyMapped) {
|
|
36860
|
-
const directHandler = (event) => {
|
|
36861
|
-
dispatch(smEvent, event.payload);
|
|
36862
|
-
};
|
|
36863
|
-
const unsubscribePrefixed = eventBus.on(
|
|
36864
|
-
uiPrefixedEvent,
|
|
36865
|
-
directHandler
|
|
36866
|
-
);
|
|
36867
|
-
unsubscribes.push(unsubscribePrefixed);
|
|
36868
|
-
const unsubscribeDirect = eventBus.on(smEvent, directHandler);
|
|
36869
|
-
unsubscribes.push(unsubscribeDirect);
|
|
36870
|
-
}
|
|
36871
|
-
});
|
|
36872
|
-
}
|
|
36903
|
+
unsubscribes.push(eventBus.on(`${UI_PREFIX}DISPATCH`, genericHandler));
|
|
36873
36904
|
return () => {
|
|
36874
|
-
|
|
36905
|
+
for (const unsub of unsubscribes) {
|
|
36875
36906
|
if (typeof unsub === "function") unsub();
|
|
36876
|
-
}
|
|
36907
|
+
}
|
|
36877
36908
|
};
|
|
36878
36909
|
}, [eventBus, dispatch, stableValidEvents]);
|
|
36879
36910
|
}
|
|
@@ -37229,21 +37260,21 @@ function useOrbitalMutations(entityName, orbitalName, options) {
|
|
|
37229
37260
|
update: options?.events?.update || ENTITY_EVENTS.UPDATE,
|
|
37230
37261
|
delete: options?.events?.delete || ENTITY_EVENTS.DELETE
|
|
37231
37262
|
};
|
|
37232
|
-
const
|
|
37263
|
+
const log3 = (message, data) => {
|
|
37233
37264
|
if (options?.debug) {
|
|
37234
37265
|
console.log(`[useOrbitalMutations:${orbitalName}] ${message}`, data ?? "");
|
|
37235
37266
|
}
|
|
37236
37267
|
};
|
|
37237
37268
|
const createMutation = useMutation({
|
|
37238
37269
|
mutationFn: async (data) => {
|
|
37239
|
-
|
|
37270
|
+
log3("Creating entity", data);
|
|
37240
37271
|
return sendOrbitalEvent(orbitalName, {
|
|
37241
37272
|
event: events2.create,
|
|
37242
37273
|
payload: { data, entityType: entityName }
|
|
37243
37274
|
});
|
|
37244
37275
|
},
|
|
37245
37276
|
onSuccess: (response) => {
|
|
37246
|
-
|
|
37277
|
+
log3("Create succeeded", response);
|
|
37247
37278
|
queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
|
|
37248
37279
|
},
|
|
37249
37280
|
onError: (error) => {
|
|
@@ -37255,7 +37286,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
|
|
|
37255
37286
|
id,
|
|
37256
37287
|
data
|
|
37257
37288
|
}) => {
|
|
37258
|
-
|
|
37289
|
+
log3(`Updating entity ${id}`, data);
|
|
37259
37290
|
return sendOrbitalEvent(orbitalName, {
|
|
37260
37291
|
event: events2.update,
|
|
37261
37292
|
entityId: id,
|
|
@@ -37263,7 +37294,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
|
|
|
37263
37294
|
});
|
|
37264
37295
|
},
|
|
37265
37296
|
onSuccess: (response, variables) => {
|
|
37266
|
-
|
|
37297
|
+
log3("Update succeeded", response);
|
|
37267
37298
|
queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
|
|
37268
37299
|
queryClient.invalidateQueries({
|
|
37269
37300
|
queryKey: entityDataKeys.detail(entityName, variables.id)
|
|
@@ -37275,7 +37306,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
|
|
|
37275
37306
|
});
|
|
37276
37307
|
const deleteMutation = useMutation({
|
|
37277
37308
|
mutationFn: async (id) => {
|
|
37278
|
-
|
|
37309
|
+
log3(`Deleting entity ${id}`);
|
|
37279
37310
|
return sendOrbitalEvent(orbitalName, {
|
|
37280
37311
|
event: events2.delete,
|
|
37281
37312
|
entityId: id,
|
|
@@ -37283,7 +37314,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
|
|
|
37283
37314
|
});
|
|
37284
37315
|
},
|
|
37285
37316
|
onSuccess: (response, id) => {
|
|
37286
|
-
|
|
37317
|
+
log3("Delete succeeded", response);
|
|
37287
37318
|
queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
|
|
37288
37319
|
queryClient.removeQueries({ queryKey: entityDataKeys.detail(entityName, id) });
|
|
37289
37320
|
},
|