@rkmodules/rules 0.0.2 → 0.0.4
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.css +623 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +43 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/Flow/Nodes/Calc.d.ts +1 -1
- package/dist/lib/Flow/index.d.ts +1 -1
- package/package.json +6 -2
- package/readme.md +6 -6
- package/dist/app/editor/calcTestFunction.d.ts +0 -2
- package/dist/app/editor/page.d.ts +0 -2
- package/dist/app/finance/entriesTestFunction.d.ts +0 -2
- package/dist/app/finance/page.d.ts +0 -2
- package/dist/app/finance/testEntries.d.ts +0 -40
- package/dist/app/layout.d.ts +0 -9
- package/dist/app/page.d.ts +0 -2
- package/dist/app/supalipu/page.d.ts +0 -13
package/dist/index.js
CHANGED
|
@@ -8,7 +8,6 @@ var useInner = require('@rkmodules/use-inner');
|
|
|
8
8
|
var React = require('react');
|
|
9
9
|
var katex = require('katex');
|
|
10
10
|
var classNames = require('classnames');
|
|
11
|
-
require('@xyflow/react/dist/style.css');
|
|
12
11
|
|
|
13
12
|
/******************************************************************************
|
|
14
13
|
Copyright (c) Microsoft Corporation.
|
|
@@ -1545,8 +1544,8 @@ function FlowInner(_a) {
|
|
|
1545
1544
|
var _c = React.useMemo(function () {
|
|
1546
1545
|
return createGraph(fn, engine, positions);
|
|
1547
1546
|
}, [fn, engine]), initialNodes = _c.nodes, initialEdges = _c.edges;
|
|
1548
|
-
var _d = __read(useInner(initialNodes), 2), nodes = _d[0], setNodes = _d[1];
|
|
1549
|
-
var _e = __read(useInner(initialEdges), 2), edges = _e[0], setEdges = _e[1];
|
|
1547
|
+
var _d = __read(useInner.useInner(initialNodes), 2), nodes = _d[0], setNodes = _d[1];
|
|
1548
|
+
var _e = __read(useInner.useInner(initialEdges), 2), edges = _e[0], setEdges = _e[1];
|
|
1550
1549
|
// useLayoutNodes();
|
|
1551
1550
|
var updatePosition = function (event, node) {
|
|
1552
1551
|
var _a;
|
|
@@ -1615,6 +1614,46 @@ function Flow(_a) {
|
|
|
1615
1614
|
React.createElement(FlowInner, { function: fn, engine: engine, onChange: onChange })))));
|
|
1616
1615
|
}
|
|
1617
1616
|
|
|
1617
|
+
/**
|
|
1618
|
+
* using functions
|
|
1619
|
+
*
|
|
1620
|
+
* in React context
|
|
1621
|
+
* - use useFunction. This will build the function, mount it if needed and provides a run function.
|
|
1622
|
+
*
|
|
1623
|
+
*
|
|
1624
|
+
* in Vanilla context
|
|
1625
|
+
* - use engine.build(fn) to build the function
|
|
1626
|
+
* - use engine.mount(fn) to mount the function (if it has a mount function)
|
|
1627
|
+
* - use await engine.run(fn, inputs) to run the function and get the result
|
|
1628
|
+
*/
|
|
1629
|
+
function useFunction(engine, fn, mount) {
|
|
1630
|
+
var _this = this;
|
|
1631
|
+
var _a = __read(React.useState(null), 2), result = _a[0], setResult = _a[1];
|
|
1632
|
+
var builtFn = React.useMemo(function () { return engine.build(fn); }, [fn]);
|
|
1633
|
+
React.useEffect(function () {
|
|
1634
|
+
if (mount) {
|
|
1635
|
+
return engine.mount(builtFn);
|
|
1636
|
+
}
|
|
1637
|
+
}, [builtFn, mount]);
|
|
1638
|
+
var run = React.useCallback(function (inputs) { return __awaiter(_this, void 0, void 0, function () {
|
|
1639
|
+
var result;
|
|
1640
|
+
return __generator(this, function (_a) {
|
|
1641
|
+
switch (_a.label) {
|
|
1642
|
+
case 0: return [4 /*yield*/, engine.run(builtFn, inputs)];
|
|
1643
|
+
case 1:
|
|
1644
|
+
result = _a.sent();
|
|
1645
|
+
setResult(result);
|
|
1646
|
+
return [2 /*return*/, result];
|
|
1647
|
+
}
|
|
1648
|
+
});
|
|
1649
|
+
}); }, [builtFn]);
|
|
1650
|
+
return React.useMemo(function () { return ({
|
|
1651
|
+
fn: builtFn,
|
|
1652
|
+
run: run,
|
|
1653
|
+
result: result,
|
|
1654
|
+
}); }, [builtFn, run, result]);
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1618
1657
|
exports.Engine = Engine;
|
|
1619
1658
|
exports.Flow = Flow;
|
|
1620
1659
|
exports.applyEdgeDelete = applyEdgeDelete;
|
|
@@ -1631,4 +1670,5 @@ exports.parseReference = parseReference;
|
|
|
1631
1670
|
exports.primitives = primitives;
|
|
1632
1671
|
exports.topSort = topSort;
|
|
1633
1672
|
exports.uid = uid;
|
|
1673
|
+
exports.useFunction = useFunction;
|
|
1634
1674
|
//# sourceMappingURL=index.js.map
|