@rkmodules/rules 0.0.117 → 0.0.118

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.esm.js CHANGED
@@ -1847,7 +1847,7 @@ var mergeTree = {
1847
1847
  name: "mergeTree",
1848
1848
  label: "Merge Tree",
1849
1849
  description: "Merge groups with the same index into a single tree.",
1850
- nodeType: "Merge",
1850
+ nodeType: "DynamicInput",
1851
1851
  inputs: {},
1852
1852
  outputs: {
1853
1853
  result: "any",
@@ -2214,7 +2214,7 @@ var mergeObject = {
2214
2214
  name: "mergeObject",
2215
2215
  label: "Merge Object",
2216
2216
  description: "Merges objects in groups",
2217
- nodeType: "Merge",
2217
+ nodeType: "DynamicInput",
2218
2218
  inputs: {},
2219
2219
  outputs: {
2220
2220
  object: "any",
@@ -2287,11 +2287,37 @@ var listToArray = {
2287
2287
  }); },
2288
2288
  };
2289
2289
 
2290
+ var objectEntries = {
2291
+ name: "objectEntries",
2292
+ label: "Entries",
2293
+ description: "Gets keys and pairs of an object",
2294
+ inputs: {
2295
+ object: "any",
2296
+ },
2297
+ outputs: {
2298
+ keys: "string",
2299
+ values: "any",
2300
+ },
2301
+ impl: function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
2302
+ var keys, values;
2303
+ var _c = _b.object, object = _c === void 0 ? {} : _c;
2304
+ return __generator(this, function (_d) {
2305
+ keys = mapTree(object, function (obj) { return Object.keys(obj); });
2306
+ values = mapTree(object, function (obj) { return Object.values(obj); });
2307
+ return [2 /*return*/, {
2308
+ keys: keys,
2309
+ values: values,
2310
+ }];
2311
+ });
2312
+ }); },
2313
+ };
2314
+
2290
2315
  var _a$1;
2291
2316
  var primitives$1 = (_a$1 = {},
2292
2317
  _a$1[object.name] = object,
2293
2318
  _a$1[listToArray.name] = listToArray,
2294
2319
  _a$1[mergeObject.name] = mergeObject,
2320
+ _a$1[objectEntries.name] = objectEntries,
2295
2321
  _a$1);
2296
2322
 
2297
2323
  var Lib = {
@@ -6081,54 +6107,17 @@ InputNode.displayName = "InputNode";
6081
6107
  function uid() {
6082
6108
  return Math.random().toString(36).substring(2, 15);
6083
6109
  }
6084
- var Merge = React.memo(function (_a) {
6085
- var _b;
6086
- var _c;
6110
+ var DynamicInput = React.memo(function (_a) {
6087
6111
  var id = _a.id, data = _a.data, selected = _a.selected;
6088
- var outputEntries = Object.entries(data.outputDefs || {});
6089
- var focus = (_c = outputEntries[0]) === null || _c === void 0 ? void 0 : _c[0];
6090
- var _d = __read(React.useState(false), 2), showPreview = _d[0], setShowPreview = _d[1];
6091
- var engine = useEngine();
6092
- var _e = __read(React.useState({}), 2), result = _e[0], setResult = _e[1];
6093
- var _f = __read(React.useState(null), 2), duration = _f[0], setDuration = _f[1];
6094
- var previewValue = focus ? result[focus] : Object.values(result)[0];
6095
- React.useEffect(function () {
6096
- return engine.subscribe("functionResult", function (event) {
6097
- var _a;
6098
- if (event.name === id) {
6099
- setResult(event.result || {});
6100
- setDuration((_a = event.duration) !== null && _a !== void 0 ? _a : null);
6101
- }
6102
- });
6103
- }, []);
6104
6112
  var inputs = Object.fromEntries(Object.keys(data.inputs || {}).map(function (name, i) { return [
6105
6113
  name,
6106
6114
  { type: "any", label: "D".concat(i + 1) },
6107
6115
  ]; }));
6108
6116
  var inputCount = Object.keys(inputs).length;
6109
6117
  inputs[uid()] = { type: "any", label: "D".concat(inputCount + 1) };
6110
- var outputs = __assign({}, (data.outputDefs || {}));
6111
- return (React.createElement(NodeContainer, { label: data.label, selected: selected, id: id },
6112
- React.createElement("div", { className: styles.Description }, data.description),
6113
- React.createElement("div", { className: styles.Ports },
6114
- Object.entries(outputs || {}).map(function (_a) {
6115
- var _b = __read(_a, 2), name = _b[0], varDef = _b[1];
6116
- return (React.createElement(Output, { key: name, name: name, varDef: varDef, id: id }));
6117
- }),
6118
- Object.entries(inputs || {}).map(function (_a) {
6119
- var _b = __read(_a, 2), name = _b[0], varDef = _b[1];
6120
- return (React.createElement(Input, { key: name, name: name, varDef: varDef, id: id, data: data }));
6121
- })),
6122
- React.createElement("div", { className: classNames(styles.PreviewHead, (_b = {},
6123
- _b[styles.expanded] = showPreview,
6124
- _b)), onClick: function () { return setShowPreview(!showPreview); } }, "Preview"),
6125
- showPreview && (React.createElement("div", { className: styles.Preview },
6126
- React.createElement(TreeView, { value: previewValue }),
6127
- duration !== null && (React.createElement("div", { className: styles.Duration },
6128
- duration.toFixed(2),
6129
- " ms"))))));
6118
+ return (React.createElement(GenericNode, { inputs: inputs, id: id, data: data, selected: selected }));
6130
6119
  });
6131
- Merge.displayName = "MergeNode";
6120
+ DynamicInput.displayName = "DynamicInputNode";
6132
6121
 
6133
6122
  /**
6134
6123
  * todo: create a factory for output component
@@ -6228,11 +6217,28 @@ var OutputNode = React.memo(function (_a) {
6228
6217
  });
6229
6218
  OutputNode.displayName = "OutputNode";
6230
6219
 
6220
+ var DynamicOutput = React.memo(function (_a) {
6221
+ var id = _a.id, data = _a.data, selected = _a.selected;
6222
+ var _b = __read(React.useState({}), 2), outputs = _b[0], setOutputs = _b[1];
6223
+ var engine = useEngine();
6224
+ React.useEffect(function () {
6225
+ return engine.subscribe("functionResult", function (event) {
6226
+ if (event.name === id) {
6227
+ var result = event.result || {};
6228
+ setOutputs(Object.fromEntries(Object.keys(result).map(function (name, i) { return [name, "any"]; })));
6229
+ }
6230
+ });
6231
+ }, []);
6232
+ return (React.createElement(GenericNode, { outputs: outputs, id: id, data: data, selected: selected }));
6233
+ });
6234
+ DynamicOutput.displayName = "DynamicOutputNode";
6235
+
6231
6236
  var nodeTypes = {
6232
6237
  Default: Default,
6233
6238
  Calc: Calc,
6234
6239
  Log: Log,
6235
- Merge: Merge,
6240
+ DynamicInput: DynamicInput,
6241
+ DynamicOutput: DynamicOutput,
6236
6242
  Input: InputNode,
6237
6243
  Output: OutputNode,
6238
6244
  };
@@ -7707,5 +7713,5 @@ function DDContext(_a) {
7707
7713
  return React.createElement(DndProvider, { backend: HTML5Backend }, children);
7708
7714
  }
7709
7715
 
7710
- export { DDContext, DISCARD, Engine, Flow, Lib, binaryOnTree, binaryOnTreeBranch, broadCast, expandTree, forEachBranch, forEachItem, getBranch, getBranches, getItem, getPaths, getPositions, getReferences, getValue$1 as getValue, getVariable, graftTree, hasReference, interpolate, isEmptyTree, isReference, isSingleTon, isTree, mapTree, mapTreeBranch, nAryOnTree, nAryOnTreeBranch, normalizePaths, normalizeVarDef, parseReference, primitives, pushItem, sameShape, simplifyTree$1 as simplifyTree, toArray, topSort, treeSize, treeStats, trimTree, uid$1 as uid, useDraggableNode, useFlow, useFunction, usePositions, useUpdatePositions, useVariable, variableStore };
7716
+ export { DDContext, DISCARD, Engine, Flow, GenericNode, Lib, binaryOnTree, binaryOnTreeBranch, broadCast, expandTree, forEachBranch, forEachItem, getBranch, getBranches, getItem, getPaths, getPositions, getReferences, getValue$1 as getValue, getVariable, graftTree, hasReference, interpolate, isEmptyTree, isReference, isSingleTon, isTree, mapTree, mapTreeBranch, nAryOnTree, nAryOnTreeBranch, normalizePaths, normalizeVarDef, parseReference, primitives, pushItem, sameShape, simplifyTree$1 as simplifyTree, toArray, topSort, treeSize, treeStats, trimTree, uid$1 as uid, useDraggableNode, useFlow, useFunction, usePositions, useUpdatePositions, useVariable, variableStore };
7711
7717
  //# sourceMappingURL=index.esm.js.map