@almadar/ui 2.26.0 → 2.27.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/components/atoms/AnimatedGraphic.d.ts +29 -0
- package/dist/components/atoms/AnimatedReveal.d.ts +24 -0
- package/dist/components/atoms/index.d.ts +2 -0
- package/dist/components/index.cjs +1412 -1064
- package/dist/components/index.js +550 -204
- package/dist/components/organisms/debug/RuntimeDebugger.d.ts +2 -2
- package/dist/lib/index.cjs +62 -50
- package/dist/lib/index.js +62 -50
- package/dist/marketing/index.cjs +285 -0
- package/dist/marketing/index.d.cts +54 -1
- package/dist/marketing/index.d.ts +4 -0
- package/dist/marketing/index.js +285 -2
- package/dist/providers/index.cjs +445 -149
- package/dist/providers/index.js +357 -61
- package/dist/runtime/index.cjs +1344 -966
- package/dist/runtime/index.js +585 -207
- package/package.json +1 -1
|
@@ -6,8 +6,8 @@ export interface RuntimeDebuggerProps {
|
|
|
6
6
|
defaultCollapsed?: boolean;
|
|
7
7
|
/** Additional CSS classes */
|
|
8
8
|
className?: string;
|
|
9
|
-
/** Display mode: floating (fixed overlay)
|
|
10
|
-
mode?: 'floating' | 'inline';
|
|
9
|
+
/** Display mode: floating (fixed overlay), inline (block element), or verify (always-visible compact overlay for verification runs) */
|
|
10
|
+
mode?: 'floating' | 'inline' | 'verify';
|
|
11
11
|
/** Default active tab id */
|
|
12
12
|
defaultTab?: string;
|
|
13
13
|
/** Raw schema for EventDispatcherTab payload extraction */
|
package/dist/lib/index.cjs
CHANGED
|
@@ -428,41 +428,52 @@ function clearTraits() {
|
|
|
428
428
|
}
|
|
429
429
|
|
|
430
430
|
// lib/verificationRegistry.ts
|
|
431
|
-
var checks = /* @__PURE__ */ new Map();
|
|
432
|
-
var transitions = [];
|
|
433
|
-
var bridgeHealth = null;
|
|
434
431
|
var MAX_TRANSITIONS = 500;
|
|
435
|
-
|
|
432
|
+
function getState() {
|
|
433
|
+
if (typeof window !== "undefined") {
|
|
434
|
+
const w = window;
|
|
435
|
+
if (!w.__verificationRegistryState) {
|
|
436
|
+
w.__verificationRegistryState = {
|
|
437
|
+
checks: /* @__PURE__ */ new Map(),
|
|
438
|
+
transitions: [],
|
|
439
|
+
bridgeHealth: null,
|
|
440
|
+
listeners: /* @__PURE__ */ new Set()
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
return w.__verificationRegistryState;
|
|
444
|
+
}
|
|
445
|
+
return { checks: /* @__PURE__ */ new Map(), transitions: [], bridgeHealth: null, listeners: /* @__PURE__ */ new Set() };
|
|
446
|
+
}
|
|
436
447
|
function notifyListeners5() {
|
|
437
|
-
|
|
448
|
+
getState().listeners.forEach((l) => l());
|
|
438
449
|
exposeOnWindow();
|
|
439
450
|
}
|
|
440
451
|
function registerCheck(id, label, status = "pending", details) {
|
|
441
|
-
checks.set(id, { id, label, status, details, updatedAt: Date.now() });
|
|
452
|
+
getState().checks.set(id, { id, label, status, details, updatedAt: Date.now() });
|
|
442
453
|
notifyListeners5();
|
|
443
454
|
}
|
|
444
455
|
function updateCheck(id, status, details) {
|
|
445
|
-
const check = checks.get(id);
|
|
456
|
+
const check = getState().checks.get(id);
|
|
446
457
|
if (check) {
|
|
447
458
|
check.status = status;
|
|
448
459
|
if (details !== void 0) check.details = details;
|
|
449
460
|
check.updatedAt = Date.now();
|
|
450
461
|
} else {
|
|
451
|
-
checks.set(id, { id, label: id, status, details, updatedAt: Date.now() });
|
|
462
|
+
getState().checks.set(id, { id, label: id, status, details, updatedAt: Date.now() });
|
|
452
463
|
}
|
|
453
464
|
notifyListeners5();
|
|
454
465
|
}
|
|
455
466
|
function getAllChecks() {
|
|
456
|
-
return Array.from(checks.values());
|
|
467
|
+
return Array.from(getState().checks.values());
|
|
457
468
|
}
|
|
458
469
|
function recordTransition(trace) {
|
|
459
470
|
const entry = {
|
|
460
471
|
...trace,
|
|
461
472
|
id: `t-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
|
|
462
473
|
};
|
|
463
|
-
transitions.push(entry);
|
|
464
|
-
if (transitions.length > MAX_TRANSITIONS) {
|
|
465
|
-
transitions.shift();
|
|
474
|
+
getState().transitions.push(entry);
|
|
475
|
+
if (getState().transitions.length > MAX_TRANSITIONS) {
|
|
476
|
+
getState().transitions.shift();
|
|
466
477
|
}
|
|
467
478
|
if (entry.event === "INIT") {
|
|
468
479
|
const hasFetch = entry.effects.some((e) => e.type === "fetch");
|
|
@@ -497,13 +508,13 @@ function recordTransition(trace) {
|
|
|
497
508
|
notifyListeners5();
|
|
498
509
|
}
|
|
499
510
|
function getTransitions() {
|
|
500
|
-
return [...transitions];
|
|
511
|
+
return [...getState().transitions];
|
|
501
512
|
}
|
|
502
513
|
function getTransitionsForTrait(traitName) {
|
|
503
|
-
return transitions.filter((t) => t.traitName === traitName);
|
|
514
|
+
return getState().transitions.filter((t) => t.traitName === traitName);
|
|
504
515
|
}
|
|
505
516
|
function updateBridgeHealth(health) {
|
|
506
|
-
bridgeHealth = { ...health };
|
|
517
|
+
getState().bridgeHealth = { ...health };
|
|
507
518
|
const checkId = "server-bridge";
|
|
508
519
|
if (health.connected) {
|
|
509
520
|
registerCheck(checkId, "Server bridge connected", "pass");
|
|
@@ -518,7 +529,8 @@ function updateBridgeHealth(health) {
|
|
|
518
529
|
notifyListeners5();
|
|
519
530
|
}
|
|
520
531
|
function getBridgeHealth() {
|
|
521
|
-
|
|
532
|
+
const bh = getState().bridgeHealth;
|
|
533
|
+
return bh ? { ...bh } : null;
|
|
522
534
|
}
|
|
523
535
|
function getSummary() {
|
|
524
536
|
const allChecks = getAllChecks();
|
|
@@ -539,8 +551,8 @@ function getSnapshot() {
|
|
|
539
551
|
};
|
|
540
552
|
}
|
|
541
553
|
function subscribeToVerification(listener) {
|
|
542
|
-
|
|
543
|
-
return () =>
|
|
554
|
+
getState().listeners.add(listener);
|
|
555
|
+
return () => getState().listeners.delete(listener);
|
|
544
556
|
}
|
|
545
557
|
function exposeOnWindow() {
|
|
546
558
|
if (typeof window === "undefined") return;
|
|
@@ -557,7 +569,7 @@ function exposeOnWindow() {
|
|
|
557
569
|
}
|
|
558
570
|
function waitForTransition(event, timeoutMs = 1e4) {
|
|
559
571
|
return new Promise((resolve) => {
|
|
560
|
-
const existing = transitions.find((t) => t.event === event);
|
|
572
|
+
const existing = getState().transitions.find((t) => t.event === event);
|
|
561
573
|
if (existing) {
|
|
562
574
|
resolve(existing);
|
|
563
575
|
return;
|
|
@@ -567,7 +579,7 @@ function waitForTransition(event, timeoutMs = 1e4) {
|
|
|
567
579
|
resolve(null);
|
|
568
580
|
}, timeoutMs);
|
|
569
581
|
const unsub = subscribeToVerification(() => {
|
|
570
|
-
const found = transitions.find((t) => t.event === event);
|
|
582
|
+
const found = getState().transitions.find((t) => t.event === event);
|
|
571
583
|
if (found) {
|
|
572
584
|
clearTimeout(timeout);
|
|
573
585
|
unsub();
|
|
@@ -627,9 +639,9 @@ function updateAssetStatus(url, status) {
|
|
|
627
639
|
}
|
|
628
640
|
}
|
|
629
641
|
function clearVerification() {
|
|
630
|
-
checks.clear();
|
|
631
|
-
transitions.length = 0;
|
|
632
|
-
bridgeHealth = null;
|
|
642
|
+
getState().checks.clear();
|
|
643
|
+
getState().transitions.length = 0;
|
|
644
|
+
getState().bridgeHealth = null;
|
|
633
645
|
notifyListeners5();
|
|
634
646
|
}
|
|
635
647
|
exposeOnWindow();
|
|
@@ -812,9 +824,9 @@ function getEffectSummary(effects) {
|
|
|
812
824
|
});
|
|
813
825
|
return summaries.join(" | ");
|
|
814
826
|
}
|
|
815
|
-
function extractOutputsFromTransitions(
|
|
827
|
+
function extractOutputsFromTransitions(transitions) {
|
|
816
828
|
const outputs = /* @__PURE__ */ new Set();
|
|
817
|
-
|
|
829
|
+
transitions.forEach((t) => {
|
|
818
830
|
if (t.effects) {
|
|
819
831
|
t.effects.forEach((effect) => {
|
|
820
832
|
if (Array.isArray(effect)) {
|
|
@@ -839,7 +851,7 @@ function getNodeRadius(stateName, config) {
|
|
|
839
851
|
if (textLength > 6) return baseRadius + 8;
|
|
840
852
|
return baseRadius;
|
|
841
853
|
}
|
|
842
|
-
function calculateLayout(states,
|
|
854
|
+
function calculateLayout(states, transitions, options, config) {
|
|
843
855
|
const positions = {};
|
|
844
856
|
const entityBoxWidth = options.hasEntity ? 200 : 0;
|
|
845
857
|
const outputBoxWidth = options.hasOutputs ? 200 : 0;
|
|
@@ -848,7 +860,7 @@ function calculateLayout(states, transitions2, options, config) {
|
|
|
848
860
|
states.filter((s) => s.isFinal);
|
|
849
861
|
states.filter((s) => !s.isInitial && !s.isFinal);
|
|
850
862
|
let maxLabelLength = 0;
|
|
851
|
-
|
|
863
|
+
transitions.forEach((t) => {
|
|
852
864
|
if (t.effects && t.effects.length > 0) {
|
|
853
865
|
const summary = getEffectSummary(t.effects);
|
|
854
866
|
maxLabelLength = Math.max(maxLabelLength, summary.length);
|
|
@@ -874,7 +886,7 @@ function calculateLayout(states, transitions2, options, config) {
|
|
|
874
886
|
if (stateColumn[name] === void 0) {
|
|
875
887
|
stateColumn[name] = col;
|
|
876
888
|
}
|
|
877
|
-
|
|
889
|
+
transitions.forEach((t) => {
|
|
878
890
|
if (t.from === name && t.from !== t.to && !visited.has(t.to)) {
|
|
879
891
|
queue.push({ name: t.to, col: col + 1 });
|
|
880
892
|
}
|
|
@@ -954,11 +966,11 @@ function drawStateSvg(name, x, y, state, config) {
|
|
|
954
966
|
svg += `</g>`;
|
|
955
967
|
return svg;
|
|
956
968
|
}
|
|
957
|
-
function drawTransitionPathSvg(from, to,
|
|
969
|
+
function drawTransitionPathSvg(from, to, transitions, positions, config) {
|
|
958
970
|
const fromPos = positions[from];
|
|
959
971
|
const toPos = positions[to];
|
|
960
972
|
if (!fromPos || !toPos) return "";
|
|
961
|
-
const relevantTransitions =
|
|
973
|
+
const relevantTransitions = transitions.filter((t) => t.from === from && t.to === to);
|
|
962
974
|
if (relevantTransitions.length === 0) return "";
|
|
963
975
|
const fromRadius = getNodeRadius(from, config);
|
|
964
976
|
const toRadius = getNodeRadius(to, config);
|
|
@@ -972,7 +984,7 @@ function drawTransitionPathSvg(from, to, transitions2, positions, config) {
|
|
|
972
984
|
const startY = fromPos.y + ny * fromRadius;
|
|
973
985
|
const endX = toPos.x - nx * (toRadius + 5);
|
|
974
986
|
const endY = toPos.y - ny * (toRadius + 5);
|
|
975
|
-
const hasReverse =
|
|
987
|
+
const hasReverse = transitions.some((t) => t.from === to && t.to === from);
|
|
976
988
|
const isReverse = hasReverse && from > to;
|
|
977
989
|
const baseOffset = hasReverse ? 50 : 30;
|
|
978
990
|
const curveOffset = baseOffset + (relevantTransitions.length > 1 ? 20 : 0);
|
|
@@ -981,11 +993,11 @@ function drawTransitionPathSvg(from, to, transitions2, positions, config) {
|
|
|
981
993
|
const midY = (startY + endY) / 2 + curveOffset * curveDirection;
|
|
982
994
|
return `<path class="transition-path" data-from="${from}" data-to="${to}" d="M ${startX} ${startY} Q ${midX} ${midY} ${endX} ${endY}" stroke="${config.colors.arrow}" stroke-width="1.5" fill="none" marker-end="url(#arrow)"/>`;
|
|
983
995
|
}
|
|
984
|
-
function drawTransitionLabelsSvg(from, to,
|
|
996
|
+
function drawTransitionLabelsSvg(from, to, transitions, positions, config) {
|
|
985
997
|
const fromPos = positions[from];
|
|
986
998
|
const toPos = positions[to];
|
|
987
999
|
if (!fromPos || !toPos) return "";
|
|
988
|
-
const relevantTransitions =
|
|
1000
|
+
const relevantTransitions = transitions.filter((t) => t.from === from && t.to === to);
|
|
989
1001
|
if (relevantTransitions.length === 0) return "";
|
|
990
1002
|
const fromRadius = getNodeRadius(from, config);
|
|
991
1003
|
const toRadius = getNodeRadius(to, config);
|
|
@@ -999,7 +1011,7 @@ function drawTransitionLabelsSvg(from, to, transitions2, positions, config) {
|
|
|
999
1011
|
const startY = fromPos.y + ny * fromRadius;
|
|
1000
1012
|
const endX = toPos.x - nx * (toRadius + 5);
|
|
1001
1013
|
const endY = toPos.y - ny * (toRadius + 5);
|
|
1002
|
-
const hasReverse =
|
|
1014
|
+
const hasReverse = transitions.some((t) => t.from === to && t.to === from);
|
|
1003
1015
|
const isReverse = hasReverse && from > to;
|
|
1004
1016
|
const baseOffset = hasReverse ? 50 : 40;
|
|
1005
1017
|
const curveOffset = baseOffset + (relevantTransitions.length > 1 ? 25 : 0);
|
|
@@ -1104,15 +1116,15 @@ function drawLegendSvg(y, config) {
|
|
|
1104
1116
|
}
|
|
1105
1117
|
function renderStateMachineToSvg(stateMachine, options = {}, config = DEFAULT_CONFIG) {
|
|
1106
1118
|
const states = stateMachine.states || [];
|
|
1107
|
-
const
|
|
1119
|
+
const transitions = stateMachine.transitions || [];
|
|
1108
1120
|
const title = options.title || "";
|
|
1109
1121
|
const entity = options.entity;
|
|
1110
|
-
const outputs = extractOutputsFromTransitions(
|
|
1122
|
+
const outputs = extractOutputsFromTransitions(transitions);
|
|
1111
1123
|
const layoutOptions = {
|
|
1112
1124
|
hasEntity: !!entity,
|
|
1113
1125
|
hasOutputs: outputs.length > 0
|
|
1114
1126
|
};
|
|
1115
|
-
const { positions, width, height } = calculateLayout(states,
|
|
1127
|
+
const { positions, width, height } = calculateLayout(states, transitions, layoutOptions, config);
|
|
1116
1128
|
let svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height + 40}" viewBox="0 0 ${width} ${height + 40}" class="orbital-state-machine" style="display: block; max-width: none;">`;
|
|
1117
1129
|
svg += `<defs>`;
|
|
1118
1130
|
svg += createArrowMarkerSvg("arrow", config.colors.arrow, config);
|
|
@@ -1130,22 +1142,22 @@ function renderStateMachineToSvg(stateMachine, options = {}, config = DEFAULT_CO
|
|
|
1130
1142
|
svg += drawEntityInputSvg(entity, 20, height / 2);
|
|
1131
1143
|
}
|
|
1132
1144
|
const drawnPairs = /* @__PURE__ */ new Set();
|
|
1133
|
-
|
|
1145
|
+
transitions.forEach((transition) => {
|
|
1134
1146
|
const pairKey = `${transition.from}->${transition.to}`;
|
|
1135
1147
|
if (!drawnPairs.has(pairKey)) {
|
|
1136
1148
|
drawnPairs.add(pairKey);
|
|
1137
|
-
svg += drawTransitionPathSvg(transition.from, transition.to,
|
|
1149
|
+
svg += drawTransitionPathSvg(transition.from, transition.to, transitions, positions, config);
|
|
1138
1150
|
}
|
|
1139
1151
|
});
|
|
1140
1152
|
for (const [name, pos] of Object.entries(positions)) {
|
|
1141
1153
|
svg += drawStateSvg(name, pos.x, pos.y, pos.state, config);
|
|
1142
1154
|
}
|
|
1143
1155
|
drawnPairs.clear();
|
|
1144
|
-
|
|
1156
|
+
transitions.forEach((transition) => {
|
|
1145
1157
|
const pairKey = `${transition.from}->${transition.to}`;
|
|
1146
1158
|
if (!drawnPairs.has(pairKey)) {
|
|
1147
1159
|
drawnPairs.add(pairKey);
|
|
1148
|
-
svg += drawTransitionLabelsSvg(transition.from, transition.to,
|
|
1160
|
+
svg += drawTransitionLabelsSvg(transition.from, transition.to, transitions, positions, config);
|
|
1149
1161
|
}
|
|
1150
1162
|
});
|
|
1151
1163
|
if (outputs.length > 0) {
|
|
@@ -1176,11 +1188,11 @@ function extractStateMachine(data) {
|
|
|
1176
1188
|
}
|
|
1177
1189
|
return null;
|
|
1178
1190
|
}
|
|
1179
|
-
function calculateTransitionPathData(from, to,
|
|
1191
|
+
function calculateTransitionPathData(from, to, transitions, positions, config) {
|
|
1180
1192
|
const fromPos = positions[from];
|
|
1181
1193
|
const toPos = positions[to];
|
|
1182
1194
|
if (!fromPos || !toPos) return null;
|
|
1183
|
-
const relevantTransitions =
|
|
1195
|
+
const relevantTransitions = transitions.filter((t) => t.from === from && t.to === to);
|
|
1184
1196
|
if (relevantTransitions.length === 0) return null;
|
|
1185
1197
|
const fromRadius = getNodeRadius(from, config);
|
|
1186
1198
|
const toRadius = getNodeRadius(to, config);
|
|
@@ -1211,7 +1223,7 @@ function calculateTransitionPathData(from, to, transitions2, positions, config)
|
|
|
1211
1223
|
const startY = fromPos.y + ny * fromRadius;
|
|
1212
1224
|
const endX = toPos.x - nx * (toRadius + 5);
|
|
1213
1225
|
const endY = toPos.y - ny * (toRadius + 5);
|
|
1214
|
-
const hasReverse =
|
|
1226
|
+
const hasReverse = transitions.some((t) => t.from === to && t.to === from);
|
|
1215
1227
|
const isReverse = hasReverse && from > to;
|
|
1216
1228
|
const baseOffset = hasReverse ? 50 : 30;
|
|
1217
1229
|
const curveOffset = baseOffset + (relevantTransitions.length > 1 ? 20 : 0);
|
|
@@ -1226,15 +1238,15 @@ function calculateTransitionPathData(from, to, transitions2, positions, config)
|
|
|
1226
1238
|
}
|
|
1227
1239
|
function renderStateMachineToDomData(stateMachine, options = {}, config = DEFAULT_CONFIG) {
|
|
1228
1240
|
const states = stateMachine.states || [];
|
|
1229
|
-
const
|
|
1241
|
+
const transitions = stateMachine.transitions || [];
|
|
1230
1242
|
const title = options.title || "";
|
|
1231
1243
|
const entity = options.entity;
|
|
1232
|
-
const outputs = extractOutputsFromTransitions(
|
|
1244
|
+
const outputs = extractOutputsFromTransitions(transitions);
|
|
1233
1245
|
const layoutOptions = {
|
|
1234
1246
|
hasEntity: !!entity,
|
|
1235
1247
|
hasOutputs: outputs.length > 0
|
|
1236
1248
|
};
|
|
1237
|
-
const { positions, width, height } = calculateLayout(states,
|
|
1249
|
+
const { positions, width, height } = calculateLayout(states, transitions, layoutOptions, config);
|
|
1238
1250
|
const domStates = Object.entries(positions).map(([name, pos]) => ({
|
|
1239
1251
|
id: `state-${name}`,
|
|
1240
1252
|
name,
|
|
@@ -1248,14 +1260,14 @@ function renderStateMachineToDomData(stateMachine, options = {}, config = DEFAUL
|
|
|
1248
1260
|
const domPaths = [];
|
|
1249
1261
|
const domLabels = [];
|
|
1250
1262
|
const drawnPairs = /* @__PURE__ */ new Set();
|
|
1251
|
-
|
|
1263
|
+
transitions.forEach((transition, idx) => {
|
|
1252
1264
|
const pairKey = `${transition.from}->${transition.to}`;
|
|
1253
1265
|
if (!drawnPairs.has(pairKey)) {
|
|
1254
1266
|
drawnPairs.add(pairKey);
|
|
1255
1267
|
const pathData2 = calculateTransitionPathData(
|
|
1256
1268
|
transition.from,
|
|
1257
1269
|
transition.to,
|
|
1258
|
-
|
|
1270
|
+
transitions,
|
|
1259
1271
|
positions,
|
|
1260
1272
|
config
|
|
1261
1273
|
);
|
|
@@ -1276,7 +1288,7 @@ function renderStateMachineToDomData(stateMachine, options = {}, config = DEFAUL
|
|
|
1276
1288
|
const pathData = calculateTransitionPathData(
|
|
1277
1289
|
transition.from,
|
|
1278
1290
|
transition.to,
|
|
1279
|
-
|
|
1291
|
+
transitions,
|
|
1280
1292
|
positions,
|
|
1281
1293
|
config
|
|
1282
1294
|
);
|
package/dist/lib/index.js
CHANGED
|
@@ -426,41 +426,52 @@ function clearTraits() {
|
|
|
426
426
|
}
|
|
427
427
|
|
|
428
428
|
// lib/verificationRegistry.ts
|
|
429
|
-
var checks = /* @__PURE__ */ new Map();
|
|
430
|
-
var transitions = [];
|
|
431
|
-
var bridgeHealth = null;
|
|
432
429
|
var MAX_TRANSITIONS = 500;
|
|
433
|
-
|
|
430
|
+
function getState() {
|
|
431
|
+
if (typeof window !== "undefined") {
|
|
432
|
+
const w = window;
|
|
433
|
+
if (!w.__verificationRegistryState) {
|
|
434
|
+
w.__verificationRegistryState = {
|
|
435
|
+
checks: /* @__PURE__ */ new Map(),
|
|
436
|
+
transitions: [],
|
|
437
|
+
bridgeHealth: null,
|
|
438
|
+
listeners: /* @__PURE__ */ new Set()
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
return w.__verificationRegistryState;
|
|
442
|
+
}
|
|
443
|
+
return { checks: /* @__PURE__ */ new Map(), transitions: [], bridgeHealth: null, listeners: /* @__PURE__ */ new Set() };
|
|
444
|
+
}
|
|
434
445
|
function notifyListeners5() {
|
|
435
|
-
|
|
446
|
+
getState().listeners.forEach((l) => l());
|
|
436
447
|
exposeOnWindow();
|
|
437
448
|
}
|
|
438
449
|
function registerCheck(id, label, status = "pending", details) {
|
|
439
|
-
checks.set(id, { id, label, status, details, updatedAt: Date.now() });
|
|
450
|
+
getState().checks.set(id, { id, label, status, details, updatedAt: Date.now() });
|
|
440
451
|
notifyListeners5();
|
|
441
452
|
}
|
|
442
453
|
function updateCheck(id, status, details) {
|
|
443
|
-
const check = checks.get(id);
|
|
454
|
+
const check = getState().checks.get(id);
|
|
444
455
|
if (check) {
|
|
445
456
|
check.status = status;
|
|
446
457
|
if (details !== void 0) check.details = details;
|
|
447
458
|
check.updatedAt = Date.now();
|
|
448
459
|
} else {
|
|
449
|
-
checks.set(id, { id, label: id, status, details, updatedAt: Date.now() });
|
|
460
|
+
getState().checks.set(id, { id, label: id, status, details, updatedAt: Date.now() });
|
|
450
461
|
}
|
|
451
462
|
notifyListeners5();
|
|
452
463
|
}
|
|
453
464
|
function getAllChecks() {
|
|
454
|
-
return Array.from(checks.values());
|
|
465
|
+
return Array.from(getState().checks.values());
|
|
455
466
|
}
|
|
456
467
|
function recordTransition(trace) {
|
|
457
468
|
const entry = {
|
|
458
469
|
...trace,
|
|
459
470
|
id: `t-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
|
|
460
471
|
};
|
|
461
|
-
transitions.push(entry);
|
|
462
|
-
if (transitions.length > MAX_TRANSITIONS) {
|
|
463
|
-
transitions.shift();
|
|
472
|
+
getState().transitions.push(entry);
|
|
473
|
+
if (getState().transitions.length > MAX_TRANSITIONS) {
|
|
474
|
+
getState().transitions.shift();
|
|
464
475
|
}
|
|
465
476
|
if (entry.event === "INIT") {
|
|
466
477
|
const hasFetch = entry.effects.some((e) => e.type === "fetch");
|
|
@@ -495,13 +506,13 @@ function recordTransition(trace) {
|
|
|
495
506
|
notifyListeners5();
|
|
496
507
|
}
|
|
497
508
|
function getTransitions() {
|
|
498
|
-
return [...transitions];
|
|
509
|
+
return [...getState().transitions];
|
|
499
510
|
}
|
|
500
511
|
function getTransitionsForTrait(traitName) {
|
|
501
|
-
return transitions.filter((t) => t.traitName === traitName);
|
|
512
|
+
return getState().transitions.filter((t) => t.traitName === traitName);
|
|
502
513
|
}
|
|
503
514
|
function updateBridgeHealth(health) {
|
|
504
|
-
bridgeHealth = { ...health };
|
|
515
|
+
getState().bridgeHealth = { ...health };
|
|
505
516
|
const checkId = "server-bridge";
|
|
506
517
|
if (health.connected) {
|
|
507
518
|
registerCheck(checkId, "Server bridge connected", "pass");
|
|
@@ -516,7 +527,8 @@ function updateBridgeHealth(health) {
|
|
|
516
527
|
notifyListeners5();
|
|
517
528
|
}
|
|
518
529
|
function getBridgeHealth() {
|
|
519
|
-
|
|
530
|
+
const bh = getState().bridgeHealth;
|
|
531
|
+
return bh ? { ...bh } : null;
|
|
520
532
|
}
|
|
521
533
|
function getSummary() {
|
|
522
534
|
const allChecks = getAllChecks();
|
|
@@ -537,8 +549,8 @@ function getSnapshot() {
|
|
|
537
549
|
};
|
|
538
550
|
}
|
|
539
551
|
function subscribeToVerification(listener) {
|
|
540
|
-
|
|
541
|
-
return () =>
|
|
552
|
+
getState().listeners.add(listener);
|
|
553
|
+
return () => getState().listeners.delete(listener);
|
|
542
554
|
}
|
|
543
555
|
function exposeOnWindow() {
|
|
544
556
|
if (typeof window === "undefined") return;
|
|
@@ -555,7 +567,7 @@ function exposeOnWindow() {
|
|
|
555
567
|
}
|
|
556
568
|
function waitForTransition(event, timeoutMs = 1e4) {
|
|
557
569
|
return new Promise((resolve) => {
|
|
558
|
-
const existing = transitions.find((t) => t.event === event);
|
|
570
|
+
const existing = getState().transitions.find((t) => t.event === event);
|
|
559
571
|
if (existing) {
|
|
560
572
|
resolve(existing);
|
|
561
573
|
return;
|
|
@@ -565,7 +577,7 @@ function waitForTransition(event, timeoutMs = 1e4) {
|
|
|
565
577
|
resolve(null);
|
|
566
578
|
}, timeoutMs);
|
|
567
579
|
const unsub = subscribeToVerification(() => {
|
|
568
|
-
const found = transitions.find((t) => t.event === event);
|
|
580
|
+
const found = getState().transitions.find((t) => t.event === event);
|
|
569
581
|
if (found) {
|
|
570
582
|
clearTimeout(timeout);
|
|
571
583
|
unsub();
|
|
@@ -625,9 +637,9 @@ function updateAssetStatus(url, status) {
|
|
|
625
637
|
}
|
|
626
638
|
}
|
|
627
639
|
function clearVerification() {
|
|
628
|
-
checks.clear();
|
|
629
|
-
transitions.length = 0;
|
|
630
|
-
bridgeHealth = null;
|
|
640
|
+
getState().checks.clear();
|
|
641
|
+
getState().transitions.length = 0;
|
|
642
|
+
getState().bridgeHealth = null;
|
|
631
643
|
notifyListeners5();
|
|
632
644
|
}
|
|
633
645
|
exposeOnWindow();
|
|
@@ -810,9 +822,9 @@ function getEffectSummary(effects) {
|
|
|
810
822
|
});
|
|
811
823
|
return summaries.join(" | ");
|
|
812
824
|
}
|
|
813
|
-
function extractOutputsFromTransitions(
|
|
825
|
+
function extractOutputsFromTransitions(transitions) {
|
|
814
826
|
const outputs = /* @__PURE__ */ new Set();
|
|
815
|
-
|
|
827
|
+
transitions.forEach((t) => {
|
|
816
828
|
if (t.effects) {
|
|
817
829
|
t.effects.forEach((effect) => {
|
|
818
830
|
if (Array.isArray(effect)) {
|
|
@@ -837,7 +849,7 @@ function getNodeRadius(stateName, config) {
|
|
|
837
849
|
if (textLength > 6) return baseRadius + 8;
|
|
838
850
|
return baseRadius;
|
|
839
851
|
}
|
|
840
|
-
function calculateLayout(states,
|
|
852
|
+
function calculateLayout(states, transitions, options, config) {
|
|
841
853
|
const positions = {};
|
|
842
854
|
const entityBoxWidth = options.hasEntity ? 200 : 0;
|
|
843
855
|
const outputBoxWidth = options.hasOutputs ? 200 : 0;
|
|
@@ -846,7 +858,7 @@ function calculateLayout(states, transitions2, options, config) {
|
|
|
846
858
|
states.filter((s) => s.isFinal);
|
|
847
859
|
states.filter((s) => !s.isInitial && !s.isFinal);
|
|
848
860
|
let maxLabelLength = 0;
|
|
849
|
-
|
|
861
|
+
transitions.forEach((t) => {
|
|
850
862
|
if (t.effects && t.effects.length > 0) {
|
|
851
863
|
const summary = getEffectSummary(t.effects);
|
|
852
864
|
maxLabelLength = Math.max(maxLabelLength, summary.length);
|
|
@@ -872,7 +884,7 @@ function calculateLayout(states, transitions2, options, config) {
|
|
|
872
884
|
if (stateColumn[name] === void 0) {
|
|
873
885
|
stateColumn[name] = col;
|
|
874
886
|
}
|
|
875
|
-
|
|
887
|
+
transitions.forEach((t) => {
|
|
876
888
|
if (t.from === name && t.from !== t.to && !visited.has(t.to)) {
|
|
877
889
|
queue.push({ name: t.to, col: col + 1 });
|
|
878
890
|
}
|
|
@@ -952,11 +964,11 @@ function drawStateSvg(name, x, y, state, config) {
|
|
|
952
964
|
svg += `</g>`;
|
|
953
965
|
return svg;
|
|
954
966
|
}
|
|
955
|
-
function drawTransitionPathSvg(from, to,
|
|
967
|
+
function drawTransitionPathSvg(from, to, transitions, positions, config) {
|
|
956
968
|
const fromPos = positions[from];
|
|
957
969
|
const toPos = positions[to];
|
|
958
970
|
if (!fromPos || !toPos) return "";
|
|
959
|
-
const relevantTransitions =
|
|
971
|
+
const relevantTransitions = transitions.filter((t) => t.from === from && t.to === to);
|
|
960
972
|
if (relevantTransitions.length === 0) return "";
|
|
961
973
|
const fromRadius = getNodeRadius(from, config);
|
|
962
974
|
const toRadius = getNodeRadius(to, config);
|
|
@@ -970,7 +982,7 @@ function drawTransitionPathSvg(from, to, transitions2, positions, config) {
|
|
|
970
982
|
const startY = fromPos.y + ny * fromRadius;
|
|
971
983
|
const endX = toPos.x - nx * (toRadius + 5);
|
|
972
984
|
const endY = toPos.y - ny * (toRadius + 5);
|
|
973
|
-
const hasReverse =
|
|
985
|
+
const hasReverse = transitions.some((t) => t.from === to && t.to === from);
|
|
974
986
|
const isReverse = hasReverse && from > to;
|
|
975
987
|
const baseOffset = hasReverse ? 50 : 30;
|
|
976
988
|
const curveOffset = baseOffset + (relevantTransitions.length > 1 ? 20 : 0);
|
|
@@ -979,11 +991,11 @@ function drawTransitionPathSvg(from, to, transitions2, positions, config) {
|
|
|
979
991
|
const midY = (startY + endY) / 2 + curveOffset * curveDirection;
|
|
980
992
|
return `<path class="transition-path" data-from="${from}" data-to="${to}" d="M ${startX} ${startY} Q ${midX} ${midY} ${endX} ${endY}" stroke="${config.colors.arrow}" stroke-width="1.5" fill="none" marker-end="url(#arrow)"/>`;
|
|
981
993
|
}
|
|
982
|
-
function drawTransitionLabelsSvg(from, to,
|
|
994
|
+
function drawTransitionLabelsSvg(from, to, transitions, positions, config) {
|
|
983
995
|
const fromPos = positions[from];
|
|
984
996
|
const toPos = positions[to];
|
|
985
997
|
if (!fromPos || !toPos) return "";
|
|
986
|
-
const relevantTransitions =
|
|
998
|
+
const relevantTransitions = transitions.filter((t) => t.from === from && t.to === to);
|
|
987
999
|
if (relevantTransitions.length === 0) return "";
|
|
988
1000
|
const fromRadius = getNodeRadius(from, config);
|
|
989
1001
|
const toRadius = getNodeRadius(to, config);
|
|
@@ -997,7 +1009,7 @@ function drawTransitionLabelsSvg(from, to, transitions2, positions, config) {
|
|
|
997
1009
|
const startY = fromPos.y + ny * fromRadius;
|
|
998
1010
|
const endX = toPos.x - nx * (toRadius + 5);
|
|
999
1011
|
const endY = toPos.y - ny * (toRadius + 5);
|
|
1000
|
-
const hasReverse =
|
|
1012
|
+
const hasReverse = transitions.some((t) => t.from === to && t.to === from);
|
|
1001
1013
|
const isReverse = hasReverse && from > to;
|
|
1002
1014
|
const baseOffset = hasReverse ? 50 : 40;
|
|
1003
1015
|
const curveOffset = baseOffset + (relevantTransitions.length > 1 ? 25 : 0);
|
|
@@ -1102,15 +1114,15 @@ function drawLegendSvg(y, config) {
|
|
|
1102
1114
|
}
|
|
1103
1115
|
function renderStateMachineToSvg(stateMachine, options = {}, config = DEFAULT_CONFIG) {
|
|
1104
1116
|
const states = stateMachine.states || [];
|
|
1105
|
-
const
|
|
1117
|
+
const transitions = stateMachine.transitions || [];
|
|
1106
1118
|
const title = options.title || "";
|
|
1107
1119
|
const entity = options.entity;
|
|
1108
|
-
const outputs = extractOutputsFromTransitions(
|
|
1120
|
+
const outputs = extractOutputsFromTransitions(transitions);
|
|
1109
1121
|
const layoutOptions = {
|
|
1110
1122
|
hasEntity: !!entity,
|
|
1111
1123
|
hasOutputs: outputs.length > 0
|
|
1112
1124
|
};
|
|
1113
|
-
const { positions, width, height } = calculateLayout(states,
|
|
1125
|
+
const { positions, width, height } = calculateLayout(states, transitions, layoutOptions, config);
|
|
1114
1126
|
let svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height + 40}" viewBox="0 0 ${width} ${height + 40}" class="orbital-state-machine" style="display: block; max-width: none;">`;
|
|
1115
1127
|
svg += `<defs>`;
|
|
1116
1128
|
svg += createArrowMarkerSvg("arrow", config.colors.arrow, config);
|
|
@@ -1128,22 +1140,22 @@ function renderStateMachineToSvg(stateMachine, options = {}, config = DEFAULT_CO
|
|
|
1128
1140
|
svg += drawEntityInputSvg(entity, 20, height / 2);
|
|
1129
1141
|
}
|
|
1130
1142
|
const drawnPairs = /* @__PURE__ */ new Set();
|
|
1131
|
-
|
|
1143
|
+
transitions.forEach((transition) => {
|
|
1132
1144
|
const pairKey = `${transition.from}->${transition.to}`;
|
|
1133
1145
|
if (!drawnPairs.has(pairKey)) {
|
|
1134
1146
|
drawnPairs.add(pairKey);
|
|
1135
|
-
svg += drawTransitionPathSvg(transition.from, transition.to,
|
|
1147
|
+
svg += drawTransitionPathSvg(transition.from, transition.to, transitions, positions, config);
|
|
1136
1148
|
}
|
|
1137
1149
|
});
|
|
1138
1150
|
for (const [name, pos] of Object.entries(positions)) {
|
|
1139
1151
|
svg += drawStateSvg(name, pos.x, pos.y, pos.state, config);
|
|
1140
1152
|
}
|
|
1141
1153
|
drawnPairs.clear();
|
|
1142
|
-
|
|
1154
|
+
transitions.forEach((transition) => {
|
|
1143
1155
|
const pairKey = `${transition.from}->${transition.to}`;
|
|
1144
1156
|
if (!drawnPairs.has(pairKey)) {
|
|
1145
1157
|
drawnPairs.add(pairKey);
|
|
1146
|
-
svg += drawTransitionLabelsSvg(transition.from, transition.to,
|
|
1158
|
+
svg += drawTransitionLabelsSvg(transition.from, transition.to, transitions, positions, config);
|
|
1147
1159
|
}
|
|
1148
1160
|
});
|
|
1149
1161
|
if (outputs.length > 0) {
|
|
@@ -1174,11 +1186,11 @@ function extractStateMachine(data) {
|
|
|
1174
1186
|
}
|
|
1175
1187
|
return null;
|
|
1176
1188
|
}
|
|
1177
|
-
function calculateTransitionPathData(from, to,
|
|
1189
|
+
function calculateTransitionPathData(from, to, transitions, positions, config) {
|
|
1178
1190
|
const fromPos = positions[from];
|
|
1179
1191
|
const toPos = positions[to];
|
|
1180
1192
|
if (!fromPos || !toPos) return null;
|
|
1181
|
-
const relevantTransitions =
|
|
1193
|
+
const relevantTransitions = transitions.filter((t) => t.from === from && t.to === to);
|
|
1182
1194
|
if (relevantTransitions.length === 0) return null;
|
|
1183
1195
|
const fromRadius = getNodeRadius(from, config);
|
|
1184
1196
|
const toRadius = getNodeRadius(to, config);
|
|
@@ -1209,7 +1221,7 @@ function calculateTransitionPathData(from, to, transitions2, positions, config)
|
|
|
1209
1221
|
const startY = fromPos.y + ny * fromRadius;
|
|
1210
1222
|
const endX = toPos.x - nx * (toRadius + 5);
|
|
1211
1223
|
const endY = toPos.y - ny * (toRadius + 5);
|
|
1212
|
-
const hasReverse =
|
|
1224
|
+
const hasReverse = transitions.some((t) => t.from === to && t.to === from);
|
|
1213
1225
|
const isReverse = hasReverse && from > to;
|
|
1214
1226
|
const baseOffset = hasReverse ? 50 : 30;
|
|
1215
1227
|
const curveOffset = baseOffset + (relevantTransitions.length > 1 ? 20 : 0);
|
|
@@ -1224,15 +1236,15 @@ function calculateTransitionPathData(from, to, transitions2, positions, config)
|
|
|
1224
1236
|
}
|
|
1225
1237
|
function renderStateMachineToDomData(stateMachine, options = {}, config = DEFAULT_CONFIG) {
|
|
1226
1238
|
const states = stateMachine.states || [];
|
|
1227
|
-
const
|
|
1239
|
+
const transitions = stateMachine.transitions || [];
|
|
1228
1240
|
const title = options.title || "";
|
|
1229
1241
|
const entity = options.entity;
|
|
1230
|
-
const outputs = extractOutputsFromTransitions(
|
|
1242
|
+
const outputs = extractOutputsFromTransitions(transitions);
|
|
1231
1243
|
const layoutOptions = {
|
|
1232
1244
|
hasEntity: !!entity,
|
|
1233
1245
|
hasOutputs: outputs.length > 0
|
|
1234
1246
|
};
|
|
1235
|
-
const { positions, width, height } = calculateLayout(states,
|
|
1247
|
+
const { positions, width, height } = calculateLayout(states, transitions, layoutOptions, config);
|
|
1236
1248
|
const domStates = Object.entries(positions).map(([name, pos]) => ({
|
|
1237
1249
|
id: `state-${name}`,
|
|
1238
1250
|
name,
|
|
@@ -1246,14 +1258,14 @@ function renderStateMachineToDomData(stateMachine, options = {}, config = DEFAUL
|
|
|
1246
1258
|
const domPaths = [];
|
|
1247
1259
|
const domLabels = [];
|
|
1248
1260
|
const drawnPairs = /* @__PURE__ */ new Set();
|
|
1249
|
-
|
|
1261
|
+
transitions.forEach((transition, idx) => {
|
|
1250
1262
|
const pairKey = `${transition.from}->${transition.to}`;
|
|
1251
1263
|
if (!drawnPairs.has(pairKey)) {
|
|
1252
1264
|
drawnPairs.add(pairKey);
|
|
1253
1265
|
const pathData2 = calculateTransitionPathData(
|
|
1254
1266
|
transition.from,
|
|
1255
1267
|
transition.to,
|
|
1256
|
-
|
|
1268
|
+
transitions,
|
|
1257
1269
|
positions,
|
|
1258
1270
|
config
|
|
1259
1271
|
);
|
|
@@ -1274,7 +1286,7 @@ function renderStateMachineToDomData(stateMachine, options = {}, config = DEFAUL
|
|
|
1274
1286
|
const pathData = calculateTransitionPathData(
|
|
1275
1287
|
transition.from,
|
|
1276
1288
|
transition.to,
|
|
1277
|
-
|
|
1289
|
+
transitions,
|
|
1278
1290
|
positions,
|
|
1279
1291
|
config
|
|
1280
1292
|
);
|