@rkmodules/rules 0.0.77 → 0.0.78

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
@@ -562,11 +562,9 @@ var getValue = {
562
562
  var paths, tree;
563
563
  return __generator(this, function (_a) {
564
564
  paths = toArray(inputs.path || {});
565
- tree = mapTree(inputs.tree, function (value) {
565
+ tree = mapTree(inputs.tree || {}, function (value) {
566
566
  // get the property from the object
567
567
  var val = getValue$1(value, paths[0]);
568
- if (val === undefined)
569
- return DISCARD;
570
568
  return val;
571
569
  });
572
570
  return [2 /*return*/, { tree: tree }];
@@ -1229,11 +1227,24 @@ var listItem = {
1229
1227
  return __generator(this, function (_a) {
1230
1228
  item = binaryOnTreeBranch(inputs.list || {}, inputs.index || {}, function (branch, indices) {
1231
1229
  if (indices) {
1232
- return indices.map(function (i) { return branch[i]; });
1230
+ var n_1 = branch.length;
1231
+ return indices.map(function (i) {
1232
+ i = i % n_1;
1233
+ if (i < 0)
1234
+ i += n_1;
1235
+ return branch[i];
1236
+ });
1233
1237
  }
1234
1238
  return DISCARD;
1235
1239
  });
1236
1240
  others = binaryOnTreeBranch(inputs.list || {}, inputs.index || {}, function (branch, indices) {
1241
+ var n = branch.length;
1242
+ indices = indices.map(function (i) {
1243
+ i = i % n;
1244
+ if (i < 0)
1245
+ i += n;
1246
+ return i;
1247
+ });
1237
1248
  return branch.filter(function (_, i) { return !(indices === null || indices === void 0 ? void 0 : indices.includes(i)); });
1238
1249
  });
1239
1250
  return [2 /*return*/, {
@@ -5313,7 +5324,26 @@ function uid() {
5313
5324
  return Math.random().toString(36).substring(2, 15);
5314
5325
  }
5315
5326
  var Merge = React.memo(function (_a) {
5327
+ var _b;
5328
+ var _c;
5316
5329
  var id = _a.id, data = _a.data, selected = _a.selected;
5330
+ var outputEntries = Object.entries(data.outputDefs || {});
5331
+ var focus = (_c = outputEntries[0]) === null || _c === void 0 ? void 0 : _c[0];
5332
+ var _d = __read(React.useState(false), 2), showPreview = _d[0], setShowPreview = _d[1];
5333
+ var engine = useEngine();
5334
+ var _e = __read(React.useState({}), 2), result = _e[0], setResult = _e[1];
5335
+ var _f = __read(React.useState(null), 2), duration = _f[0], setDuration = _f[1];
5336
+ var previewValue = focus ? result[focus] : Object.values(result)[0];
5337
+ React.useEffect(function () {
5338
+ return engine.subscribe("functionResult", function (event) {
5339
+ var _a;
5340
+ console.log("functionresult", event.name, event);
5341
+ if (event.name === id) {
5342
+ setResult(event.result || {});
5343
+ setDuration((_a = event.duration) !== null && _a !== void 0 ? _a : null);
5344
+ }
5345
+ });
5346
+ }, []);
5317
5347
  var inputs = Object.fromEntries(Object.keys(data.inputs || {}).map(function (name, i) { return [
5318
5348
  name,
5319
5349
  { type: "any", label: "D".concat(i + 1) },
@@ -5331,7 +5361,15 @@ var Merge = React.memo(function (_a) {
5331
5361
  Object.entries(inputs || {}).map(function (_a) {
5332
5362
  var _b = __read(_a, 2), name = _b[0], varDef = _b[1];
5333
5363
  return (React.createElement(Input, { key: name, name: name, varDef: varDef, id: id, data: data }));
5334
- }))));
5364
+ })),
5365
+ React.createElement("div", { className: classNames(styles.PreviewHead, (_b = {},
5366
+ _b[styles.expanded] = showPreview,
5367
+ _b)), onClick: function () { return setShowPreview(!showPreview); } }, "Preview"),
5368
+ showPreview && (React.createElement("div", { className: styles.Preview },
5369
+ React.createElement(TreeView, { value: previewValue }),
5370
+ duration !== null && (React.createElement("div", { className: styles.Duration },
5371
+ duration.toFixed(2),
5372
+ " ms"))))));
5335
5373
  });
5336
5374
  Merge.displayName = "MergeNode";
5337
5375