@rkmodules/rules 0.0.73 → 0.0.75

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
@@ -1781,7 +1781,10 @@ var Engine = /** @class */ (function () {
1781
1781
  return node;
1782
1782
  }
1783
1783
  var _a = node.body, body = _a === void 0 ? {} : _a, props = __rest(node, ["body"]);
1784
- var primitive = __assign(__assign({}, props), { outputs: {}, mount: function (trigger) {
1784
+ var primitive = __assign(__assign({}, props), { outputs: Object.fromEntries(Object.entries(node.outputs || {}).map(function (_a) {
1785
+ var _b = __read(_a, 2), key = _b[0]; _b[1];
1786
+ return [key, { type: "any" }];
1787
+ })), mount: function (trigger) {
1785
1788
  // mount all the nodes
1786
1789
  var unsubs = [];
1787
1790
  Object.values(body).forEach(function (n) {
@@ -4795,6 +4798,10 @@ var useControls = function () {
4795
4798
  var useGraphedFunction = function () {
4796
4799
  return React.useContext(FlowContext).graphedFn;
4797
4800
  };
4801
+ var usePrompts = function () {
4802
+ var prompts = React.useContext(FlowContext).prompts;
4803
+ return __assign({ confirm: confirm, prompt: prompt, alert: alert }, prompts);
4804
+ };
4798
4805
 
4799
4806
  var styles$1 = {"Port":"Port_XWl7K","required":"required_ofB6J","Icon":"Icon_YJDC5","PortLabel":"PortLabel_wwLN0","Input":"Input_PHp3D","Output":"Output_FMRNv","ConnectionPath":"ConnectionPath_XkXr1","valid":"valid_LGNvc","Edge":"Edge_aNtpH","Hover":"Hover_1v8QT","Menu":"Menu_cusza","MenuCanvas":"MenuCanvas_3M2Ek","MenuItem":"MenuItem_UWLzD"};
4800
4807
 
@@ -5129,33 +5136,50 @@ function MenuItem(_a) {
5129
5136
  var InputNode = React.memo(function (_a) {
5130
5137
  var id = _a.id, data = _a.data, selected = _a.selected;
5131
5138
  var fn = useGraphedFunction();
5139
+ var prompt = usePrompts().prompt;
5132
5140
  var outputs = Object.fromEntries(Object.keys(fn.inputs || {}).map(function (name) { return [
5133
5141
  name,
5134
5142
  normalizeVarDef(fn.inputs[name]),
5135
5143
  ]; }));
5136
- var onRename = function (id, oldLabel) {
5144
+ var onRename = function (id, oldLabel) { return __awaiter(void 0, void 0, void 0, function () {
5145
+ var label;
5137
5146
  var _a;
5138
- var label = prompt("Enter new name", oldLabel);
5139
- if (label !== null && label !== oldLabel) {
5140
- (_a = data.onIOChange) === null || _a === void 0 ? void 0 : _a.call(data, function (fn) {
5141
- var inputs = __assign({}, fn.inputs);
5142
- var n = normalizeVarDef(inputs[id]);
5143
- inputs[id] = __assign(__assign({}, n), { label: label });
5144
- return { inputs: inputs };
5145
- });
5146
- }
5147
- };
5148
- var onAdd = function () {
5147
+ return __generator(this, function (_b) {
5148
+ switch (_b.label) {
5149
+ case 0: return [4 /*yield*/, prompt("Enter new name", oldLabel)];
5150
+ case 1:
5151
+ label = _b.sent();
5152
+ if (label !== null && label !== oldLabel) {
5153
+ (_a = data.onIOChange) === null || _a === void 0 ? void 0 : _a.call(data, function (fn) {
5154
+ var inputs = __assign({}, fn.inputs);
5155
+ var n = normalizeVarDef(inputs[id]);
5156
+ inputs[id] = __assign(__assign({}, n), { label: label });
5157
+ return { inputs: inputs };
5158
+ });
5159
+ }
5160
+ return [2 /*return*/];
5161
+ }
5162
+ });
5163
+ }); };
5164
+ var onAdd = function () { return __awaiter(void 0, void 0, void 0, function () {
5165
+ var label;
5149
5166
  var _a;
5150
- var label = prompt("Enter new name");
5151
- if (label !== null) {
5152
- (_a = data.onIOChange) === null || _a === void 0 ? void 0 : _a.call(data, function (fn) {
5153
- var inputs = __assign({}, fn.inputs);
5154
- inputs[uid$1()] = { type: "any", label: label };
5155
- return { inputs: inputs };
5156
- });
5157
- }
5158
- };
5167
+ return __generator(this, function (_b) {
5168
+ switch (_b.label) {
5169
+ case 0: return [4 /*yield*/, prompt("Enter new name")];
5170
+ case 1:
5171
+ label = _b.sent();
5172
+ if (label !== null) {
5173
+ (_a = data.onIOChange) === null || _a === void 0 ? void 0 : _a.call(data, function (fn) {
5174
+ var inputs = __assign({}, fn.inputs);
5175
+ inputs[uid$1()] = { type: "any", label: label };
5176
+ return { inputs: inputs };
5177
+ });
5178
+ }
5179
+ return [2 /*return*/];
5180
+ }
5181
+ });
5182
+ }); };
5159
5183
  var onDelete = function (name) {
5160
5184
  var _a;
5161
5185
  (_a = data.onIOChange) === null || _a === void 0 ? void 0 : _a.call(data, function (fn) {
@@ -5164,36 +5188,52 @@ var InputNode = React.memo(function (_a) {
5164
5188
  return { inputs: inputs };
5165
5189
  });
5166
5190
  };
5167
- var onDefault = function (id) {
5191
+ var onDefault = function (id) { return __awaiter(void 0, void 0, void 0, function () {
5192
+ var value, n_1;
5168
5193
  var _a, _b;
5169
- var value = prompt("Enter default value");
5170
- if (value !== null && ((_a = fn.inputs) === null || _a === void 0 ? void 0 : _a[id])) {
5171
- var n_1 = normalizeVarDef(fn.inputs[id]);
5172
- if (n_1.type === "number") {
5173
- value = Number(value);
5174
- }
5175
- else if (n_1.type === "boolean") {
5176
- value = value.toLowerCase() === "true";
5194
+ return __generator(this, function (_c) {
5195
+ switch (_c.label) {
5196
+ case 0: return [4 /*yield*/, prompt("Enter default value")];
5197
+ case 1:
5198
+ value = _c.sent();
5199
+ if (value !== null && ((_a = fn.inputs) === null || _a === void 0 ? void 0 : _a[id])) {
5200
+ n_1 = normalizeVarDef(fn.inputs[id]);
5201
+ if (n_1.type === "number") {
5202
+ value = Number(value);
5203
+ }
5204
+ else if (n_1.type === "boolean") {
5205
+ value = value.toLowerCase() === "true";
5206
+ }
5207
+ (_b = data.onIOChange) === null || _b === void 0 ? void 0 : _b.call(data, function (fn) {
5208
+ var inputs = __assign({}, fn.inputs);
5209
+ inputs[id] = __assign(__assign({}, n_1), { default: value });
5210
+ return { inputs: inputs };
5211
+ });
5212
+ }
5213
+ return [2 /*return*/];
5177
5214
  }
5178
- (_b = data.onIOChange) === null || _b === void 0 ? void 0 : _b.call(data, function (fn) {
5179
- var inputs = __assign({}, fn.inputs);
5180
- inputs[id] = __assign(__assign({}, n_1), { default: value });
5181
- return { inputs: inputs };
5182
- });
5183
- }
5184
- };
5185
- var onType = function (id) {
5215
+ });
5216
+ }); };
5217
+ var onType = function (id) { return __awaiter(void 0, void 0, void 0, function () {
5218
+ var type, n_2;
5186
5219
  var _a, _b;
5187
- var type = prompt("Enter type");
5188
- if (type !== null && ((_a = fn.inputs) === null || _a === void 0 ? void 0 : _a[id])) {
5189
- var n_2 = normalizeVarDef(fn.inputs[id]);
5190
- (_b = data.onIOChange) === null || _b === void 0 ? void 0 : _b.call(data, function (fn) {
5191
- var inputs = __assign({}, fn.inputs);
5192
- inputs[id] = __assign(__assign({}, n_2), { type: type });
5193
- return { inputs: inputs };
5194
- });
5195
- }
5196
- };
5220
+ return __generator(this, function (_c) {
5221
+ switch (_c.label) {
5222
+ case 0: return [4 /*yield*/, prompt("Enter type")];
5223
+ case 1:
5224
+ type = _c.sent();
5225
+ if (type !== null && ((_a = fn.inputs) === null || _a === void 0 ? void 0 : _a[id])) {
5226
+ n_2 = normalizeVarDef(fn.inputs[id]);
5227
+ (_b = data.onIOChange) === null || _b === void 0 ? void 0 : _b.call(data, function (fn) {
5228
+ var inputs = __assign({}, fn.inputs);
5229
+ inputs[id] = __assign(__assign({}, n_2), { type: type });
5230
+ return { inputs: inputs };
5231
+ });
5232
+ }
5233
+ return [2 /*return*/];
5234
+ }
5235
+ });
5236
+ }); };
5197
5237
  return (React.createElement(NodeContainer, { label: data.label, selected: selected, id: id, noDelete: true },
5198
5238
  React.createElement("div", { className: styles.Description }, data.description),
5199
5239
  React.createElement("div", { className: styles.Ports },
@@ -5254,6 +5294,7 @@ var OutputNode = React.memo(function (_a) {
5254
5294
  var id = _a.id, data = _a.data, selected = _a.selected;
5255
5295
  var engine = useEngine();
5256
5296
  var fn = useGraphedFunction();
5297
+ var prompt = usePrompts().prompt;
5257
5298
  var inputs = Object.fromEntries(Object.entries(data.inputs || {}).map(function (_a, i) {
5258
5299
  var _b, _c;
5259
5300
  var _d = __read(_a, 2), name = _d[0], ref = _d[1];
@@ -5274,29 +5315,45 @@ var OutputNode = React.memo(function (_a) {
5274
5315
  }
5275
5316
  return [name, { type: type, label: name }];
5276
5317
  }));
5277
- var onRename = function (oldName) {
5318
+ var onRename = function (oldName) { return __awaiter(void 0, void 0, void 0, function () {
5319
+ var newName;
5278
5320
  var _a;
5279
- var newName = prompt("Enter new name", oldName);
5280
- if (newName !== null && newName !== oldName) {
5281
- (_a = data.onIOChange) === null || _a === void 0 ? void 0 : _a.call(data, function (fn) {
5282
- var outputs = __assign({}, fn.outputs);
5283
- outputs[newName] = outputs[oldName];
5284
- delete outputs[oldName];
5285
- return { outputs: outputs };
5286
- });
5287
- }
5288
- };
5289
- var onAdd = function () {
5321
+ return __generator(this, function (_b) {
5322
+ switch (_b.label) {
5323
+ case 0: return [4 /*yield*/, prompt("Enter new name", oldName)];
5324
+ case 1:
5325
+ newName = _b.sent();
5326
+ if (newName !== null && newName !== oldName) {
5327
+ (_a = data.onIOChange) === null || _a === void 0 ? void 0 : _a.call(data, function (fn) {
5328
+ var outputs = __assign({}, fn.outputs);
5329
+ outputs[newName] = outputs[oldName];
5330
+ delete outputs[oldName];
5331
+ return { outputs: outputs };
5332
+ });
5333
+ }
5334
+ return [2 /*return*/];
5335
+ }
5336
+ });
5337
+ }); };
5338
+ var onAdd = function () { return __awaiter(void 0, void 0, void 0, function () {
5339
+ var newName;
5290
5340
  var _a;
5291
- var newName = prompt("Enter new name");
5292
- if (newName !== null) {
5293
- (_a = data.onIOChange) === null || _a === void 0 ? void 0 : _a.call(data, function (fn) {
5294
- var outputs = __assign({}, fn.outputs);
5295
- outputs[newName] = "";
5296
- return { outputs: outputs };
5297
- });
5298
- }
5299
- };
5341
+ return __generator(this, function (_b) {
5342
+ switch (_b.label) {
5343
+ case 0: return [4 /*yield*/, prompt("Enter new name")];
5344
+ case 1:
5345
+ newName = _b.sent();
5346
+ if (newName !== null) {
5347
+ (_a = data.onIOChange) === null || _a === void 0 ? void 0 : _a.call(data, function (fn) {
5348
+ var outputs = __assign({}, fn.outputs);
5349
+ outputs[newName] = "";
5350
+ return { outputs: outputs };
5351
+ });
5352
+ }
5353
+ return [2 /*return*/];
5354
+ }
5355
+ });
5356
+ }); };
5300
5357
  var onDelete = function (name) {
5301
5358
  var _a;
5302
5359
  (_a = data.onIOChange) === null || _a === void 0 ? void 0 : _a.call(data, function (fn) {
@@ -5740,6 +5797,7 @@ function Flow(props) {
5740
5797
  engine: props.engine,
5741
5798
  controls: props.customControls,
5742
5799
  graphedFn: props.function,
5800
+ prompts: props.customPrompts,
5743
5801
  }); }, [props.engine, props.customControls, props.function]);
5744
5802
  return (React.createElement(FlowContext.Provider, { value: contextValue },
5745
5803
  React.createElement(ReactFlowProvider, null,