x-block-lib 0.8.44 → 0.8.46

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.
@@ -1,15 +1,10 @@
1
1
  import * as Blockly from 'blockly/core';
2
- import { EventKind, Type } from 'x-runtime-lib';
3
- interface Param {
4
- key: string;
5
- name: string;
6
- type: Type;
7
- }
2
+ import { EventKind, ZField } from 'x-runtime-lib';
8
3
  interface EventInfo {
9
4
  id: string;
10
5
  kind: EventKind;
11
6
  names: string[];
12
- params: Param[];
7
+ params?: ZField[];
13
8
  }
14
9
  export declare function getAllOnEventInfos(nodeId: string): EventInfo[];
15
10
  export declare function getOnEventInfo(id: string): EventInfo | undefined;
@@ -1,21 +1,11 @@
1
1
  import * as Blockly from 'blockly/core';
2
- import { MethodKind, Type } from 'x-runtime-lib';
3
- interface Input {
4
- key: string;
5
- name: string;
6
- type: Type;
7
- }
8
- interface Output {
9
- key: string;
10
- name: string;
11
- type: Type;
12
- }
2
+ import { MethodKind, ZField } from 'x-runtime-lib';
13
3
  interface MethodInfo {
14
4
  id: string;
15
5
  kind: MethodKind;
16
6
  names: string[];
17
- inputs: Input[];
18
- outputs: Output[];
7
+ inputs?: ZField[];
8
+ outputs?: ZField[];
19
9
  }
20
10
  export declare function getAllCallMethodInfos(nodeId: string): MethodInfo[];
21
11
  export declare function getCallMethodInfo(id: string): MethodInfo | undefined;
@@ -23,7 +13,7 @@ export declare function genCallMethodOpts(nodeId: string): Blockly.MenuOption[];
23
13
  export declare function getAllImplementMethodInfos(): MethodInfo[];
24
14
  export declare function getImplementMethodInfo(id: string): MethodInfo | undefined;
25
15
  export declare function genImplementMethodOpts(): Blockly.MenuOption[];
26
- export declare function getAllImplementMethodOutputInfos(methodId: string): Output[];
27
- export declare function getImplementMethodOutputInfo(methodId: string, outputKey: string): Output | undefined;
16
+ export declare function getAllImplementMethodOutputInfos(methodId: string): ZField[] | undefined;
17
+ export declare function getImplementMethodOutputInfo(methodId: string, outputKey: string): ZField | undefined;
28
18
  export declare function genImplementMethodOutputOpts(methodKey: string): Blockly.MenuOption[];
29
19
  export {};
package/dist/index.js CHANGED
@@ -577,13 +577,14 @@ function Qe(t) {
577
577
  const _ = et[l.key];
578
578
  if (!_)
579
579
  return console.assert(!1, "invalid element", l.key), c;
580
- for (const { key: p, name: h, params: d } of _.events)
581
- c.push({
582
- id: Z("elementEvent", t, p),
583
- kind: "elementEvent",
584
- names: [h],
585
- params: d
586
- });
580
+ if (_.events)
581
+ for (const { key: p, name: h, params: d } of _.events)
582
+ c.push({
583
+ id: Z("elementEvent", t, p),
584
+ kind: "elementEvent",
585
+ names: [h],
586
+ params: d
587
+ });
587
588
  if (J(_.key) && l.reference && l.reference.comp) {
588
589
  const p = a[l.reference.comp];
589
590
  if (p)
@@ -687,7 +688,7 @@ function Fe(t) {
687
688
  return;
688
689
  }
689
690
  if (r === "elementEvent") {
690
- const d = h.events.find((m) => m.key === _);
691
+ const d = h.events?.find((m) => m.key === _);
691
692
  if (d)
692
693
  return {
693
694
  id: t,
@@ -878,14 +879,15 @@ function ze(t) {
878
879
  const c = et[a.key];
879
880
  if (!c)
880
881
  return console.assert(!1, "inavlid element", a.key), i;
881
- for (const { key: r, name: l, inputs: _, outputs: p } of c.methods)
882
- i.push({
883
- id: Yt("elementMethod", t, r),
884
- kind: "elementMethod",
885
- names: [l],
886
- inputs: _,
887
- outputs: p
888
- });
882
+ if (c.methods)
883
+ for (const { key: r, name: l, inputs: _, outputs: p } of c.methods)
884
+ i.push({
885
+ id: Yt("elementMethod", t, r),
886
+ kind: "elementMethod",
887
+ names: [l],
888
+ inputs: _,
889
+ outputs: p
890
+ });
889
891
  if (J(c.key) && a.reference && a.reference.comp) {
890
892
  const r = o[a.reference.comp];
891
893
  if (r)
@@ -933,7 +935,7 @@ function we(t) {
933
935
  return;
934
936
  }
935
937
  if (i === "elementMethod") {
936
- const _ = l.methods.find((p) => p.key === c);
938
+ const _ = l.methods?.find((p) => p.key === c);
937
939
  if (_)
938
940
  return {
939
941
  id: t,
@@ -1040,17 +1042,18 @@ function Ze(t) {
1040
1042
  function Ke(t, e) {
1041
1043
  const n = Dt(t);
1042
1044
  if (n)
1043
- return n.outputs.find((o) => o.key === e);
1045
+ return n.outputs?.find((o) => o.key === e);
1044
1046
  }
1045
1047
  function Bi(t) {
1046
1048
  const e = [], n = Ze(t);
1047
- for (const { name: o, key: i } of n)
1048
- e.push([o, i]);
1049
+ if (n)
1050
+ for (const { name: o, key: i } of n)
1051
+ e.push([o, i]);
1049
1052
  return k(e);
1050
1053
  }
1051
1054
  function bi(t, e, n) {
1052
1055
  const { properties: o } = g.runtime, { activeObject: i, activePage: a, activeComp: c, depends: r } = g.app;
1053
- if (t.events.length > 0)
1056
+ if (t.events && t.events.length > 0)
1054
1057
  return !1;
1055
1058
  if (J(t.key) && n) {
1056
1059
  const l = r[n];
@@ -1092,7 +1095,7 @@ function bi(t, e, n) {
1092
1095
  }
1093
1096
  function Pi(t, e) {
1094
1097
  const { activeObject: n, activeComp: o, depends: i } = g.app;
1095
- if (t.methods.length > 0)
1098
+ if (t.methods && t.methods.length > 0)
1096
1099
  return !1;
1097
1100
  if (J(t.key) && e) {
1098
1101
  const a = i[e];
@@ -1374,8 +1377,7 @@ const Mi = {
1374
1377
  }, this.event = {
1375
1378
  id: "",
1376
1379
  kind: "",
1377
- names: [],
1378
- params: []
1380
+ names: []
1379
1381
  }, this.appendDummyInput().appendField("%{BKY_APP_V1_ON_APP_EVENT_TITLE}").appendField(new O(() => this.genNodeOpts_()), "NODE").appendField(
1380
1382
  new O(() => this.genEventOpts_()),
1381
1383
  "EVENT"
@@ -1404,7 +1406,7 @@ const Mi = {
1404
1406
  };
1405
1407
  },
1406
1408
  loadExtraState: function(t) {
1407
- this.node.id = t.node?.id ?? "", this.node.key = t.node?.key ?? "", this.node.alias = t.node?.alias ?? "", this.event.id = t.event?.id ?? "", this.event.kind = t.event?.kind ?? "", this.event.names = t.event?.names ?? [], this.event.params = t.event?.params ?? [], this.updateShape_(), setTimeout(() => {
1409
+ this.node.id = t.node?.id ?? "", this.node.key = t.node?.key ?? "", this.node.alias = t.node?.alias ?? "", this.event.id = t.event?.id ?? "", this.event.kind = t.event?.kind ?? "", this.event.names = t.event?.names ?? [], this.event.params = t.event?.params, this.updateShape_(), setTimeout(() => {
1408
1410
  this.ensureBlocks_(), this.checkWarning_();
1409
1411
  }, 0);
1410
1412
  },
@@ -1441,20 +1443,21 @@ const Mi = {
1441
1443
  },
1442
1444
  onEventChange_: function(t) {
1443
1445
  const e = Fe(t);
1444
- e ? (this.event.id = e.id, this.event.kind = e.kind, this.event.names = e.names, this.event.params = e.params) : (this.event.id = "", this.event.kind = "", this.event.names = [], this.event.params = []), this.updateShape_(), setTimeout(() => {
1446
+ e ? (this.event.id = e.id, this.event.kind = e.kind, this.event.names = e.names, this.event.params = e.params) : (this.event.id = "", this.event.kind = "", this.event.names = [], this.event.params = void 0), this.updateShape_(), setTimeout(() => {
1445
1447
  this.ensureBlocks_();
1446
1448
  }, 0);
1447
1449
  },
1448
1450
  updateShape_: function() {
1449
- for (let e = this.event.params.length; this.getInput("PARAM" + e); e++) {
1451
+ for (let e = this.event.params?.length ?? 0; this.getInput("PARAM" + e); e++) {
1450
1452
  const n = this.getInput("PARAM" + e).connection.targetBlock();
1451
1453
  n && n.dispose(), this.removeInput("PARAM" + e);
1452
1454
  }
1453
- for (let e = 0; e < this.event.params.length; e++)
1454
- this.getInput("PARAM" + e) || (this.appendValueInput("PARAM" + e), this.moveInputBefore("PARAM" + e, "HANDLE"));
1455
+ if (this.event.params)
1456
+ for (let e = 0; e < this.event.params.length; e++)
1457
+ this.getInput("PARAM" + e) || (this.appendValueInput("PARAM" + e), this.moveInputBefore("PARAM" + e, "HANDLE"));
1455
1458
  const { kind: t } = on(this.event.id);
1456
1459
  if (t === "multipleRefEvent")
1457
- this.getInput("REF_KEY") || this.appendValueInput("REF_KEY"), this.event.params.length > 0 ? this.moveInputBefore("REF_KEY", "PARAM0") : this.moveInputBefore("REF_KEY", "HANDLE");
1460
+ this.getInput("REF_KEY") || this.appendValueInput("REF_KEY"), this.event.params && this.event.params.length > 0 ? this.moveInputBefore("REF_KEY", "PARAM0") : this.moveInputBefore("REF_KEY", "HANDLE");
1458
1461
  else if (this.getInput("REF_KEY")) {
1459
1462
  const e = this.getInput("REF_KEY").connection.targetBlock();
1460
1463
  e && e.dispose(), this.removeInput("REF_KEY");
@@ -1466,9 +1469,12 @@ const Mi = {
1466
1469
  const t = [];
1467
1470
  this.event.kind === "referenceEvent" && t.push(["REF_KEY", "__refKey__", "x-runtime-lib.refKey", !0]);
1468
1471
  let e = !0;
1469
- (this.event.kind === "referenceEvent" || this.event.kind === "customEvent") && (e = !1), this.event.params.forEach(({ key: n, name: o }, i) => {
1470
- t.push(["PARAM" + i, `__param$${n}__`, o, e]);
1471
- }), t.length > 0 && F(this, t);
1472
+ if ((this.event.kind === "referenceEvent" || this.event.kind === "customEvent") && (e = !1), this.event.params)
1473
+ for (let n = 0; n < this.event.params.length; n++) {
1474
+ const { key: o, name: i } = this.event.params[n];
1475
+ t.push(["PARAM" + n, `__param$${o}__`, i, e]);
1476
+ }
1477
+ t.length > 0 && F(this, t);
1472
1478
  },
1473
1479
  checkWarning_: function() {
1474
1480
  const t = mt(this.node.id);
@@ -1501,9 +1507,9 @@ E.on_app_event_v1 = Mi;
1501
1507
  s.forBlock.on_app_event_v1 = function(t) {
1502
1508
  const e = s.quote_, n = t, o = n.event.id;
1503
1509
  let i = "";
1504
- n.event.params.forEach((r, l) => {
1505
- l !== 0 && (i += ", "), i += `__param$${r.key}__`;
1506
- });
1510
+ if (n.event.params)
1511
+ for (const { key: r } of n.event.params)
1512
+ i && (i += ", "), i += `__param$${r}__`;
1507
1513
  const a = s.statementToCode(n, "HANDLE");
1508
1514
  return `__onEventV1__(${e(o)}, async function(${i}) {
1509
1515
  ${a}});
@@ -1514,8 +1520,7 @@ const Ui = {
1514
1520
  this.event = {
1515
1521
  id: "",
1516
1522
  kind: "",
1517
- names: [],
1518
- params: []
1523
+ names: []
1519
1524
  }, this.appendDummyInput().appendField("%{BKY_APP_V1_TRIGGER_APP_EVENT_TITLE}").appendField(
1520
1525
  new O(() => this.genEventOpts_()),
1521
1526
  "EVENT"
@@ -1537,7 +1542,7 @@ const Ui = {
1537
1542
  };
1538
1543
  },
1539
1544
  loadExtraState: function(t) {
1540
- this.event.id = t.event?.id ?? "", this.event.kind = t.event?.kind ?? "", this.event.names = t.event?.names ?? [], this.event.params = t.event?.params ?? [], this.updateShape_(), this.updateShadows_(), setTimeout(() => {
1545
+ this.event.id = t.event?.id ?? "", this.event.kind = t.event?.kind ?? "", this.event.names = t.event?.names ?? [], this.event.params = t.event?.params, this.updateShape_(), this.updateShadows_(), setTimeout(() => {
1541
1546
  this.checkWarning_();
1542
1547
  }, 0);
1543
1548
  },
@@ -1556,26 +1561,26 @@ const Ui = {
1556
1561
  },
1557
1562
  onEventChange_: function(t) {
1558
1563
  const e = kn(t);
1559
- e ? (this.event.id = e.id, this.event.kind = e.kind, this.event.names = e.names, this.event.params = e.params) : (this.event.id = "", this.event.kind = "", this.event.names = [], this.event.params = []);
1564
+ e ? (this.event.id = e.id, this.event.kind = e.kind, this.event.names = e.names, this.event.params = e.params) : (this.event.id = "", this.event.kind = "", this.event.names = [], this.event.params = void 0);
1560
1565
  },
1561
1566
  updateShape_: function() {
1562
- for (let t = this.event.params.length; this.getInput("PARAM" + t); t++) {
1567
+ for (let t = this.event.params?.length ?? 0; this.getInput("PARAM" + t); t++) {
1563
1568
  const e = this.getInput("PARAM" + t)?.connection?.targetBlock();
1564
1569
  e && e.dispose(), this.removeInput("PARAM" + t);
1565
1570
  }
1566
- for (let t = 0; t < this.event.params.length; t++)
1567
- this.getInput("PARAM" + t) || this.appendValueInput("PARAM" + t);
1568
- for (let t = 0; t < this.event.params.length; t++) {
1569
- const e = this.getInput("PARAM" + t);
1570
- e.connection.setShadowDom(null);
1571
- const n = e.connection.targetBlock();
1572
- n && !n.isShadow() && n.dispose();
1573
- const { type: o } = this.event.params[t], i = gt(o);
1574
- e.setCheck(i);
1571
+ if (this.event.params) {
1572
+ for (let t = 0; t < this.event.params.length; t++)
1573
+ this.getInput("PARAM" + t) || this.appendValueInput("PARAM" + t);
1574
+ for (let t = 0; t < this.event.params.length; t++) {
1575
+ const { type: e } = this.event.params[t], n = this.getInput("PARAM" + t);
1576
+ n.connection.setShadowDom(null);
1577
+ const o = n.connection.targetBlock();
1578
+ o && !o.isShadow() && o.dispose(), n.setCheck(gt(e));
1579
+ }
1575
1580
  }
1576
1581
  },
1577
1582
  updateShadows_: function() {
1578
- if (!this.isInsertionMarker())
1583
+ if (!this.isInsertionMarker() && this.event.params)
1579
1584
  for (let t = 0; t < this.event.params.length; t++) {
1580
1585
  const e = this.event.params[t], n = At(e.type);
1581
1586
  this.getInput("PARAM" + t)?.connection?.setShadowDom(n);
@@ -1602,14 +1607,15 @@ E.trigger_app_event_v1 = Ui;
1602
1607
  s.forBlock.trigger_app_event_v1 = function(t) {
1603
1608
  const e = s.quote_, n = t;
1604
1609
  let o = "";
1605
- for (let a = 0; a < n.event.params.length; a++) {
1606
- const c = s.valueToCode(
1607
- n,
1608
- "PARAM" + a,
1609
- u.NONE
1610
- );
1611
- o && (o += ", "), o += c;
1612
- }
1610
+ if (n.event.params)
1611
+ for (let a = 0; a < n.event.params.length; a++) {
1612
+ const c = s.valueToCode(
1613
+ n,
1614
+ "PARAM" + a,
1615
+ u.NONE
1616
+ );
1617
+ o && (o += ", "), o += c;
1618
+ }
1613
1619
  return `__triggerEventV1__(${e(n.event.id)}, ${o});
1614
1620
  `;
1615
1621
  };
@@ -1691,7 +1697,7 @@ E.open_confirm_dlg_v1 = Vi;
1691
1697
  s.forBlock.open_confirm_dlg_v1 = function(t) {
1692
1698
  const e = s.valueToCode(t, "TITLE", u.ATOMIC), n = s.valueToCode(t, "TEXT", u.ATOMIC), o = s.statementToCode(t, "HANDLE");
1693
1699
  return `{
1694
- var __result__ = __openConfirmDlgV1__(${e}, ${n});
1700
+ var __result__ = await __openConfirmDlgV1__(${e}, ${n});
1695
1701
  ${o}}
1696
1702
  `;
1697
1703
  };
@@ -1730,7 +1736,7 @@ E.open_prompt_dlg_v1 = xi;
1730
1736
  s.forBlock.open_prompt_dlg_v1 = function(t) {
1731
1737
  const e = s.valueToCode(t, "TITLE", u.ATOMIC), n = s.valueToCode(t, "LABEL", u.ATOMIC), o = s.valueToCode(t, "VALUE", u.ATOMIC), i = s.statementToCode(t, "HANDLE");
1732
1738
  return `{
1733
- var __result__ = __openPromptDlgV1__(${e}, ${n}, ${o});
1739
+ var __result__ = await __openPromptDlgV1__(${e}, ${n}, ${o});
1734
1740
  ${i}}
1735
1741
  `;
1736
1742
  };
@@ -1775,9 +1781,7 @@ const Yi = {
1775
1781
  }, this.method = {
1776
1782
  id: "",
1777
1783
  kind: "",
1778
- names: [],
1779
- inputs: [],
1780
- outputs: []
1784
+ names: []
1781
1785
  }, this.appendDummyInput("DUMMY").appendField("%{BKY_APP_V1_CALL_APP_METHOD_TITLE}").appendField(new O(() => this.genNodeOpts_()), "NODE").appendField(
1782
1786
  new O(() => this.genMethodOpts_()),
1783
1787
  "METHOD"
@@ -1806,7 +1810,7 @@ const Yi = {
1806
1810
  };
1807
1811
  },
1808
1812
  loadExtraState: function(t) {
1809
- this.node.id = t.node?.id ?? "", this.node.key = t.node?.key ?? "", this.node.alias = t.node?.alias ?? "", this.method.id = t.method?.id ?? "", this.method.kind = t.method?.kind ?? "", this.method.names = t.method?.names ?? [], this.method.inputs = t.method?.inputs ?? [], this.method.outputs = t.method?.outputs ?? [], this.updateShape_(), this.updateShadow_(), setTimeout(() => {
1813
+ this.node.id = t.node?.id ?? "", this.node.key = t.node?.key ?? "", this.node.alias = t.node?.alias ?? "", this.method.id = t.method?.id ?? "", this.method.kind = t.method?.kind ?? "", this.method.names = t.method?.names ?? [], this.method.inputs = t.method?.inputs, this.method.outputs = t.method?.outputs, this.updateShape_(), this.updateShadow_(), setTimeout(() => {
1810
1814
  this.ensureBlocks_(), this.checkWarning_();
1811
1815
  }, 0);
1812
1816
  },
@@ -1848,32 +1852,34 @@ const Yi = {
1848
1852
  }, 0);
1849
1853
  },
1850
1854
  updateShape_: function() {
1851
- this.method.outputs.length > 0 ? this.getInput("HANDLE") || this.appendStatementInput("HANDLE").appendField("%{BKY_APP_DO}") : this.getInput("HANDLE") && this.removeInput("HANDLE");
1852
- for (let t = this.method.outputs.length; this.getInput("OUTPUT" + t); t++) {
1855
+ this.method.outputs && this.method.outputs.length > 0 ? this.getInput("HANDLE") || this.appendStatementInput("HANDLE").appendField("%{BKY_APP_DO}") : this.getInput("HANDLE") && this.removeInput("HANDLE");
1856
+ for (let t = this.method.outputs?.length ?? 0; this.getInput("OUTPUT" + t); t++) {
1853
1857
  const e = this.getInput("OUTPUT" + t)?.connection?.targetBlock();
1854
1858
  e && e.dispose(), this.removeInput("OUTPUT" + t);
1855
1859
  }
1856
- for (let t = 0; t < this.method.outputs.length; t++) {
1857
- if (this.getInput("OUTPUT" + t))
1858
- continue;
1859
- const e = this.appendValueInput("OUTPUT" + t);
1860
- t === 0 && e.appendField("%{BKY_APP_RETURN}"), this.moveInputBefore("OUTPUT" + t, "HANDLE");
1861
- }
1862
- for (let t = this.method.inputs.length; this.getInput("INPUT" + t); t++)
1860
+ if (this.method.outputs)
1861
+ for (let t = 0; t < this.method.outputs.length; t++) {
1862
+ if (this.getInput("OUTPUT" + t))
1863
+ continue;
1864
+ const e = this.appendValueInput("OUTPUT" + t);
1865
+ t === 0 && e.appendField("%{BKY_APP_RETURN}"), this.moveInputBefore("OUTPUT" + t, "HANDLE");
1866
+ }
1867
+ for (let t = this.method.inputs?.length ?? 0; this.getInput("INPUT" + t); t++)
1863
1868
  this.removeInput("INPUT" + t);
1864
- for (let t = 0; t < this.method.inputs.length; t++) {
1865
- const e = this.method.inputs[t];
1866
- this.getInput("INPUT" + t) || (this.appendValueInput("INPUT" + t).setAlign(v.Align.RIGHT).appendField(f(e.name)), this.method.outputs.length > 0 && this.moveInputBefore("INPUT" + t, "OUTPUT0"));
1867
- }
1869
+ if (this.method.inputs)
1870
+ for (let t = 0; t < this.method.inputs.length; t++) {
1871
+ const e = this.method.inputs[t];
1872
+ this.getInput("INPUT" + t) || (this.appendValueInput("INPUT" + t).setAlign(v.Align.RIGHT).appendField(f(e.name)), this.method.outputs && this.method.outputs.length > 0 && this.moveInputBefore("INPUT" + t, "OUTPUT0"));
1873
+ }
1868
1874
  if (this.method.kind === "multipleRefMethod")
1869
- this.getInput("REF_KEY") || this.appendValueInput("REF_KEY").setAlign(v.Align.RIGHT).appendField(f("BKY_APP_REF_KEY")), this.method.inputs.length > 0 ? this.moveInputBefore("REF_KEY", "INPUT0") : this.method.outputs.length > 0 && this.moveInputBefore("REF_KEY", "OUTPUT0");
1875
+ this.getInput("REF_KEY") || this.appendValueInput("REF_KEY").setAlign(v.Align.RIGHT).appendField(f("BKY_APP_REF_KEY")), this.method.inputs && this.method.inputs.length > 0 ? this.moveInputBefore("REF_KEY", "INPUT0") : this.method.outputs && this.method.outputs.length > 0 && this.moveInputBefore("REF_KEY", "OUTPUT0");
1870
1876
  else if (this.getInput("REF_KEY")) {
1871
1877
  const t = this.getInput("REF_KEY").connection.targetBlock();
1872
1878
  t && t.dispose(), this.removeInput("REF_KEY");
1873
1879
  }
1874
1880
  },
1875
1881
  updateShadow_: function() {
1876
- if (!this.isInsertionMarker())
1882
+ if (!this.isInsertionMarker() && this.method.inputs)
1877
1883
  for (let t = 0; t < this.method.inputs.length; t++) {
1878
1884
  const e = this.method.inputs[t];
1879
1885
  if (!e.type)
@@ -1886,10 +1892,11 @@ const Yi = {
1886
1892
  if (this.isInsertionMarker())
1887
1893
  return;
1888
1894
  const { kind: t } = Jt(this.method.id), e = wn(t), n = [];
1889
- for (let o = 0; o < this.method.outputs.length; o++) {
1890
- const { key: i, name: a } = this.method.outputs[o];
1891
- n.push(["OUTPUT" + o, `__output$${i}__`, a, e]);
1892
- }
1895
+ if (this.method.outputs)
1896
+ for (let o = 0; o < this.method.outputs.length; o++) {
1897
+ const { key: i, name: a } = this.method.outputs[o];
1898
+ n.push(["OUTPUT" + o, `__output$${i}__`, a, e]);
1899
+ }
1893
1900
  n.length > 0 && F(this, n);
1894
1901
  },
1895
1902
  checkWarning_: function() {
@@ -1929,41 +1936,45 @@ s.forBlock.call_app_method_v1 = function(t) {
1929
1936
  let i;
1930
1937
  o.method.kind === "multipleRefMethod" && (i = s.valueToCode(o, "REF_KEY", u.NONE) || "''");
1931
1938
  let a = "{";
1932
- o.method.inputs.forEach(({ key: r, type: l }, _) => {
1933
- let p = s.valueToCode(
1934
- o,
1935
- "INPUT" + _,
1936
- u.ATOMIC
1937
- );
1938
- if (p === void 0)
1939
- switch (l) {
1940
- case "string":
1941
- p = "''";
1942
- break;
1943
- case "number":
1944
- p = "0";
1945
- break;
1946
- case "boolean":
1947
- p = "false";
1948
- break;
1949
- case "array":
1950
- p = "[]";
1951
- break;
1952
- case "object":
1953
- p = "{}";
1954
- break;
1955
- default:
1956
- p = "null";
1957
- }
1958
- a !== "{" && (a += ", "), a += `${n(r)}: ${p}`;
1959
- }), a += "}";
1939
+ if (o.method.inputs)
1940
+ for (let r = 0; r < o.method.inputs.length; r++) {
1941
+ const { key: l, type: _ } = o.method.inputs[r];
1942
+ let p = s.valueToCode(
1943
+ o,
1944
+ "INPUT" + r,
1945
+ u.ATOMIC
1946
+ );
1947
+ if (p === void 0)
1948
+ switch (_) {
1949
+ case "string":
1950
+ p = "''";
1951
+ break;
1952
+ case "number":
1953
+ p = "0";
1954
+ break;
1955
+ case "boolean":
1956
+ p = "false";
1957
+ break;
1958
+ case "array":
1959
+ p = "[]";
1960
+ break;
1961
+ case "object":
1962
+ p = "{}";
1963
+ break;
1964
+ default:
1965
+ p = "null";
1966
+ }
1967
+ a !== "{" && (a += ", "), a += `${n(l)}: ${p}`;
1968
+ }
1969
+ a += "}";
1960
1970
  let c = "";
1961
- if (o.method.outputs.forEach(({ key: r }) => {
1962
- c += `${e}__output$${r}__ = __outputs__[${n(r)}];
1971
+ if (o.method.outputs)
1972
+ for (const { key: r } of o.method.outputs)
1973
+ c += `${e}__output$${r}__ = __outputs__[${n(r)}];
1963
1974
  `;
1964
- }), o.method.kind === "customMethod") {
1975
+ if (o.method.kind === "customMethod") {
1965
1976
  const { methodKey: r } = Jt(o.method.id);
1966
- if (o.method.outputs.length > 0) {
1977
+ if (o.method.outputs && o.method.outputs.length > 0) {
1967
1978
  const l = s.statementToCode(o, "HANDLE");
1968
1979
  return `{
1969
1980
  var __outputs__ = __implementMethod$${r}__(${a});
@@ -1972,7 +1983,7 @@ ${c}${l}}
1972
1983
  } else
1973
1984
  return `__implementMethod$${r}__(${a});
1974
1985
  `;
1975
- } else if (o.method.outputs.length > 0) {
1986
+ } else if (o.method.outputs && o.method.outputs.length > 0) {
1976
1987
  const r = s.statementToCode(o, "HANDLE");
1977
1988
  return `{
1978
1989
  var __outputs__ = __callMethodV1__(${n(o.method.id)}, ${i}, ${a});
@@ -1987,8 +1998,7 @@ const Fi = {
1987
1998
  this.method = {
1988
1999
  id: "",
1989
2000
  kind: "",
1990
- names: [],
1991
- inputs: []
2001
+ names: []
1992
2002
  }, this.appendDummyInput().appendField("%{BKY_APP_V1_IMPLEMENT_APP_METHOD_TITLE}").appendField(
1993
2003
  new O(() => this.genMethodOpts_()),
1994
2004
  "METHOD"
@@ -2008,7 +2018,7 @@ const Fi = {
2008
2018
  };
2009
2019
  },
2010
2020
  loadExtraState: function(t) {
2011
- this.method.id = t.method?.id ?? "", this.method.kind = t.method?.kind ?? "", this.method.names = t.method?.names ?? [], this.method.inputs = t.method?.inputs ?? [], this.updateShape_(), setTimeout(() => {
2021
+ this.method.id = t.method?.id ?? "", this.method.kind = t.method?.kind ?? "", this.method.names = t.method?.names ?? [], this.method.inputs = t.method?.inputs, this.updateShape_(), setTimeout(() => {
2012
2022
  this.ensureBlocks_(), this.checkWarning_();
2013
2023
  }, 0);
2014
2024
  },
@@ -2032,21 +2042,23 @@ const Fi = {
2032
2042
  }, 0);
2033
2043
  },
2034
2044
  updateShape_: function() {
2035
- for (let t = this.method.inputs.length; this.getInput("INPUT" + t); t++) {
2045
+ for (let t = this.method.inputs?.length ?? 0; this.getInput("INPUT" + t); t++) {
2036
2046
  const e = this.getInput("INPUT" + t)?.connection?.targetBlock();
2037
2047
  e && e.dispose(), this.removeInput("INPUT" + t);
2038
2048
  }
2039
- for (let t = 0; t < this.method.inputs.length; t++)
2040
- this.getInput("INPUT" + t) || (this.appendValueInput("INPUT" + t), this.moveInputBefore("INPUT" + t, "HANDLE"));
2049
+ if (this.method.inputs)
2050
+ for (let t = 0; t < this.method.inputs.length; t++)
2051
+ this.getInput("INPUT" + t) || (this.appendValueInput("INPUT" + t), this.moveInputBefore("INPUT" + t, "HANDLE"));
2041
2052
  },
2042
2053
  ensureBlocks_: function() {
2043
2054
  if (this.isInsertionMarker() || !this.method.id)
2044
2055
  return;
2045
2056
  const t = wn(this.method.kind), e = [];
2046
- for (let n = 0; n < this.method.inputs.length; n++) {
2047
- const { key: o, name: i } = this.method.inputs[n];
2048
- e.push(["INPUT" + n, `__input$${o}__`, i, t]);
2049
- }
2057
+ if (this.method.inputs)
2058
+ for (let n = 0; n < this.method.inputs.length; n++) {
2059
+ const { key: o, name: i } = this.method.inputs[n];
2060
+ e.push(["INPUT" + n, `__input$${o}__`, i, t]);
2061
+ }
2050
2062
  F(this, e);
2051
2063
  },
2052
2064
  checkWarning_: function() {
@@ -2070,10 +2082,10 @@ E.implement_app_method_v1 = Fi;
2070
2082
  s.forBlock.implement_app_method_v1 = function(t) {
2071
2083
  const e = s.INDENT, n = s.quote_, o = t, { methodKey: i } = Jt(o.method.id);
2072
2084
  let a = "";
2073
- o.method.inputs.forEach(({ key: l }) => {
2074
- a += `${e}var __input$${l}__ = __inputs__[${n(l)}];
2085
+ if (o.method.inputs)
2086
+ for (const { key: l } of o.method.inputs)
2087
+ a += `${e}var __input$${l}__ = __inputs__[${n(l)}];
2075
2088
  `;
2076
- });
2077
2089
  const c = s.statementToCode(o, "HANDLE");
2078
2090
  return `async function __implementMethod$${i}__(__inputs__) {
2079
2091
  ${a}${e}var __outputs__ = {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "x-block-lib",
3
3
  "private": false,
4
- "version": "0.8.44",
4
+ "version": "0.8.46",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -37,8 +37,8 @@
37
37
  "vue-i18n": "^11.1.12",
38
38
  "vue-router": "^4.6.3",
39
39
  "vuetify": "^3.10.9",
40
- "x-essential-lib": "^0.9.3",
41
- "x-runtime-lib": "^0.8.76",
40
+ "x-essential-lib": "^0.9.5",
41
+ "x-runtime-lib": "^0.8.85",
42
42
  "x-state-lib": "^0.3.24"
43
43
  },
44
44
  "devDependencies": {