@rkmodules/rules 0.0.80 → 0.0.82

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
@@ -4,6 +4,7 @@ import { Handle, Position, useReactFlow, useConnection, getSimpleBezierPath, Rea
4
4
  import katex from 'katex';
5
5
  import classNames from 'classnames';
6
6
  import rcin from 'rc-input-number';
7
+ import useInner from '@rkmodules/use-inner';
7
8
  import { useLongPress } from 'use-long-press';
8
9
  import { create as create$1 } from 'zustand';
9
10
  import { persist } from 'zustand/middleware';
@@ -1713,12 +1714,14 @@ function topSort(fn) {
1713
1714
  return __assign(__assign({}, fn), { body: orderedBody });
1714
1715
  }
1715
1716
  var Engine = /** @class */ (function () {
1716
- function Engine(morePrimitives) {
1717
+ function Engine(morePrimitives, env) {
1717
1718
  if (morePrimitives === void 0) { morePrimitives = {}; }
1719
+ if (env === void 0) { env = {}; }
1718
1720
  this.listeners = {};
1719
1721
  this.cache = {};
1720
1722
  this.cacheMiss = Symbol("cacheMiss");
1721
1723
  this.fnIndex = __assign(__assign({}, primitives), morePrimitives);
1724
+ this.env = env;
1722
1725
  }
1723
1726
  Engine.prototype.checkCache = function (fnName, inputs) {
1724
1727
  if (!this.cache[fnName]) {
@@ -1788,7 +1791,7 @@ var Engine = /** @class */ (function () {
1788
1791
  context: context,
1789
1792
  startTime: startTime_1,
1790
1793
  });
1791
- return [4 /*yield*/, fn.impl(inputs_1, params_1)];
1794
+ return [4 /*yield*/, fn.impl(inputs_1, params_1, this)];
1792
1795
  case 3:
1793
1796
  result_1 = _e.sent();
1794
1797
  endTime_1 = performance.now();
@@ -1949,7 +1952,7 @@ var Engine = /** @class */ (function () {
1949
1952
  return [2 /*return*/, this.run(builtFn, inputs)];
1950
1953
  }
1951
1954
  mappedInputs = interpolate(inputs, {});
1952
- return [4 /*yield*/, ((_a = node.impl) === null || _a === void 0 ? void 0 : _a.call(node, mappedInputs, {}))];
1955
+ return [4 /*yield*/, ((_a = node.impl) === null || _a === void 0 ? void 0 : _a.call(node, mappedInputs, {}, this))];
1953
1956
  case 1:
1954
1957
  result = _b.sent();
1955
1958
  // console.log("Engine run complete", result);
@@ -4875,7 +4878,18 @@ var _a;
4875
4878
  var InputNumber = (_a = rcin.default) !== null && _a !== void 0 ? _a : rcin;
4876
4879
  var InputString = React.memo(function (_a) {
4877
4880
  var value = _a.value, onChange = _a.onChange;
4878
- return (React.createElement("input", { type: "text", value: value, onChange: function (e) { return onChange === null || onChange === void 0 ? void 0 : onChange(e.target.value); } }));
4881
+ var _b = __read(useInner(value), 2), inner = _b[0], setInner = _b[1];
4882
+ var handleBlur = React.useCallback(function () {
4883
+ if (inner !== value) {
4884
+ onChange === null || onChange === void 0 ? void 0 : onChange(inner);
4885
+ }
4886
+ }, [inner, value, onChange]);
4887
+ var handleKey = React.useCallback(function (e) {
4888
+ if (e.key === "Enter" && inner !== value) {
4889
+ onChange === null || onChange === void 0 ? void 0 : onChange(inner);
4890
+ }
4891
+ }, [inner, value, onChange]);
4892
+ return (React.createElement("input", { type: "text", value: inner, onChange: function (e) { return setInner(e.target.value); }, onBlur: handleBlur, onKeyDown: handleKey }));
4879
4893
  });
4880
4894
  function Control(_a) {
4881
4895
  var value = _a.value, vardef = _a.vardef, onChange = _a.onChange;