@mantaq/traversal 0.0.2 → 0.1.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/index.mjs +10 -7
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ function collectActiveStates(snapshot, prefix, activeSet) {
|
|
|
8
8
|
if (!currentName) return;
|
|
9
9
|
const fullId = nodeId(prefix, currentName);
|
|
10
10
|
activeSet.add(fullId);
|
|
11
|
-
if (snapshot.regions && !snapshot.done) for (const [regionName, regionSnap] of Object.entries(snapshot.regions)) collectActiveStates(regionSnap, regionName, activeSet);
|
|
11
|
+
if (snapshot.regions && !snapshot.done && !snapshot.error) for (const [regionName, regionSnap] of Object.entries(snapshot.regions)) collectActiveStates(regionSnap, regionName, activeSet);
|
|
12
12
|
}
|
|
13
13
|
function nodeId(prefix, name) {
|
|
14
14
|
return prefix ? `${prefix}.${name}` : name;
|
|
@@ -26,13 +26,16 @@ function buildNodesFromStates(states, activeSet, pathPrefix) {
|
|
|
26
26
|
}
|
|
27
27
|
function invokeHandler(handler, eventId, context, actor) {
|
|
28
28
|
return Either.from(() => {
|
|
29
|
-
const result = handler({
|
|
29
|
+
const result = handler({
|
|
30
|
+
type: eventId,
|
|
31
|
+
payload: {}
|
|
32
|
+
}, {
|
|
30
33
|
context: new Context(() => context, () => {}),
|
|
31
34
|
actor
|
|
32
35
|
});
|
|
33
36
|
return {
|
|
34
37
|
targetName: result?.state?.name,
|
|
35
|
-
emitNames: result?.emit?.map((e) => e.
|
|
38
|
+
emitNames: result?.emit?.map((e) => e.type).filter((type) => Boolean(type)) ?? []
|
|
36
39
|
};
|
|
37
40
|
});
|
|
38
41
|
}
|
|
@@ -294,8 +297,8 @@ function wrapWithProxy(actor, hooks) {
|
|
|
294
297
|
return actor.options;
|
|
295
298
|
},
|
|
296
299
|
send(event) {
|
|
297
|
-
const {
|
|
298
|
-
pendingEventId.value =
|
|
300
|
+
const { type: eventType } = trackSendEvent(history, event);
|
|
301
|
+
pendingEventId.value = eventType;
|
|
299
302
|
try {
|
|
300
303
|
origSend(event);
|
|
301
304
|
} finally {
|
|
@@ -335,7 +338,7 @@ function recordTransition(history, from, to, eventId) {
|
|
|
335
338
|
});
|
|
336
339
|
}
|
|
337
340
|
function trackSendEvent(history, event) {
|
|
338
|
-
const eventId = event?.
|
|
341
|
+
const eventId = event?.type ?? "unknown";
|
|
339
342
|
history.append({
|
|
340
343
|
type: "send",
|
|
341
344
|
data: {
|
|
@@ -343,7 +346,7 @@ function trackSendEvent(history, event) {
|
|
|
343
346
|
timestamp: Date.now()
|
|
344
347
|
}
|
|
345
348
|
});
|
|
346
|
-
return {
|
|
349
|
+
return { type: eventId };
|
|
347
350
|
}
|
|
348
351
|
function instrument(actor) {
|
|
349
352
|
const history = new History();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mantaq/traversal",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Graph extraction, traversal algorithms, and runtime tracking for mantaq actors.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@mantaq/core": "0.0
|
|
24
|
-
"@mantaq/utils": "0.0.
|
|
23
|
+
"@mantaq/core": "0.1.0",
|
|
24
|
+
"@mantaq/utils": "0.0.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^26.2.0",
|