@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
|
@@ -14,6 +14,7 @@ var clsx = require('clsx');
|
|
|
14
14
|
var tailwindMerge = require('tailwind-merge');
|
|
15
15
|
var postprocessing = require('@react-three/postprocessing');
|
|
16
16
|
|
|
17
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
17
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
19
|
|
|
19
20
|
function _interopNamespace(e) {
|
|
@@ -1375,6 +1376,67 @@ function useRaycaster(options) {
|
|
|
1375
1376
|
isWithinCanvas
|
|
1376
1377
|
};
|
|
1377
1378
|
}
|
|
1379
|
+
|
|
1380
|
+
// lib/logger.ts
|
|
1381
|
+
var LEVEL_PRIORITY = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3 };
|
|
1382
|
+
var ENV = typeof process !== "undefined" && process.env ? process.env : {};
|
|
1383
|
+
var VITE_ENV = typeof globalThis !== "undefined" && globalThis.__vite_env__ ? globalThis.__vite_env__ : {};
|
|
1384
|
+
function getViteEnv(key) {
|
|
1385
|
+
try {
|
|
1386
|
+
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)) });
|
|
1387
|
+
return meta?.env?.[key];
|
|
1388
|
+
} catch {
|
|
1389
|
+
return void 0;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
function envGet(key, viteKey) {
|
|
1393
|
+
return ENV[key] ?? (viteKey ? getViteEnv(viteKey) : void 0) ?? VITE_ENV[viteKey ?? key];
|
|
1394
|
+
}
|
|
1395
|
+
var NODE_ENV = envGet("NODE_ENV", "VITE_NODE_ENV") ?? "development";
|
|
1396
|
+
var CONFIGURED_LEVEL = (envGet("LOG_LEVEL", "VITE_LOG_LEVEL") ?? (NODE_ENV === "production" ? "info" : "debug")).toUpperCase();
|
|
1397
|
+
var MIN_PRIORITY = LEVEL_PRIORITY[CONFIGURED_LEVEL] ?? 0;
|
|
1398
|
+
var DEBUG_FILTER = (envGet("ALMADAR_DEBUG", "VITE_ALMADAR_DEBUG") ?? "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
1399
|
+
function matchesNamespace(namespace) {
|
|
1400
|
+
if (DEBUG_FILTER.length === 0) return true;
|
|
1401
|
+
return DEBUG_FILTER.some((pattern) => {
|
|
1402
|
+
if (pattern === "*" || pattern === "almadar:*") return true;
|
|
1403
|
+
if (pattern.endsWith(":*")) return namespace.startsWith(pattern.slice(0, -1));
|
|
1404
|
+
return namespace === pattern;
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
function createLogger(namespace) {
|
|
1408
|
+
const nsAllowed = matchesNamespace(namespace);
|
|
1409
|
+
const log2 = (level, message, data, correlationId) => {
|
|
1410
|
+
if (LEVEL_PRIORITY[level] < MIN_PRIORITY) return;
|
|
1411
|
+
if (level === "DEBUG" && !nsAllowed) return;
|
|
1412
|
+
const prefix = `[${namespace}]`;
|
|
1413
|
+
const logData = correlationId ? { ...data, cid: correlationId } : data;
|
|
1414
|
+
switch (level) {
|
|
1415
|
+
case "DEBUG":
|
|
1416
|
+
console.debug(prefix, message, logData ?? "");
|
|
1417
|
+
break;
|
|
1418
|
+
case "INFO":
|
|
1419
|
+
console.info(prefix, message, logData ?? "");
|
|
1420
|
+
break;
|
|
1421
|
+
case "WARN":
|
|
1422
|
+
console.warn(prefix, message, logData ?? "");
|
|
1423
|
+
break;
|
|
1424
|
+
case "ERROR":
|
|
1425
|
+
console.error(prefix, message, logData ?? "");
|
|
1426
|
+
break;
|
|
1427
|
+
}
|
|
1428
|
+
};
|
|
1429
|
+
return {
|
|
1430
|
+
debug: (msg, data, cid) => log2("DEBUG", msg, data, cid),
|
|
1431
|
+
info: (msg, data, cid) => log2("INFO", msg, data, cid),
|
|
1432
|
+
warn: (msg, data, cid) => log2("WARN", msg, data, cid),
|
|
1433
|
+
error: (msg, data, cid) => log2("ERROR", msg, data, cid)
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
// hooks/useEventBus.ts
|
|
1438
|
+
var log = createLogger("almadar:eventbus");
|
|
1439
|
+
var subLog = createLogger("almadar:eventbus:subscribe");
|
|
1378
1440
|
function getGlobalEventBus() {
|
|
1379
1441
|
if (typeof window !== "undefined") {
|
|
1380
1442
|
return window.__kflowEventBus ?? null;
|
|
@@ -1391,6 +1453,7 @@ var fallbackEventBus = {
|
|
|
1391
1453
|
timestamp: Date.now()
|
|
1392
1454
|
};
|
|
1393
1455
|
const handlers = fallbackListeners.get(type);
|
|
1456
|
+
log.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
|
|
1394
1457
|
if (handlers) {
|
|
1395
1458
|
handlers.forEach((handler) => {
|
|
1396
1459
|
try {
|
|
@@ -1413,6 +1476,7 @@ var fallbackEventBus = {
|
|
|
1413
1476
|
fallbackListeners.set(type, /* @__PURE__ */ new Set());
|
|
1414
1477
|
}
|
|
1415
1478
|
fallbackListeners.get(type).add(listener);
|
|
1479
|
+
subLog.debug("subscribe", { type, totalListeners: fallbackListeners.get(type).size });
|
|
1416
1480
|
return () => {
|
|
1417
1481
|
const handlers = fallbackListeners.get(type);
|
|
1418
1482
|
if (handlers) {
|
|
@@ -1436,6 +1500,7 @@ var fallbackEventBus = {
|
|
|
1436
1500
|
},
|
|
1437
1501
|
onAny: (listener) => {
|
|
1438
1502
|
fallbackAnyListeners.add(listener);
|
|
1503
|
+
subLog.debug("subscribe:any", { totalAnyListeners: fallbackAnyListeners.size });
|
|
1439
1504
|
return () => {
|
|
1440
1505
|
fallbackAnyListeners.delete(listener);
|
|
1441
1506
|
};
|
|
@@ -1351,6 +1351,67 @@ function useRaycaster(options) {
|
|
|
1351
1351
|
isWithinCanvas
|
|
1352
1352
|
};
|
|
1353
1353
|
}
|
|
1354
|
+
|
|
1355
|
+
// lib/logger.ts
|
|
1356
|
+
var LEVEL_PRIORITY = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3 };
|
|
1357
|
+
var ENV = typeof process !== "undefined" && process.env ? process.env : {};
|
|
1358
|
+
var VITE_ENV = typeof globalThis !== "undefined" && globalThis.__vite_env__ ? globalThis.__vite_env__ : {};
|
|
1359
|
+
function getViteEnv(key) {
|
|
1360
|
+
try {
|
|
1361
|
+
const meta = import.meta;
|
|
1362
|
+
return meta?.env?.[key];
|
|
1363
|
+
} catch {
|
|
1364
|
+
return void 0;
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
function envGet(key, viteKey) {
|
|
1368
|
+
return ENV[key] ?? (viteKey ? getViteEnv(viteKey) : void 0) ?? VITE_ENV[viteKey ?? key];
|
|
1369
|
+
}
|
|
1370
|
+
var NODE_ENV = envGet("NODE_ENV", "VITE_NODE_ENV") ?? "development";
|
|
1371
|
+
var CONFIGURED_LEVEL = (envGet("LOG_LEVEL", "VITE_LOG_LEVEL") ?? (NODE_ENV === "production" ? "info" : "debug")).toUpperCase();
|
|
1372
|
+
var MIN_PRIORITY = LEVEL_PRIORITY[CONFIGURED_LEVEL] ?? 0;
|
|
1373
|
+
var DEBUG_FILTER = (envGet("ALMADAR_DEBUG", "VITE_ALMADAR_DEBUG") ?? "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
1374
|
+
function matchesNamespace(namespace) {
|
|
1375
|
+
if (DEBUG_FILTER.length === 0) return true;
|
|
1376
|
+
return DEBUG_FILTER.some((pattern) => {
|
|
1377
|
+
if (pattern === "*" || pattern === "almadar:*") return true;
|
|
1378
|
+
if (pattern.endsWith(":*")) return namespace.startsWith(pattern.slice(0, -1));
|
|
1379
|
+
return namespace === pattern;
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
function createLogger(namespace) {
|
|
1383
|
+
const nsAllowed = matchesNamespace(namespace);
|
|
1384
|
+
const log2 = (level, message, data, correlationId) => {
|
|
1385
|
+
if (LEVEL_PRIORITY[level] < MIN_PRIORITY) return;
|
|
1386
|
+
if (level === "DEBUG" && !nsAllowed) return;
|
|
1387
|
+
const prefix = `[${namespace}]`;
|
|
1388
|
+
const logData = correlationId ? { ...data, cid: correlationId } : data;
|
|
1389
|
+
switch (level) {
|
|
1390
|
+
case "DEBUG":
|
|
1391
|
+
console.debug(prefix, message, logData ?? "");
|
|
1392
|
+
break;
|
|
1393
|
+
case "INFO":
|
|
1394
|
+
console.info(prefix, message, logData ?? "");
|
|
1395
|
+
break;
|
|
1396
|
+
case "WARN":
|
|
1397
|
+
console.warn(prefix, message, logData ?? "");
|
|
1398
|
+
break;
|
|
1399
|
+
case "ERROR":
|
|
1400
|
+
console.error(prefix, message, logData ?? "");
|
|
1401
|
+
break;
|
|
1402
|
+
}
|
|
1403
|
+
};
|
|
1404
|
+
return {
|
|
1405
|
+
debug: (msg, data, cid) => log2("DEBUG", msg, data, cid),
|
|
1406
|
+
info: (msg, data, cid) => log2("INFO", msg, data, cid),
|
|
1407
|
+
warn: (msg, data, cid) => log2("WARN", msg, data, cid),
|
|
1408
|
+
error: (msg, data, cid) => log2("ERROR", msg, data, cid)
|
|
1409
|
+
};
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
// hooks/useEventBus.ts
|
|
1413
|
+
var log = createLogger("almadar:eventbus");
|
|
1414
|
+
var subLog = createLogger("almadar:eventbus:subscribe");
|
|
1354
1415
|
function getGlobalEventBus() {
|
|
1355
1416
|
if (typeof window !== "undefined") {
|
|
1356
1417
|
return window.__kflowEventBus ?? null;
|
|
@@ -1367,6 +1428,7 @@ var fallbackEventBus = {
|
|
|
1367
1428
|
timestamp: Date.now()
|
|
1368
1429
|
};
|
|
1369
1430
|
const handlers = fallbackListeners.get(type);
|
|
1431
|
+
log.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
|
|
1370
1432
|
if (handlers) {
|
|
1371
1433
|
handlers.forEach((handler) => {
|
|
1372
1434
|
try {
|
|
@@ -1389,6 +1451,7 @@ var fallbackEventBus = {
|
|
|
1389
1451
|
fallbackListeners.set(type, /* @__PURE__ */ new Set());
|
|
1390
1452
|
}
|
|
1391
1453
|
fallbackListeners.get(type).add(listener);
|
|
1454
|
+
subLog.debug("subscribe", { type, totalListeners: fallbackListeners.get(type).size });
|
|
1392
1455
|
return () => {
|
|
1393
1456
|
const handlers = fallbackListeners.get(type);
|
|
1394
1457
|
if (handlers) {
|
|
@@ -1412,6 +1475,7 @@ var fallbackEventBus = {
|
|
|
1412
1475
|
},
|
|
1413
1476
|
onAny: (listener) => {
|
|
1414
1477
|
fallbackAnyListeners.add(listener);
|
|
1478
|
+
subLog.debug("subscribe:any", { totalAnyListeners: fallbackAnyListeners.size });
|
|
1415
1479
|
return () => {
|
|
1416
1480
|
fallbackAnyListeners.delete(listener);
|
|
1417
1481
|
};
|
package/dist/docs/index.cjs
CHANGED
|
@@ -4,6 +4,7 @@ var React4 = require('react');
|
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var LucideIcons = require('lucide-react');
|
|
6
6
|
|
|
7
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
7
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
9
|
|
|
9
10
|
function _interopNamespace(e) {
|
|
@@ -2506,9 +2507,70 @@ var twMerge = /* @__PURE__ */ createTailwindMerge(getDefaultConfig);
|
|
|
2506
2507
|
function cn(...inputs) {
|
|
2507
2508
|
return twMerge(clsx(inputs));
|
|
2508
2509
|
}
|
|
2510
|
+
|
|
2511
|
+
// lib/logger.ts
|
|
2512
|
+
var LEVEL_PRIORITY = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3 };
|
|
2513
|
+
var ENV = typeof process !== "undefined" && process.env ? process.env : {};
|
|
2514
|
+
var VITE_ENV = typeof globalThis !== "undefined" && globalThis.__vite_env__ ? globalThis.__vite_env__ : {};
|
|
2515
|
+
function getViteEnv(key) {
|
|
2516
|
+
try {
|
|
2517
|
+
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)) });
|
|
2518
|
+
return meta?.env?.[key];
|
|
2519
|
+
} catch {
|
|
2520
|
+
return void 0;
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
function envGet(key, viteKey) {
|
|
2524
|
+
return ENV[key] ?? (viteKey ? getViteEnv(viteKey) : void 0) ?? VITE_ENV[viteKey ?? key];
|
|
2525
|
+
}
|
|
2526
|
+
var NODE_ENV = envGet("NODE_ENV", "VITE_NODE_ENV") ?? "development";
|
|
2527
|
+
var CONFIGURED_LEVEL = (envGet("LOG_LEVEL", "VITE_LOG_LEVEL") ?? (NODE_ENV === "production" ? "info" : "debug")).toUpperCase();
|
|
2528
|
+
var MIN_PRIORITY = LEVEL_PRIORITY[CONFIGURED_LEVEL] ?? 0;
|
|
2529
|
+
var DEBUG_FILTER = (envGet("ALMADAR_DEBUG", "VITE_ALMADAR_DEBUG") ?? "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
2530
|
+
function matchesNamespace(namespace) {
|
|
2531
|
+
if (DEBUG_FILTER.length === 0) return true;
|
|
2532
|
+
return DEBUG_FILTER.some((pattern) => {
|
|
2533
|
+
if (pattern === "*" || pattern === "almadar:*") return true;
|
|
2534
|
+
if (pattern.endsWith(":*")) return namespace.startsWith(pattern.slice(0, -1));
|
|
2535
|
+
return namespace === pattern;
|
|
2536
|
+
});
|
|
2537
|
+
}
|
|
2538
|
+
function createLogger(namespace) {
|
|
2539
|
+
const nsAllowed = matchesNamespace(namespace);
|
|
2540
|
+
const log2 = (level, message, data, correlationId) => {
|
|
2541
|
+
if (LEVEL_PRIORITY[level] < MIN_PRIORITY) return;
|
|
2542
|
+
if (level === "DEBUG" && !nsAllowed) return;
|
|
2543
|
+
const prefix = `[${namespace}]`;
|
|
2544
|
+
const logData = correlationId ? { ...data, cid: correlationId } : data;
|
|
2545
|
+
switch (level) {
|
|
2546
|
+
case "DEBUG":
|
|
2547
|
+
console.debug(prefix, message, logData ?? "");
|
|
2548
|
+
break;
|
|
2549
|
+
case "INFO":
|
|
2550
|
+
console.info(prefix, message, logData ?? "");
|
|
2551
|
+
break;
|
|
2552
|
+
case "WARN":
|
|
2553
|
+
console.warn(prefix, message, logData ?? "");
|
|
2554
|
+
break;
|
|
2555
|
+
case "ERROR":
|
|
2556
|
+
console.error(prefix, message, logData ?? "");
|
|
2557
|
+
break;
|
|
2558
|
+
}
|
|
2559
|
+
};
|
|
2560
|
+
return {
|
|
2561
|
+
debug: (msg, data, cid) => log2("DEBUG", msg, data, cid),
|
|
2562
|
+
info: (msg, data, cid) => log2("INFO", msg, data, cid),
|
|
2563
|
+
warn: (msg, data, cid) => log2("WARN", msg, data, cid),
|
|
2564
|
+
error: (msg, data, cid) => log2("ERROR", msg, data, cid)
|
|
2565
|
+
};
|
|
2566
|
+
}
|
|
2567
|
+
createLogger("almadar:eventbus");
|
|
2568
|
+
createLogger("almadar:eventbus:subscribe");
|
|
2509
2569
|
var EventBusContext = React4.createContext(null);
|
|
2510
2570
|
|
|
2511
2571
|
// hooks/useEventBus.ts
|
|
2572
|
+
var log = createLogger("almadar:eventbus");
|
|
2573
|
+
var subLog2 = createLogger("almadar:eventbus:subscribe");
|
|
2512
2574
|
function getGlobalEventBus() {
|
|
2513
2575
|
if (typeof window !== "undefined") {
|
|
2514
2576
|
return window.__kflowEventBus ?? null;
|
|
@@ -2525,6 +2587,7 @@ var fallbackEventBus = {
|
|
|
2525
2587
|
timestamp: Date.now()
|
|
2526
2588
|
};
|
|
2527
2589
|
const handlers = fallbackListeners.get(type);
|
|
2590
|
+
log.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
|
|
2528
2591
|
if (handlers) {
|
|
2529
2592
|
handlers.forEach((handler) => {
|
|
2530
2593
|
try {
|
|
@@ -2547,6 +2610,7 @@ var fallbackEventBus = {
|
|
|
2547
2610
|
fallbackListeners.set(type, /* @__PURE__ */ new Set());
|
|
2548
2611
|
}
|
|
2549
2612
|
fallbackListeners.get(type).add(listener);
|
|
2613
|
+
subLog2.debug("subscribe", { type, totalListeners: fallbackListeners.get(type).size });
|
|
2550
2614
|
return () => {
|
|
2551
2615
|
const handlers = fallbackListeners.get(type);
|
|
2552
2616
|
if (handlers) {
|
|
@@ -2570,6 +2634,7 @@ var fallbackEventBus = {
|
|
|
2570
2634
|
},
|
|
2571
2635
|
onAny: (listener) => {
|
|
2572
2636
|
fallbackAnyListeners.add(listener);
|
|
2637
|
+
subLog2.debug("subscribe:any", { totalAnyListeners: fallbackAnyListeners.size });
|
|
2573
2638
|
return () => {
|
|
2574
2639
|
fallbackAnyListeners.delete(listener);
|
|
2575
2640
|
};
|
package/dist/docs/index.js
CHANGED
|
@@ -2482,9 +2482,70 @@ var twMerge = /* @__PURE__ */ createTailwindMerge(getDefaultConfig);
|
|
|
2482
2482
|
function cn(...inputs) {
|
|
2483
2483
|
return twMerge(clsx(inputs));
|
|
2484
2484
|
}
|
|
2485
|
+
|
|
2486
|
+
// lib/logger.ts
|
|
2487
|
+
var LEVEL_PRIORITY = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3 };
|
|
2488
|
+
var ENV = typeof process !== "undefined" && process.env ? process.env : {};
|
|
2489
|
+
var VITE_ENV = typeof globalThis !== "undefined" && globalThis.__vite_env__ ? globalThis.__vite_env__ : {};
|
|
2490
|
+
function getViteEnv(key) {
|
|
2491
|
+
try {
|
|
2492
|
+
const meta = import.meta;
|
|
2493
|
+
return meta?.env?.[key];
|
|
2494
|
+
} catch {
|
|
2495
|
+
return void 0;
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
function envGet(key, viteKey) {
|
|
2499
|
+
return ENV[key] ?? (viteKey ? getViteEnv(viteKey) : void 0) ?? VITE_ENV[viteKey ?? key];
|
|
2500
|
+
}
|
|
2501
|
+
var NODE_ENV = envGet("NODE_ENV", "VITE_NODE_ENV") ?? "development";
|
|
2502
|
+
var CONFIGURED_LEVEL = (envGet("LOG_LEVEL", "VITE_LOG_LEVEL") ?? (NODE_ENV === "production" ? "info" : "debug")).toUpperCase();
|
|
2503
|
+
var MIN_PRIORITY = LEVEL_PRIORITY[CONFIGURED_LEVEL] ?? 0;
|
|
2504
|
+
var DEBUG_FILTER = (envGet("ALMADAR_DEBUG", "VITE_ALMADAR_DEBUG") ?? "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
2505
|
+
function matchesNamespace(namespace) {
|
|
2506
|
+
if (DEBUG_FILTER.length === 0) return true;
|
|
2507
|
+
return DEBUG_FILTER.some((pattern) => {
|
|
2508
|
+
if (pattern === "*" || pattern === "almadar:*") return true;
|
|
2509
|
+
if (pattern.endsWith(":*")) return namespace.startsWith(pattern.slice(0, -1));
|
|
2510
|
+
return namespace === pattern;
|
|
2511
|
+
});
|
|
2512
|
+
}
|
|
2513
|
+
function createLogger(namespace) {
|
|
2514
|
+
const nsAllowed = matchesNamespace(namespace);
|
|
2515
|
+
const log2 = (level, message, data, correlationId) => {
|
|
2516
|
+
if (LEVEL_PRIORITY[level] < MIN_PRIORITY) return;
|
|
2517
|
+
if (level === "DEBUG" && !nsAllowed) return;
|
|
2518
|
+
const prefix = `[${namespace}]`;
|
|
2519
|
+
const logData = correlationId ? { ...data, cid: correlationId } : data;
|
|
2520
|
+
switch (level) {
|
|
2521
|
+
case "DEBUG":
|
|
2522
|
+
console.debug(prefix, message, logData ?? "");
|
|
2523
|
+
break;
|
|
2524
|
+
case "INFO":
|
|
2525
|
+
console.info(prefix, message, logData ?? "");
|
|
2526
|
+
break;
|
|
2527
|
+
case "WARN":
|
|
2528
|
+
console.warn(prefix, message, logData ?? "");
|
|
2529
|
+
break;
|
|
2530
|
+
case "ERROR":
|
|
2531
|
+
console.error(prefix, message, logData ?? "");
|
|
2532
|
+
break;
|
|
2533
|
+
}
|
|
2534
|
+
};
|
|
2535
|
+
return {
|
|
2536
|
+
debug: (msg, data, cid) => log2("DEBUG", msg, data, cid),
|
|
2537
|
+
info: (msg, data, cid) => log2("INFO", msg, data, cid),
|
|
2538
|
+
warn: (msg, data, cid) => log2("WARN", msg, data, cid),
|
|
2539
|
+
error: (msg, data, cid) => log2("ERROR", msg, data, cid)
|
|
2540
|
+
};
|
|
2541
|
+
}
|
|
2542
|
+
createLogger("almadar:eventbus");
|
|
2543
|
+
createLogger("almadar:eventbus:subscribe");
|
|
2485
2544
|
var EventBusContext = createContext(null);
|
|
2486
2545
|
|
|
2487
2546
|
// hooks/useEventBus.ts
|
|
2547
|
+
var log = createLogger("almadar:eventbus");
|
|
2548
|
+
var subLog2 = createLogger("almadar:eventbus:subscribe");
|
|
2488
2549
|
function getGlobalEventBus() {
|
|
2489
2550
|
if (typeof window !== "undefined") {
|
|
2490
2551
|
return window.__kflowEventBus ?? null;
|
|
@@ -2501,6 +2562,7 @@ var fallbackEventBus = {
|
|
|
2501
2562
|
timestamp: Date.now()
|
|
2502
2563
|
};
|
|
2503
2564
|
const handlers = fallbackListeners.get(type);
|
|
2565
|
+
log.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
|
|
2504
2566
|
if (handlers) {
|
|
2505
2567
|
handlers.forEach((handler) => {
|
|
2506
2568
|
try {
|
|
@@ -2523,6 +2585,7 @@ var fallbackEventBus = {
|
|
|
2523
2585
|
fallbackListeners.set(type, /* @__PURE__ */ new Set());
|
|
2524
2586
|
}
|
|
2525
2587
|
fallbackListeners.get(type).add(listener);
|
|
2588
|
+
subLog2.debug("subscribe", { type, totalListeners: fallbackListeners.get(type).size });
|
|
2526
2589
|
return () => {
|
|
2527
2590
|
const handlers = fallbackListeners.get(type);
|
|
2528
2591
|
if (handlers) {
|
|
@@ -2546,6 +2609,7 @@ var fallbackEventBus = {
|
|
|
2546
2609
|
},
|
|
2547
2610
|
onAny: (listener) => {
|
|
2548
2611
|
fallbackAnyListeners.add(listener);
|
|
2612
|
+
subLog2.debug("subscribe:any", { totalAnyListeners: fallbackAnyListeners.size });
|
|
2549
2613
|
return () => {
|
|
2550
2614
|
fallbackAnyListeners.delete(listener);
|
|
2551
2615
|
};
|
package/dist/hooks/index.cjs
CHANGED
|
@@ -5,6 +5,7 @@ var providers = require('@almadar/ui/providers');
|
|
|
5
5
|
require('react/jsx-runtime');
|
|
6
6
|
var reactQuery = require('@tanstack/react-query');
|
|
7
7
|
|
|
8
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
8
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
10
|
|
|
10
11
|
var React2__default = /*#__PURE__*/_interopDefault(React2);
|
|
@@ -872,6 +873,67 @@ function useDeepAgentGeneration() {
|
|
|
872
873
|
submitInterruptDecisions
|
|
873
874
|
};
|
|
874
875
|
}
|
|
876
|
+
|
|
877
|
+
// lib/logger.ts
|
|
878
|
+
var LEVEL_PRIORITY = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3 };
|
|
879
|
+
var ENV = typeof process !== "undefined" && process.env ? process.env : {};
|
|
880
|
+
var VITE_ENV = typeof globalThis !== "undefined" && globalThis.__vite_env__ ? globalThis.__vite_env__ : {};
|
|
881
|
+
function getViteEnv(key) {
|
|
882
|
+
try {
|
|
883
|
+
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)) });
|
|
884
|
+
return meta?.env?.[key];
|
|
885
|
+
} catch {
|
|
886
|
+
return void 0;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
function envGet(key, viteKey) {
|
|
890
|
+
return ENV[key] ?? (viteKey ? getViteEnv(viteKey) : void 0) ?? VITE_ENV[viteKey ?? key];
|
|
891
|
+
}
|
|
892
|
+
var NODE_ENV = envGet("NODE_ENV", "VITE_NODE_ENV") ?? "development";
|
|
893
|
+
var CONFIGURED_LEVEL = (envGet("LOG_LEVEL", "VITE_LOG_LEVEL") ?? (NODE_ENV === "production" ? "info" : "debug")).toUpperCase();
|
|
894
|
+
var MIN_PRIORITY = LEVEL_PRIORITY[CONFIGURED_LEVEL] ?? 0;
|
|
895
|
+
var DEBUG_FILTER = (envGet("ALMADAR_DEBUG", "VITE_ALMADAR_DEBUG") ?? "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
896
|
+
function matchesNamespace(namespace) {
|
|
897
|
+
if (DEBUG_FILTER.length === 0) return true;
|
|
898
|
+
return DEBUG_FILTER.some((pattern) => {
|
|
899
|
+
if (pattern === "*" || pattern === "almadar:*") return true;
|
|
900
|
+
if (pattern.endsWith(":*")) return namespace.startsWith(pattern.slice(0, -1));
|
|
901
|
+
return namespace === pattern;
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
function createLogger(namespace) {
|
|
905
|
+
const nsAllowed = matchesNamespace(namespace);
|
|
906
|
+
const log2 = (level, message, data, correlationId) => {
|
|
907
|
+
if (LEVEL_PRIORITY[level] < MIN_PRIORITY) return;
|
|
908
|
+
if (level === "DEBUG" && !nsAllowed) return;
|
|
909
|
+
const prefix = `[${namespace}]`;
|
|
910
|
+
const logData = correlationId ? { ...data, cid: correlationId } : data;
|
|
911
|
+
switch (level) {
|
|
912
|
+
case "DEBUG":
|
|
913
|
+
console.debug(prefix, message, logData ?? "");
|
|
914
|
+
break;
|
|
915
|
+
case "INFO":
|
|
916
|
+
console.info(prefix, message, logData ?? "");
|
|
917
|
+
break;
|
|
918
|
+
case "WARN":
|
|
919
|
+
console.warn(prefix, message, logData ?? "");
|
|
920
|
+
break;
|
|
921
|
+
case "ERROR":
|
|
922
|
+
console.error(prefix, message, logData ?? "");
|
|
923
|
+
break;
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
return {
|
|
927
|
+
debug: (msg, data, cid) => log2("DEBUG", msg, data, cid),
|
|
928
|
+
info: (msg, data, cid) => log2("INFO", msg, data, cid),
|
|
929
|
+
warn: (msg, data, cid) => log2("WARN", msg, data, cid),
|
|
930
|
+
error: (msg, data, cid) => log2("ERROR", msg, data, cid)
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
// hooks/useEventBus.ts
|
|
935
|
+
var log = createLogger("almadar:eventbus");
|
|
936
|
+
var subLog = createLogger("almadar:eventbus:subscribe");
|
|
875
937
|
function getGlobalEventBus() {
|
|
876
938
|
if (typeof window !== "undefined") {
|
|
877
939
|
return window.__kflowEventBus ?? null;
|
|
@@ -888,6 +950,7 @@ var fallbackEventBus = {
|
|
|
888
950
|
timestamp: Date.now()
|
|
889
951
|
};
|
|
890
952
|
const handlers = fallbackListeners.get(type);
|
|
953
|
+
log.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
|
|
891
954
|
if (handlers) {
|
|
892
955
|
handlers.forEach((handler) => {
|
|
893
956
|
try {
|
|
@@ -910,6 +973,7 @@ var fallbackEventBus = {
|
|
|
910
973
|
fallbackListeners.set(type, /* @__PURE__ */ new Set());
|
|
911
974
|
}
|
|
912
975
|
fallbackListeners.get(type).add(listener);
|
|
976
|
+
subLog.debug("subscribe", { type, totalListeners: fallbackListeners.get(type).size });
|
|
913
977
|
return () => {
|
|
914
978
|
const handlers = fallbackListeners.get(type);
|
|
915
979
|
if (handlers) {
|
|
@@ -933,6 +997,7 @@ var fallbackEventBus = {
|
|
|
933
997
|
},
|
|
934
998
|
onAny: (listener) => {
|
|
935
999
|
fallbackAnyListeners.add(listener);
|
|
1000
|
+
subLog.debug("subscribe:any", { totalAnyListeners: fallbackAnyListeners.size });
|
|
936
1001
|
return () => {
|
|
937
1002
|
fallbackAnyListeners.delete(listener);
|
|
938
1003
|
};
|
|
@@ -1112,31 +1177,7 @@ function useUISlotManager() {
|
|
|
1112
1177
|
var SelectionContext = React2.createContext(null);
|
|
1113
1178
|
|
|
1114
1179
|
// hooks/useUIEvents.ts
|
|
1115
|
-
var
|
|
1116
|
-
// Form/CRUD events
|
|
1117
|
-
"UI:SAVE": "SAVE",
|
|
1118
|
-
"UI:CANCEL": "CANCEL",
|
|
1119
|
-
"UI:CLOSE": "CLOSE",
|
|
1120
|
-
"UI:VIEW": "VIEW",
|
|
1121
|
-
"UI:EDIT": "EDIT",
|
|
1122
|
-
"UI:DELETE": "DELETE",
|
|
1123
|
-
"UI:CREATE": "CREATE",
|
|
1124
|
-
"UI:SELECT": "SELECT",
|
|
1125
|
-
"UI:DESELECT": "DESELECT",
|
|
1126
|
-
"UI:SUBMIT": "SAVE",
|
|
1127
|
-
"UI:UPDATE_STATUS": "UPDATE_STATUS",
|
|
1128
|
-
"UI:SEARCH": "SEARCH",
|
|
1129
|
-
"UI:CLEAR_SEARCH": "CLEAR_SEARCH",
|
|
1130
|
-
"UI:ADD": "CREATE",
|
|
1131
|
-
// Game events (for closed circuit with GameMenu, GamePauseOverlay, GameOverScreen)
|
|
1132
|
-
"UI:PAUSE": "PAUSE",
|
|
1133
|
-
"UI:RESUME": "RESUME",
|
|
1134
|
-
"UI:RESTART": "RESTART",
|
|
1135
|
-
"UI:GAME_OVER": "GAME_OVER",
|
|
1136
|
-
"UI:START": "START",
|
|
1137
|
-
"UI:QUIT": "QUIT",
|
|
1138
|
-
"UI:INIT": "INIT"
|
|
1139
|
-
};
|
|
1180
|
+
var UI_PREFIX = "UI:";
|
|
1140
1181
|
function useUIEvents(dispatch, validEvents, eventBusInstance) {
|
|
1141
1182
|
const defaultEventBus = useEventBus();
|
|
1142
1183
|
const eventBus = eventBusInstance ?? defaultEventBus;
|
|
@@ -1148,15 +1189,18 @@ function useUIEvents(dispatch, validEvents, eventBusInstance) {
|
|
|
1148
1189
|
);
|
|
1149
1190
|
React2.useEffect(() => {
|
|
1150
1191
|
const unsubscribes = [];
|
|
1151
|
-
|
|
1152
|
-
const
|
|
1153
|
-
|
|
1192
|
+
if (stableValidEvents) {
|
|
1193
|
+
for (const smEvent of stableValidEvents) {
|
|
1194
|
+
const prefixedHandler = (event) => {
|
|
1154
1195
|
dispatch(smEvent, event.payload);
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1196
|
+
};
|
|
1197
|
+
unsubscribes.push(eventBus.on(`${UI_PREFIX}${smEvent}`, prefixedHandler));
|
|
1198
|
+
const directHandler = (event) => {
|
|
1199
|
+
dispatch(smEvent, event.payload);
|
|
1200
|
+
};
|
|
1201
|
+
unsubscribes.push(eventBus.on(smEvent, directHandler));
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1160
1204
|
const genericHandler = (event) => {
|
|
1161
1205
|
const eventName = event.payload?.event;
|
|
1162
1206
|
if (eventName) {
|
|
@@ -1166,30 +1210,11 @@ function useUIEvents(dispatch, validEvents, eventBusInstance) {
|
|
|
1166
1210
|
}
|
|
1167
1211
|
}
|
|
1168
1212
|
};
|
|
1169
|
-
|
|
1170
|
-
unsubscribes.push(genericUnsubscribe);
|
|
1171
|
-
if (stableValidEvents) {
|
|
1172
|
-
stableValidEvents.forEach((smEvent) => {
|
|
1173
|
-
const uiPrefixedEvent = `UI:${smEvent}`;
|
|
1174
|
-
const alreadyMapped = Object.keys(UI_EVENT_MAP).includes(uiPrefixedEvent);
|
|
1175
|
-
if (!alreadyMapped) {
|
|
1176
|
-
const directHandler = (event) => {
|
|
1177
|
-
dispatch(smEvent, event.payload);
|
|
1178
|
-
};
|
|
1179
|
-
const unsubscribePrefixed = eventBus.on(
|
|
1180
|
-
uiPrefixedEvent,
|
|
1181
|
-
directHandler
|
|
1182
|
-
);
|
|
1183
|
-
unsubscribes.push(unsubscribePrefixed);
|
|
1184
|
-
const unsubscribeDirect = eventBus.on(smEvent, directHandler);
|
|
1185
|
-
unsubscribes.push(unsubscribeDirect);
|
|
1186
|
-
}
|
|
1187
|
-
});
|
|
1188
|
-
}
|
|
1213
|
+
unsubscribes.push(eventBus.on(`${UI_PREFIX}DISPATCH`, genericHandler));
|
|
1189
1214
|
return () => {
|
|
1190
|
-
|
|
1215
|
+
for (const unsub of unsubscribes) {
|
|
1191
1216
|
if (typeof unsub === "function") unsub();
|
|
1192
|
-
}
|
|
1217
|
+
}
|
|
1193
1218
|
};
|
|
1194
1219
|
}, [eventBus, dispatch, stableValidEvents]);
|
|
1195
1220
|
}
|
|
@@ -1611,21 +1636,21 @@ function useOrbitalMutations(entityName, orbitalName, options) {
|
|
|
1611
1636
|
update: options?.events?.update || ENTITY_EVENTS.UPDATE,
|
|
1612
1637
|
delete: options?.events?.delete || ENTITY_EVENTS.DELETE
|
|
1613
1638
|
};
|
|
1614
|
-
const
|
|
1639
|
+
const log2 = (message, data) => {
|
|
1615
1640
|
if (options?.debug) {
|
|
1616
1641
|
console.log(`[useOrbitalMutations:${orbitalName}] ${message}`, data ?? "");
|
|
1617
1642
|
}
|
|
1618
1643
|
};
|
|
1619
1644
|
const createMutation = reactQuery.useMutation({
|
|
1620
1645
|
mutationFn: async (data) => {
|
|
1621
|
-
|
|
1646
|
+
log2("Creating entity", data);
|
|
1622
1647
|
return sendOrbitalEvent(orbitalName, {
|
|
1623
1648
|
event: events.create,
|
|
1624
1649
|
payload: { data, entityType: entityName }
|
|
1625
1650
|
});
|
|
1626
1651
|
},
|
|
1627
1652
|
onSuccess: (response) => {
|
|
1628
|
-
|
|
1653
|
+
log2("Create succeeded", response);
|
|
1629
1654
|
queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
|
|
1630
1655
|
},
|
|
1631
1656
|
onError: (error) => {
|
|
@@ -1637,7 +1662,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
|
|
|
1637
1662
|
id,
|
|
1638
1663
|
data
|
|
1639
1664
|
}) => {
|
|
1640
|
-
|
|
1665
|
+
log2(`Updating entity ${id}`, data);
|
|
1641
1666
|
return sendOrbitalEvent(orbitalName, {
|
|
1642
1667
|
event: events.update,
|
|
1643
1668
|
entityId: id,
|
|
@@ -1645,7 +1670,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
|
|
|
1645
1670
|
});
|
|
1646
1671
|
},
|
|
1647
1672
|
onSuccess: (response, variables) => {
|
|
1648
|
-
|
|
1673
|
+
log2("Update succeeded", response);
|
|
1649
1674
|
queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
|
|
1650
1675
|
queryClient.invalidateQueries({
|
|
1651
1676
|
queryKey: entityDataKeys.detail(entityName, variables.id)
|
|
@@ -1657,7 +1682,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
|
|
|
1657
1682
|
});
|
|
1658
1683
|
const deleteMutation = reactQuery.useMutation({
|
|
1659
1684
|
mutationFn: async (id) => {
|
|
1660
|
-
|
|
1685
|
+
log2(`Deleting entity ${id}`);
|
|
1661
1686
|
return sendOrbitalEvent(orbitalName, {
|
|
1662
1687
|
event: events.delete,
|
|
1663
1688
|
entityId: id,
|
|
@@ -1665,7 +1690,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
|
|
|
1665
1690
|
});
|
|
1666
1691
|
},
|
|
1667
1692
|
onSuccess: (response, id) => {
|
|
1668
|
-
|
|
1693
|
+
log2("Delete succeeded", response);
|
|
1669
1694
|
queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
|
|
1670
1695
|
queryClient.removeQueries({ queryKey: entityDataKeys.detail(entityName, id) });
|
|
1671
1696
|
},
|