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