Socket
Socket
Sign inDemoInstall

blueshell

Package Overview
Dependencies
5
Maintainers
6
Versions
241
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.4.2-whileBtv.3 to 3.4.2-whileBtv.4

2

dist/nodes/decorators/RepeatWhen.js

@@ -28,3 +28,3 @@ "use strict";

Base_1.Action.treePublisher.publishResult(state, event, false);
Parent_1.clearEventSeenRecursive(this, state);
Parent_1.modifyLastEventSeenRecursive(this, state, () => ({ action: 'clear' }));
return this.handleEvent(state, event);

@@ -31,0 +31,0 @@ }

@@ -24,3 +24,3 @@ "use strict";

Base_1.Action.treePublisher.publishResult(state, event, false);
Parent_1.clearEventSeenRecursive(this.child, state);
Parent_1.modifyLastEventSeenRecursive(this.child, state, () => ({ action: 'clear' }));
}

@@ -45,7 +45,15 @@ storage.ranAtLeastOnce = true;

if (storage.lastLoopResult) {
// Parent will see one additional event than the child when it evaluates the conditional
// and breaks out of the loop. We still want that child's lastResult to be shown in btv
// though, so we must pretend that it saw the last event.
// FIXME: this should be recursive for the last child of every descendant
this.child.getNodeStorage(state).lastEventSeen = storage.lastEventSeen;
// While will see one additional event than the descendants when it evaluates the conditional
// and breaks out of the loop. We still want all descendants who ran on the last loop iteration
// to display their result in btv, so we will advance those that are behind by one event one event
// forward to compensate.
Parent_1.modifyLastEventSeenRecursive(this.child, state, (node) => {
const s = node.getNodeStorage(state);
if (s.lastEventSeen && s.lastEventSeen === storage.lastEventSeen - 1) {
return { action: 'set', value: storage.lastEventSeen };
}
else {
return { action: 'none' };
}
});
}

@@ -52,0 +60,0 @@ storage.ranAtLeastOnce = undefined;

@@ -12,7 +12,15 @@ import { BlueshellState, BaseNode, ParentNode } from '../models';

/**
* Clears the last event seen property of node and all of node's children
* Modify the lastEventSeen property recursively from a root node according to the supplied nodeQuery
* @param node The node to clear
* @param state The state holding the node storage
* @param nodeQuery Criteria which dictates how to modify lastEventSeen on each node
*/
export declare function clearEventSeenRecursive<S extends BlueshellState, E>(node: BaseNode<S, E>, state: S): void;
export declare function modifyLastEventSeenRecursive<S extends BlueshellState, E>(node: BaseNode<S, E>, state: S, nodeQuery: (node: BaseNode<S, E>) => ({
action: 'none';
} | {
action: 'clear';
} | {
action: 'set';
value: number;
})): void;
/**

@@ -19,0 +27,0 @@ * Base class for all nodes that expose a list of children.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Parent = exports.clearEventSeenRecursive = exports.setEventCounter = void 0;
exports.Parent = exports.modifyLastEventSeenRecursive = exports.setEventCounter = void 0;
const models_1 = require("../models");

@@ -26,16 +26,27 @@ const Base_1 = require("./Base");

/**
* Clears the last event seen property of node and all of node's children
* Modify the lastEventSeen property recursively from a root node according to the supplied nodeQuery
* @param node The node to clear
* @param state The state holding the node storage
* @param nodeQuery Criteria which dictates how to modify lastEventSeen on each node
*/
function clearEventSeenRecursive(node, state) {
function modifyLastEventSeenRecursive(node, state, nodeQuery) {
if (models_1.isParentNode(node)) {
node.getChildren().forEach((child) => {
clearEventSeenRecursive(child, state);
const children = node.getChildren();
children.forEach((child, index) => {
modifyLastEventSeenRecursive(child, state, nodeQuery);
});
}
const nodeQueryResult = nodeQuery(node);
const nodeStorage = node.getNodeStorage(state);
nodeStorage.lastEventSeen = undefined;
if (nodeQueryResult.action === 'none') {
// do nothing
}
else if (nodeQueryResult.action === 'clear') {
nodeStorage.lastEventSeen = undefined;
}
else if (nodeQueryResult.action === 'set') {
nodeStorage.lastEventSeen = nodeQueryResult.value;
}
}
exports.clearEventSeenRecursive = clearEventSeenRecursive;
exports.modifyLastEventSeenRecursive = modifyLastEventSeenRecursive;
/**

@@ -42,0 +53,0 @@ * Base class for all nodes that expose a list of children.

import {ResultCode, BlueshellState, BaseNode, ConditionalWithResult} from '../../models';
import {Action} from '../Base';
import {Decorator} from '../Decorator';
import {clearEventSeenRecursive} from '../Parent';
import {modifyLastEventSeenRecursive} from '../Parent';

@@ -29,3 +29,3 @@ /**

Action.treePublisher.publishResult(state, event, false);
clearEventSeenRecursive(this, state);
modifyLastEventSeenRecursive(this, state, () => ({action: 'clear'}));
return this.handleEvent(state, event);

@@ -32,0 +32,0 @@ } else {

import {ResultCode, BlueshellState, BaseNode, rc, Conditional, NodeStorage} from '../../models';
import {Action} from '../Base';
import {Decorator} from '../Decorator';
import {clearEventSeenRecursive} from '../Parent';
import {modifyLastEventSeenRecursive} from '../Parent';

@@ -33,3 +33,3 @@ interface WhileNodeStorage extends NodeStorage {

Action.treePublisher.publishResult(state, event, false);
clearEventSeenRecursive(this.child, state);
modifyLastEventSeenRecursive(this.child, state, () => ({action: 'clear'}));
}

@@ -55,7 +55,15 @@ storage.ranAtLeastOnce = true;

if (storage.lastLoopResult) {
// Parent will see one additional event than the child when it evaluates the conditional
// and breaks out of the loop. We still want that child's lastResult to be shown in btv
// though, so we must pretend that it saw the last event.
// FIXME: this should be recursive for the last child of every descendant
this.child.getNodeStorage(state).lastEventSeen = storage.lastEventSeen;
// While will see one additional event than the descendants when it evaluates the conditional
// and breaks out of the loop. We still want all descendants who ran on the last loop iteration
// to display their result in btv, so we will advance those that are behind by one event one event
// forward to compensate.
modifyLastEventSeenRecursive(this.child, state, (node: BaseNode<S, E>) => {
const s = node.getNodeStorage(state);
if (s.lastEventSeen && s.lastEventSeen === storage.lastEventSeen! - 1) {
return {action: 'set', value: storage.lastEventSeen!};
} else {
return {action: 'none'};
}
});
}

@@ -62,0 +70,0 @@ storage.ranAtLeastOnce = undefined;

@@ -28,14 +28,32 @@ import {BlueshellState, BaseNode, ParentNode, isParentNode} from '../models';

/**
* Clears the last event seen property of node and all of node's children
* Modify the lastEventSeen property recursively from a root node according to the supplied nodeQuery
* @param node The node to clear
* @param state The state holding the node storage
* @param nodeQuery Criteria which dictates how to modify lastEventSeen on each node
*/
export function clearEventSeenRecursive<S extends BlueshellState, E>(node: BaseNode<S, E>, state: S) {
export function modifyLastEventSeenRecursive<S extends BlueshellState, E>(
node: BaseNode<S, E>,
state: S,
nodeQuery: (node: BaseNode<S, E>,) => (
{action: 'none'} | {action: 'clear'} | {action: 'set', value: number}
),
): void {
if (isParentNode(node)) {
node.getChildren().forEach((child: any) => {
clearEventSeenRecursive(child, state);
const children = node.getChildren();
children.forEach((child: any, index: number) => {
modifyLastEventSeenRecursive(child, state, nodeQuery);
});
}
const nodeQueryResult = nodeQuery(node);
const nodeStorage = node.getNodeStorage(state);
nodeStorage.lastEventSeen = undefined;
if (nodeQueryResult.action === 'none') {
// do nothing
} else if (nodeQueryResult.action === 'clear') {
nodeStorage.lastEventSeen = undefined;
} else if (nodeQueryResult.action === 'set') {
nodeStorage.lastEventSeen = nodeQueryResult.value;
}
}

@@ -42,0 +60,0 @@

@@ -103,3 +103,3 @@ {

"types": "dist/index.d.ts",
"version": "3.4.2-whileBtv.3"
"version": "3.4.2-whileBtv.4"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc