@rkmodules/rules 0.0.117 → 0.0.119
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 +150 -45
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +150 -46
- package/dist/index.esm.js.map +1 -1
- package/dist/lib/Flow/Nodes/DynamicInput.d.ts +4 -0
- package/dist/lib/Flow/Nodes/DynamicOutput.d.ts +4 -0
- package/dist/lib/Flow/Nodes/index.d.ts +2 -1
- package/dist/lib/Flow/index.d.ts +1 -0
- package/dist/lib/Primitives/Json/arrayToList.d.ts +2 -0
- package/dist/lib/Primitives/Json/explodeObject.d.ts +2 -0
- package/dist/lib/Primitives/List/uniqueItems.d.ts +2 -0
- package/package.json +1 -1
- package/dist/lib/Flow/Nodes/Merge.d.ts +0 -4
package/dist/index.esm.js
CHANGED
|
@@ -3,8 +3,8 @@ import React, { createContext, memo, useEffect, useLayoutEffect, useState, useCa
|
|
|
3
3
|
import { Handle, Position, useReactFlow, useConnection, getSimpleBezierPath, ReactFlowProvider, useOnSelectionChange, applyNodeChanges, applyEdgeChanges, ReactFlow, Background, BackgroundVariant, Controls } from '@xyflow/react';
|
|
4
4
|
import katex from 'katex';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
-
import rcin from 'rc-input-number';
|
|
7
6
|
import useInner from '@rkmodules/use-inner';
|
|
7
|
+
import rcin from 'rc-input-number';
|
|
8
8
|
import { useLongPress } from 'use-long-press';
|
|
9
9
|
import { create as create$1 } from 'zustand';
|
|
10
10
|
import { persist } from 'zustand/middleware';
|
|
@@ -1749,6 +1749,28 @@ var listInput = {
|
|
|
1749
1749
|
}); },
|
|
1750
1750
|
};
|
|
1751
1751
|
|
|
1752
|
+
var uniqueItems = {
|
|
1753
|
+
name: "uniqueItems",
|
|
1754
|
+
label: "Unique Items",
|
|
1755
|
+
description: "Removes duplicate items from a list",
|
|
1756
|
+
inputs: {
|
|
1757
|
+
items: "any",
|
|
1758
|
+
},
|
|
1759
|
+
outputs: {
|
|
1760
|
+
unique: "any",
|
|
1761
|
+
},
|
|
1762
|
+
impl: function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
1763
|
+
var _c = _b.items, items = _c === void 0 ? {} : _c;
|
|
1764
|
+
return __generator(this, function (_d) {
|
|
1765
|
+
return [2 /*return*/, {
|
|
1766
|
+
unique: mapTreeBranch(items, function (items) {
|
|
1767
|
+
return Array.from(new Set(items));
|
|
1768
|
+
}),
|
|
1769
|
+
}];
|
|
1770
|
+
});
|
|
1771
|
+
}); },
|
|
1772
|
+
};
|
|
1773
|
+
|
|
1752
1774
|
var _a$6;
|
|
1753
1775
|
var primitives$6 = (_a$6 = {},
|
|
1754
1776
|
_a$6[listInput.name] = listInput,
|
|
@@ -1758,6 +1780,7 @@ var primitives$6 = (_a$6 = {},
|
|
|
1758
1780
|
_a$6[relativeItem.name] = relativeItem,
|
|
1759
1781
|
_a$6[relativeItems.name] = relativeItems,
|
|
1760
1782
|
_a$6[concat.name] = concat,
|
|
1783
|
+
_a$6[uniqueItems.name] = uniqueItems,
|
|
1761
1784
|
_a$6);
|
|
1762
1785
|
|
|
1763
1786
|
var splitGroup = {
|
|
@@ -1847,7 +1870,7 @@ var mergeTree = {
|
|
|
1847
1870
|
name: "mergeTree",
|
|
1848
1871
|
label: "Merge Tree",
|
|
1849
1872
|
description: "Merge groups with the same index into a single tree.",
|
|
1850
|
-
nodeType: "
|
|
1873
|
+
nodeType: "DynamicInput",
|
|
1851
1874
|
inputs: {},
|
|
1852
1875
|
outputs: {
|
|
1853
1876
|
result: "any",
|
|
@@ -2214,7 +2237,7 @@ var mergeObject = {
|
|
|
2214
2237
|
name: "mergeObject",
|
|
2215
2238
|
label: "Merge Object",
|
|
2216
2239
|
description: "Merges objects in groups",
|
|
2217
|
-
nodeType: "
|
|
2240
|
+
nodeType: "DynamicInput",
|
|
2218
2241
|
inputs: {},
|
|
2219
2242
|
outputs: {
|
|
2220
2243
|
object: "any",
|
|
@@ -2287,11 +2310,112 @@ var listToArray = {
|
|
|
2287
2310
|
}); },
|
|
2288
2311
|
};
|
|
2289
2312
|
|
|
2313
|
+
var objectEntries = {
|
|
2314
|
+
name: "objectEntries",
|
|
2315
|
+
label: "Entries",
|
|
2316
|
+
description: "Gets keys and pairs of an object",
|
|
2317
|
+
inputs: {
|
|
2318
|
+
object: "any",
|
|
2319
|
+
},
|
|
2320
|
+
outputs: {
|
|
2321
|
+
keys: "string",
|
|
2322
|
+
values: "any",
|
|
2323
|
+
},
|
|
2324
|
+
impl: function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
2325
|
+
var keys, values;
|
|
2326
|
+
var _c = _b.object, object = _c === void 0 ? {} : _c;
|
|
2327
|
+
return __generator(this, function (_d) {
|
|
2328
|
+
keys = mapTree(object, function (obj) { return Object.keys(obj); });
|
|
2329
|
+
values = mapTree(object, function (obj) { return Object.values(obj); });
|
|
2330
|
+
return [2 /*return*/, {
|
|
2331
|
+
keys: keys,
|
|
2332
|
+
values: values,
|
|
2333
|
+
}];
|
|
2334
|
+
});
|
|
2335
|
+
}); },
|
|
2336
|
+
};
|
|
2337
|
+
|
|
2338
|
+
var arrayToList = {
|
|
2339
|
+
name: "arrayToList",
|
|
2340
|
+
label: "Array to List",
|
|
2341
|
+
description: "Separates array",
|
|
2342
|
+
inputs: {
|
|
2343
|
+
items: "any",
|
|
2344
|
+
},
|
|
2345
|
+
params: {
|
|
2346
|
+
split: { type: "boolean", default: false, label: "split groups" },
|
|
2347
|
+
},
|
|
2348
|
+
outputs: {
|
|
2349
|
+
arrays: "any",
|
|
2350
|
+
},
|
|
2351
|
+
impl: function (_a, params_1) { return __awaiter(void 0, [_a, params_1], void 0, function (_b, params) {
|
|
2352
|
+
var _c = _b.items, items = _c === void 0 ? {} : _c;
|
|
2353
|
+
return __generator(this, function (_d) {
|
|
2354
|
+
if (params.split) {
|
|
2355
|
+
items = graftTree(items);
|
|
2356
|
+
}
|
|
2357
|
+
return [2 /*return*/, {
|
|
2358
|
+
arrays: mapTreeBranch(items, function (items) {
|
|
2359
|
+
return items.flat();
|
|
2360
|
+
}),
|
|
2361
|
+
}];
|
|
2362
|
+
});
|
|
2363
|
+
}); },
|
|
2364
|
+
};
|
|
2365
|
+
|
|
2366
|
+
var explodeObject = {
|
|
2367
|
+
name: "explodeObject",
|
|
2368
|
+
label: "Explode Object",
|
|
2369
|
+
description: "Separates all fields of an object",
|
|
2370
|
+
nodeType: "DynamicOutput",
|
|
2371
|
+
inputs: {
|
|
2372
|
+
object: "any",
|
|
2373
|
+
},
|
|
2374
|
+
params: {
|
|
2375
|
+
split: { type: "boolean", default: false, label: "split groups" },
|
|
2376
|
+
},
|
|
2377
|
+
outputs: {
|
|
2378
|
+
// values: "any",
|
|
2379
|
+
},
|
|
2380
|
+
impl: function (_a, params_1) { return __awaiter(void 0, [_a, params_1], void 0, function (_b, params) {
|
|
2381
|
+
var outputs;
|
|
2382
|
+
var _c = _b.object, object = _c === void 0 ? {} : _c;
|
|
2383
|
+
return __generator(this, function (_d) {
|
|
2384
|
+
outputs = {};
|
|
2385
|
+
if (params.split) {
|
|
2386
|
+
object = graftTree(object);
|
|
2387
|
+
}
|
|
2388
|
+
forEachBranch(object, function (branch, path) {
|
|
2389
|
+
branch.forEach(function (obj, index) {
|
|
2390
|
+
if (!obj)
|
|
2391
|
+
return;
|
|
2392
|
+
var props = obj || {};
|
|
2393
|
+
Object.entries(props).forEach(function (_a) {
|
|
2394
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
2395
|
+
if (key[0] === "_")
|
|
2396
|
+
return;
|
|
2397
|
+
if (!outputs[key]) {
|
|
2398
|
+
outputs[key] = {};
|
|
2399
|
+
}
|
|
2400
|
+
[].concat(value).forEach(function (v) {
|
|
2401
|
+
pushItem(outputs[key], path, v);
|
|
2402
|
+
});
|
|
2403
|
+
});
|
|
2404
|
+
});
|
|
2405
|
+
});
|
|
2406
|
+
return [2 /*return*/, outputs];
|
|
2407
|
+
});
|
|
2408
|
+
}); },
|
|
2409
|
+
};
|
|
2410
|
+
|
|
2290
2411
|
var _a$1;
|
|
2291
2412
|
var primitives$1 = (_a$1 = {},
|
|
2292
2413
|
_a$1[object.name] = object,
|
|
2293
2414
|
_a$1[listToArray.name] = listToArray,
|
|
2415
|
+
_a$1[arrayToList.name] = arrayToList,
|
|
2294
2416
|
_a$1[mergeObject.name] = mergeObject,
|
|
2417
|
+
_a$1[objectEntries.name] = objectEntries,
|
|
2418
|
+
_a$1[explodeObject.name] = explodeObject,
|
|
2295
2419
|
_a$1);
|
|
2296
2420
|
|
|
2297
2421
|
var Lib = {
|
|
@@ -5855,7 +5979,7 @@ function GenericNode(_a) {
|
|
|
5855
5979
|
var engine = useEngine();
|
|
5856
5980
|
var _d = __read(React.useState({}), 2), result = _d[0], setResult = _d[1];
|
|
5857
5981
|
var _e = __read(React.useState(null), 2), duration = _e[0], setDuration = _e[1];
|
|
5858
|
-
var _f = __read(
|
|
5982
|
+
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];
|
|
5859
5983
|
var _g = __read(React.useState(false), 2), showPreview = _g[0], setShowPreview = _g[1];
|
|
5860
5984
|
var previewValue = focus ? result[focus] : Object.values(result)[0];
|
|
5861
5985
|
React.useEffect(function () {
|
|
@@ -6081,54 +6205,17 @@ InputNode.displayName = "InputNode";
|
|
|
6081
6205
|
function uid() {
|
|
6082
6206
|
return Math.random().toString(36).substring(2, 15);
|
|
6083
6207
|
}
|
|
6084
|
-
var
|
|
6085
|
-
var _b;
|
|
6086
|
-
var _c;
|
|
6208
|
+
var DynamicInput = React.memo(function (_a) {
|
|
6087
6209
|
var id = _a.id, data = _a.data, selected = _a.selected;
|
|
6088
|
-
var outputEntries = Object.entries(data.outputDefs || {});
|
|
6089
|
-
var focus = (_c = outputEntries[0]) === null || _c === void 0 ? void 0 : _c[0];
|
|
6090
|
-
var _d = __read(React.useState(false), 2), showPreview = _d[0], setShowPreview = _d[1];
|
|
6091
|
-
var engine = useEngine();
|
|
6092
|
-
var _e = __read(React.useState({}), 2), result = _e[0], setResult = _e[1];
|
|
6093
|
-
var _f = __read(React.useState(null), 2), duration = _f[0], setDuration = _f[1];
|
|
6094
|
-
var previewValue = focus ? result[focus] : Object.values(result)[0];
|
|
6095
|
-
React.useEffect(function () {
|
|
6096
|
-
return engine.subscribe("functionResult", function (event) {
|
|
6097
|
-
var _a;
|
|
6098
|
-
if (event.name === id) {
|
|
6099
|
-
setResult(event.result || {});
|
|
6100
|
-
setDuration((_a = event.duration) !== null && _a !== void 0 ? _a : null);
|
|
6101
|
-
}
|
|
6102
|
-
});
|
|
6103
|
-
}, []);
|
|
6104
6210
|
var inputs = Object.fromEntries(Object.keys(data.inputs || {}).map(function (name, i) { return [
|
|
6105
6211
|
name,
|
|
6106
6212
|
{ type: "any", label: "D".concat(i + 1) },
|
|
6107
6213
|
]; }));
|
|
6108
6214
|
var inputCount = Object.keys(inputs).length;
|
|
6109
6215
|
inputs[uid()] = { type: "any", label: "D".concat(inputCount + 1) };
|
|
6110
|
-
|
|
6111
|
-
return (React.createElement(NodeContainer, { label: data.label, selected: selected, id: id },
|
|
6112
|
-
React.createElement("div", { className: styles.Description }, data.description),
|
|
6113
|
-
React.createElement("div", { className: styles.Ports },
|
|
6114
|
-
Object.entries(outputs || {}).map(function (_a) {
|
|
6115
|
-
var _b = __read(_a, 2), name = _b[0], varDef = _b[1];
|
|
6116
|
-
return (React.createElement(Output, { key: name, name: name, varDef: varDef, id: id }));
|
|
6117
|
-
}),
|
|
6118
|
-
Object.entries(inputs || {}).map(function (_a) {
|
|
6119
|
-
var _b = __read(_a, 2), name = _b[0], varDef = _b[1];
|
|
6120
|
-
return (React.createElement(Input, { key: name, name: name, varDef: varDef, id: id, data: data }));
|
|
6121
|
-
})),
|
|
6122
|
-
React.createElement("div", { className: classNames(styles.PreviewHead, (_b = {},
|
|
6123
|
-
_b[styles.expanded] = showPreview,
|
|
6124
|
-
_b)), onClick: function () { return setShowPreview(!showPreview); } }, "Preview"),
|
|
6125
|
-
showPreview && (React.createElement("div", { className: styles.Preview },
|
|
6126
|
-
React.createElement(TreeView, { value: previewValue }),
|
|
6127
|
-
duration !== null && (React.createElement("div", { className: styles.Duration },
|
|
6128
|
-
duration.toFixed(2),
|
|
6129
|
-
" ms"))))));
|
|
6216
|
+
return (React.createElement(GenericNode, { inputs: inputs, id: id, data: data, selected: selected }));
|
|
6130
6217
|
});
|
|
6131
|
-
|
|
6218
|
+
DynamicInput.displayName = "DynamicInputNode";
|
|
6132
6219
|
|
|
6133
6220
|
/**
|
|
6134
6221
|
* todo: create a factory for output component
|
|
@@ -6228,11 +6315,28 @@ var OutputNode = React.memo(function (_a) {
|
|
|
6228
6315
|
});
|
|
6229
6316
|
OutputNode.displayName = "OutputNode";
|
|
6230
6317
|
|
|
6318
|
+
var DynamicOutput = React.memo(function (_a) {
|
|
6319
|
+
var id = _a.id, data = _a.data, selected = _a.selected;
|
|
6320
|
+
var _b = __read(React.useState({}), 2), outputs = _b[0], setOutputs = _b[1];
|
|
6321
|
+
var engine = useEngine();
|
|
6322
|
+
React.useEffect(function () {
|
|
6323
|
+
return engine.subscribe("functionResult", function (event) {
|
|
6324
|
+
if (event.name === id) {
|
|
6325
|
+
var result = event.result || {};
|
|
6326
|
+
setOutputs(Object.fromEntries(Object.keys(result).map(function (name, i) { return [name, "any"]; })));
|
|
6327
|
+
}
|
|
6328
|
+
});
|
|
6329
|
+
}, []);
|
|
6330
|
+
return (React.createElement(GenericNode, { outputs: outputs, id: id, data: data, selected: selected }));
|
|
6331
|
+
});
|
|
6332
|
+
DynamicOutput.displayName = "DynamicOutputNode";
|
|
6333
|
+
|
|
6231
6334
|
var nodeTypes = {
|
|
6232
6335
|
Default: Default,
|
|
6233
6336
|
Calc: Calc,
|
|
6234
6337
|
Log: Log,
|
|
6235
|
-
|
|
6338
|
+
DynamicInput: DynamicInput,
|
|
6339
|
+
DynamicOutput: DynamicOutput,
|
|
6236
6340
|
Input: InputNode,
|
|
6237
6341
|
Output: OutputNode,
|
|
6238
6342
|
};
|
|
@@ -7707,5 +7811,5 @@ function DDContext(_a) {
|
|
|
7707
7811
|
return React.createElement(DndProvider, { backend: HTML5Backend }, children);
|
|
7708
7812
|
}
|
|
7709
7813
|
|
|
7710
|
-
export { DDContext, DISCARD, Engine, Flow, Lib, binaryOnTree, binaryOnTreeBranch, broadCast, expandTree, forEachBranch, forEachItem, getBranch, getBranches, getItem, getPaths, getPositions, getReferences, getValue$1 as getValue, getVariable, graftTree, hasReference, interpolate, isEmptyTree, isReference, isSingleTon, isTree, mapTree, mapTreeBranch, nAryOnTree, nAryOnTreeBranch, normalizePaths, normalizeVarDef, parseReference, primitives, pushItem, sameShape, simplifyTree$1 as simplifyTree, toArray, topSort, treeSize, treeStats, trimTree, uid$1 as uid, useDraggableNode, useFlow, useFunction, usePositions, useUpdatePositions, useVariable, variableStore };
|
|
7814
|
+
export { DDContext, DISCARD, Engine, Flow, GenericNode, Lib, binaryOnTree, binaryOnTreeBranch, broadCast, expandTree, forEachBranch, forEachItem, getBranch, getBranches, getItem, getPaths, getPositions, getReferences, getValue$1 as getValue, getVariable, graftTree, hasReference, interpolate, isEmptyTree, isReference, isSingleTon, isTree, mapTree, mapTreeBranch, nAryOnTree, nAryOnTreeBranch, normalizePaths, normalizeVarDef, parseReference, primitives, pushItem, sameShape, simplifyTree$1 as simplifyTree, toArray, topSort, treeSize, treeStats, trimTree, uid$1 as uid, useDraggableNode, useFlow, useFunction, usePositions, useUpdatePositions, useVariable, variableStore };
|
|
7711
7815
|
//# sourceMappingURL=index.esm.js.map
|