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