@rkmodules/rules 0.0.168 → 0.0.170

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.
@@ -1,7 +1,7 @@
1
1
  import { create, all } from 'mathjs';
2
2
  import { interpolate as interpolate$1 } from '@rkmodules/stringtemplate';
3
3
  import React, { createContext, memo, useEffect, useLayoutEffect, useState, useCallback, useMemo, isValidElement, cloneElement, useContext } from 'react';
4
- import { Handle, Position, useReactFlow, BezierEdge, useConnection, getSimpleBezierPath, ReactFlowProvider, useOnSelectionChange, applyNodeChanges, applyEdgeChanges, ReactFlow, Background, BackgroundVariant, Controls } from '@xyflow/react';
4
+ import { Handle, Position, useReactFlow, useUpdateNodeInternals, BezierEdge, useConnection, getSimpleBezierPath, ReactFlowProvider, useOnSelectionChange, applyNodeChanges, applyEdgeChanges, ReactFlow, Background, BackgroundVariant, Controls } from '@xyflow/react';
5
5
  import katex from 'katex';
6
6
  import classNames from 'classnames';
7
7
  import { useInner } from '@rkmodules/use-inner';
@@ -2620,8 +2620,16 @@ var objectEntries = {
2620
2620
  var keys, values;
2621
2621
  var _c = _b.object, object = _c === void 0 ? {} : _c;
2622
2622
  return __generator(this, function (_d) {
2623
- keys = mapTree(object, function (obj) { return Object.keys(obj); });
2624
- values = mapTree(object, function (obj) { return Object.values(obj); });
2623
+ keys = mapTree(object, function (obj) {
2624
+ if (!obj)
2625
+ return DISCARD;
2626
+ return Object.keys(obj);
2627
+ });
2628
+ values = mapTree(object, function (obj) {
2629
+ if (!obj)
2630
+ return DISCARD;
2631
+ return Object.values(obj);
2632
+ });
2625
2633
  return [2 /*return*/, {
2626
2634
  keys: keys,
2627
2635
  values: values,
@@ -6728,16 +6736,16 @@ Log.displayName = "LogNode";
6728
6736
 
6729
6737
  function GenericNode(_a) {
6730
6738
  var _b;
6731
- var _c;
6739
+ var _c, _d;
6732
6740
  var id = _a.id, data = _a.data, selected = _a.selected, inputs = _a.inputs, outputs = _a.outputs, params = _a.params, children = _a.children;
6733
6741
  var inputEntries = Object.entries(inputs || data.inputDefs || {});
6734
6742
  var outputEntries = Object.entries(outputs || data.outputDefs || {});
6735
6743
  var paramEntries = Object.entries(params || data.paramDefs || {});
6736
6744
  var engine = useEngine();
6737
- var _d = __read(React.useState({}), 2), result = _d[0], setResult = _d[1];
6738
- var _e = __read(React.useState(null), 2), duration = _e[0], setDuration = _e[1];
6739
- var _f = __read(useInner(((_c = outputEntries[0]) === null || _c === void 0 ? void 0 : _c[0]) || null, [outputs, data.outputDefs]), 2), focus = _f[0], setFocus = _f[1];
6740
- var _g = __read(React.useState(false), 2), showPreview = _g[0], setShowPreview = _g[1];
6745
+ var _e = __read(React.useState({}), 2), result = _e[0], setResult = _e[1];
6746
+ var _f = __read(React.useState(null), 2), duration = _f[0], setDuration = _f[1];
6747
+ var _g = __read(useInner(((_c = outputEntries[0]) === null || _c === void 0 ? void 0 : _c[0]) || null, [outputs, data.outputDefs]), 2), focus = _g[0], setFocus = _g[1];
6748
+ var _h = __read(React.useState(false), 2), showPreview = _h[0], setShowPreview = _h[1];
6741
6749
  var previewValue = focus ? result[focus] : Object.values(result)[0];
6742
6750
  React.useEffect(function () {
6743
6751
  return engine.subscribe("functionResult", function (event) {
@@ -6748,7 +6756,7 @@ function GenericNode(_a) {
6748
6756
  }
6749
6757
  });
6750
6758
  }, []);
6751
- return (React.createElement(NodeContainer, { label: data.label, selected: selected, id: id },
6759
+ return (React.createElement(NodeContainer, { label: data.label, selected: selected, id: id, className: (_d = data.nodeProps) === null || _d === void 0 ? void 0 : _d.className },
6752
6760
  React.createElement("div", { className: styles$1.Description }, data.description),
6753
6761
  children,
6754
6762
  React.createElement("div", { className: styles$1.Ports },
@@ -7107,6 +7115,7 @@ OutputNode.displayName = "OutputNode";
7107
7115
 
7108
7116
  var DynamicOutput = React.memo(function (_a) {
7109
7117
  var id = _a.id, data = _a.data, selected = _a.selected;
7118
+ var updateNodeInternals = useUpdateNodeInternals();
7110
7119
  var outputDefs = React.useMemo(function () {
7111
7120
  var outputDefs = __assign({}, (data.outputDefs || {}));
7112
7121
  Object.keys(data.outputs || {}).forEach(function (key) {
@@ -7126,6 +7135,7 @@ var DynamicOutput = React.memo(function (_a) {
7126
7135
  name,
7127
7136
  { type: "any", label: name },
7128
7137
  ]; })), outputDefs));
7138
+ updateNodeInternals(id);
7129
7139
  }
7130
7140
  });
7131
7141
  }, [outputDefs]);
@@ -7279,29 +7289,8 @@ var styles = {
7279
7289
  },
7280
7290
  };
7281
7291
  var Default = React.memo(function (_a) {
7282
- var _b, _c;
7283
7292
  var props = __rest(_a, []);
7284
7293
  var data = useNodeResult(props.source);
7285
- var flow = useReactFlow();
7286
- var src = flow.getInternalNode(props.source);
7287
- if ((src === null || src === void 0 ? void 0 : src.type) === "DynamicOutput") {
7288
- /**
7289
- * fix for dynamic output nodes. As connection order can change,
7290
- * the position of the handles is not updated internally with react-flow
7291
- * so we need to get the position of the handle and update the
7292
- * source position manually.
7293
- */
7294
- var el = document.querySelector("[data-handleid=\"".concat(props.sourceHandleId, "\"]"));
7295
- var bbox = el === null || el === void 0 ? void 0 : el.getBoundingClientRect();
7296
- if (bbox) {
7297
- var pos = flow.screenToFlowPosition({
7298
- x: (bbox === null || bbox === void 0 ? void 0 : bbox.x) + (bbox === null || bbox === void 0 ? void 0 : bbox.width),
7299
- y: (bbox === null || bbox === void 0 ? void 0 : bbox.y) + (bbox === null || bbox === void 0 ? void 0 : bbox.height) / 2,
7300
- });
7301
- props.sourceX = (_b = pos === null || pos === void 0 ? void 0 : pos.x) !== null && _b !== void 0 ? _b : props.sourceX;
7302
- props.sourceY = (_c = pos === null || pos === void 0 ? void 0 : pos.y) !== null && _c !== void 0 ? _c : props.sourceY;
7303
- }
7304
- }
7305
7294
  if (props.sourceHandleId) {
7306
7295
  var field = deRefEdgeHandle(props.sourceHandleId).field;
7307
7296
  var value = data[field];