x-block-lib 0.11.9 → 0.11.10

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.
@@ -308,6 +308,7 @@ var en_default = {
308
308
  CATEGORY_RESOURCE: "resource",
309
309
  CATEGORY_TEXT: "text",
310
310
  CATEGORY_TIME: "time",
311
+ CATEGORY_TYPE: "type",
311
312
  CATEGORY_VARIABLE: "var",
312
313
  LABEL_ARGUMENT: "Argument",
313
314
  LABEL_BOOLEAN: "Boolean",
package/dist/index.js CHANGED
@@ -9,8 +9,8 @@ import { useDisplay } from "vuetify";
9
9
 
10
10
  //#region src/core/locale/index.ts
11
11
  async function setLocale(locale) {
12
- if (locale === "en") setLocale$1((await import("./en.e929s12a.js")).default);
13
- else if (locale === "zhHans") setLocale$1((await import("./zhHans.c7mba28i.js")).default);
12
+ if (locale === "en") setLocale$1((await import("./en.non7wgtb.js")).default);
13
+ else if (locale === "zhHans") setLocale$1((await import("./zhHans.er5jfqth.js")).default);
14
14
  else throw new Error(`invalid locale=${locale}`);
15
15
  }
16
16
  function localeMsg(key) {
@@ -457,7 +457,7 @@ function inWhiteList(type) {
457
457
 
458
458
  //#endregion
459
459
  //#region src/core/blocks/common/parameter/v1/index.ts
460
- const xmlUtils$11 = utils.xml;
460
+ const xmlUtils$12 = utils.xml;
461
461
  const PARAMETER_V1 = {
462
462
  init: function() {
463
463
  this.key = "";
@@ -468,7 +468,7 @@ const PARAMETER_V1 = {
468
468
  this.setColour(220);
469
469
  },
470
470
  mutationToDom: function() {
471
- const container = xmlUtils$11.createElement("mutation");
471
+ const container = xmlUtils$12.createElement("mutation");
472
472
  container.setAttribute("key", this.key);
473
473
  container.setAttribute("name", this.name);
474
474
  container.setAttribute("locale", this.locale ? "TRUE" : "FALSE");
@@ -2769,7 +2769,7 @@ javascriptGenerator.forBlock["app_bind_entry_v1"] = function() {
2769
2769
 
2770
2770
  //#endregion
2771
2771
  //#region src/core/blocks/app/event/appBind/v1/index.ts
2772
- const xmlUtils$10 = utils.xml;
2772
+ const xmlUtils$11 = utils.xml;
2773
2773
  const APP_BIND_CONTAINER_V1 = { init: function() {
2774
2774
  this.appendDummyInput().appendField("%{BKY_APP_V1_APP_BIND_CONTAINER_TITLE}");
2775
2775
  this.appendStatementInput("STACK");
@@ -2797,7 +2797,7 @@ const APP_BIND_V1 = {
2797
2797
  this.setHelpUrl("%{BKY_APP_V1_APP_BIND_HELPURL}");
2798
2798
  },
2799
2799
  mutationToDom: function() {
2800
- const container = xmlUtils$10.createElement("mutation");
2800
+ const container = xmlUtils$11.createElement("mutation");
2801
2801
  container.setAttribute("items", String(this.itemCount_));
2802
2802
  return container;
2803
2803
  },
@@ -7880,7 +7880,7 @@ ${javascriptGenerator.statementToCode(block, "HANDLE")}}
7880
7880
 
7881
7881
  //#endregion
7882
7882
  //#region src/core/blocks/json/jsonArray/v1/index.ts
7883
- const xmlUtils$9 = utils.xml;
7883
+ const xmlUtils$10 = utils.xml;
7884
7884
  const JSON_ARRAY_V1 = {
7885
7885
  init: function() {
7886
7886
  this.length = 0;
@@ -7897,7 +7897,7 @@ const JSON_ARRAY_V1 = {
7897
7897
  this.setHelpUrl("");
7898
7898
  },
7899
7899
  mutationToDom: function() {
7900
- const container = xmlUtils$9.createElement("mutation");
7900
+ const container = xmlUtils$10.createElement("mutation");
7901
7901
  container.setAttribute("items", String(this.length));
7902
7902
  return container;
7903
7903
  },
@@ -7974,7 +7974,7 @@ Blocks.json_boolean_v1 = JSON_BOOLEAN_V1;
7974
7974
 
7975
7975
  //#endregion
7976
7976
  //#region src/core/blocks/json/jsonMap/v1/index.ts
7977
- const xmlUtils$8 = utils.xml;
7977
+ const xmlUtils$9 = utils.xml;
7978
7978
  const JSON_MAP_V1 = {
7979
7979
  init: function() {
7980
7980
  this.length = 0;
@@ -7991,9 +7991,9 @@ const JSON_MAP_V1 = {
7991
7991
  this.setHelpUrl("");
7992
7992
  },
7993
7993
  mutationToDom: function() {
7994
- const container = xmlUtils$8.createElement("mutation");
7994
+ const container = xmlUtils$9.createElement("mutation");
7995
7995
  for (let i = 0; i < this.length; i++) {
7996
- const item = xmlUtils$8.createElement("item");
7996
+ const item = xmlUtils$9.createElement("item");
7997
7997
  item.setAttribute("key", this.getFieldValue("KEY" + i));
7998
7998
  container.appendChild(item);
7999
7999
  }
@@ -8097,7 +8097,7 @@ Blocks.json_string_v1 = JSON_STRING_V1;
8097
8097
 
8098
8098
  //#endregion
8099
8099
  //#region src/core/blocks/list/listCreate/v1/index.ts
8100
- const xmlUtils$7 = utils.xml;
8100
+ const xmlUtils$8 = utils.xml;
8101
8101
  const LIST_CREATE_CONTAINER_V1 = { init: function() {
8102
8102
  this.appendDummyInput().appendField("%{BKY_LIST_V1_CREATE_CONTAINER_TITLE}");
8103
8103
  this.appendStatementInput("STACK");
@@ -8124,7 +8124,7 @@ const LIST_CREATE_V1 = {
8124
8124
  this.updateShape_();
8125
8125
  },
8126
8126
  mutationToDom: function() {
8127
- const container = xmlUtils$7.createElement("mutation");
8127
+ const container = xmlUtils$8.createElement("mutation");
8128
8128
  container.setAttribute("items", String(this.itemCount_));
8129
8129
  return container;
8130
8130
  },
@@ -9738,7 +9738,7 @@ javascriptGenerator.forBlock["math_trig_v1"] = function(block) {
9738
9738
 
9739
9739
  //#endregion
9740
9740
  //#region src/core/blocks/object/objectCreate/v1/index.ts
9741
- const xmlUtils$6 = utils.xml;
9741
+ const xmlUtils$7 = utils.xml;
9742
9742
  const OBJECT_CREATE_CONTAINER_V1 = { init: function() {
9743
9743
  this.appendDummyInput().appendField("%{BKY_OBJECT_V1_CREATE_CONTAINER_TITLE}");
9744
9744
  this.appendStatementInput("STACK");
@@ -9765,7 +9765,7 @@ const OBJECT_CREATE_V1 = {
9765
9765
  this.setHelpUrl("%{BKY_OBJECT_V1_CREATE_HELPURL}");
9766
9766
  },
9767
9767
  mutationToDom: function() {
9768
- const container = xmlUtils$6.createElement("mutation");
9768
+ const container = xmlUtils$7.createElement("mutation");
9769
9769
  container.setAttribute("items", String(this.itemCount_));
9770
9770
  return container;
9771
9771
  },
@@ -10071,7 +10071,7 @@ javascriptGenerator.forBlock["object_to_json_v1"] = function(block) {
10071
10071
 
10072
10072
  //#endregion
10073
10073
  //#region src/core/blocks/procedure/procedureDef/v1/index.ts
10074
- const xmlUtils$5 = utils.xml;
10074
+ const xmlUtils$6 = utils.xml;
10075
10075
  const PROCEDURE_DEF_CONTAINER_V1 = { init: function() {
10076
10076
  this.appendDummyInput().appendField("%{BKY_PROCEDURE_V1_DEF_CONTAINER_TITLE}").appendField(new FieldCheckbox(false), "WITHRETURN");
10077
10077
  this.appendStatementInput("STACK");
@@ -10122,10 +10122,10 @@ const PROCEDURE_DEF_V1 = {
10122
10122
  this.setHelpUrl("%{BKY_PROCEDURE_V1_DEF_HELPURL}");
10123
10123
  },
10124
10124
  mutationToDom: function() {
10125
- const container = xmlUtils$5.createElement("mutation");
10125
+ const container = xmlUtils$6.createElement("mutation");
10126
10126
  container.setAttribute("withreturn", this.withReturn ? "TRUE" : "FALSE");
10127
10127
  this.args.forEach((arg) => {
10128
- const child = xmlUtils$5.createElement("arg");
10128
+ const child = xmlUtils$6.createElement("arg");
10129
10129
  child.setAttribute("name", arg.name);
10130
10130
  child.setAttribute("id", arg.id);
10131
10131
  container.appendChild(child);
@@ -10241,6 +10241,137 @@ const PROCEDURE_DEF_V1 = {
10241
10241
  };
10242
10242
  Blocks.procedure_def_v1 = PROCEDURE_DEF_V1;
10243
10243
 
10244
+ //#endregion
10245
+ //#region src/core/blocks/procedure/procedureCall/v1/index.ts
10246
+ const xmlUtils$5 = utils.xml;
10247
+ const PROCEDURE_CALL_V1 = {
10248
+ init: function() {
10249
+ this.withReturn = false;
10250
+ this.args = [];
10251
+ this.quarkIds_ = [];
10252
+ this.quarkConnections_ = {};
10253
+ this.appendDummyInput().appendField("", "NAME");
10254
+ this.setStyle("procedure_blocks");
10255
+ this.setTooltip("%{BKY_PROCEDURE_V1_CALL_TOOLTIP}");
10256
+ this.setHelpUrl("%{BKY_PROCEDURE_V1_CALL_HELPURL}");
10257
+ },
10258
+ mutationToDom: function() {
10259
+ const container = xmlUtils$5.createElement("mutation");
10260
+ container.setAttribute("name", this.getProcedureName_());
10261
+ container.setAttribute("withreturn", this.withReturn ? "TRUE" : "FALSE");
10262
+ this.args.forEach((arg) => {
10263
+ const child = xmlUtils$5.createElement("arg");
10264
+ child.setAttribute("name", arg);
10265
+ container.appendChild(child);
10266
+ });
10267
+ return container;
10268
+ },
10269
+ domToMutation: function(xmlElement) {
10270
+ const name = xmlElement.getAttribute("name") ?? "";
10271
+ const withReturn = xmlElement.getAttribute("withreturn") === "TRUE" ? true : false;
10272
+ const args = [];
10273
+ for (let i = 0, childNode; childNode = xmlElement.childNodes[i]; i++) if (childNode.nodeName.toLowerCase() === "arg") args.push(childNode.getAttribute("name"));
10274
+ this.setProcedureName_(name);
10275
+ this.setProcedureReturnArgs_(withReturn, [], []);
10276
+ },
10277
+ saveExtraState: function() {},
10278
+ loadExtraState: function() {},
10279
+ getProcedureName_: function() {
10280
+ return this.getFieldValue("NAME");
10281
+ },
10282
+ setProcedureName_: function(name) {
10283
+ this.setFieldValue(name, "NAME");
10284
+ },
10285
+ setProcedureReturnArgs_: function(withReturn, argNames, argIds) {
10286
+ if (argNames.length !== argIds.length) throw RangeError("argNames and argIds must be same length");
10287
+ this.withReturn = withReturn;
10288
+ const defBlock = Procedures.getDefinition(this.getProcedureName_(), this.workspace);
10289
+ const mutatorIcon = defBlock && defBlock.getIcon(icons.MutatorIcon.TYPE);
10290
+ const mutatorOpen = mutatorIcon && mutatorIcon.bubbleIsVisible();
10291
+ if (mutatorOpen) this.setCollapsed(false);
10292
+ else {
10293
+ this.quarkIds_ = [];
10294
+ this.quarkConnections_ = {};
10295
+ }
10296
+ if (argNames.join("\n") === this.args.join("\n")) {
10297
+ this.quarkIds_ = argIds;
10298
+ this.updateShape_();
10299
+ return;
10300
+ }
10301
+ for (let i = 0; i < this.args.length; i++) {
10302
+ const input = this.getInput("ARG" + i);
10303
+ if (input) {
10304
+ const connection = input.connection.targetConnection;
10305
+ this.quarkConnections_[this.quarkIds_[i]] = connection;
10306
+ if (connection && mutatorOpen && !argIds.includes(this.quarkIds_[i])) {
10307
+ connection.disconnect();
10308
+ connection.getSourceBlock().bumpNeighbours();
10309
+ }
10310
+ }
10311
+ }
10312
+ this.args = [...argNames];
10313
+ this.updateShape_();
10314
+ this.quarkIds_ = argIds;
10315
+ for (let i = 0; i < this.args.length; i++) {
10316
+ const quarkId = this.quarkIds_[i];
10317
+ if (quarkId in this.quarkConnections_) {
10318
+ if (!this.quarkConnections_[quarkId]?.reconnect(this, "ARG" + i)) delete this.quarkConnections_[quarkId];
10319
+ }
10320
+ }
10321
+ },
10322
+ onchange: function(event) {
10323
+ if (!this.workspace || this.workspace.isFlyout) return;
10324
+ if (event.type === Events.BLOCK_DELETE) {
10325
+ if (!Procedures.getDefinition(this.getProcedureName_(), this.workspace)) this.dispose();
10326
+ } else if (event.type === Events.BLOCK_CHANGE) {
10327
+ const changeEvent = event;
10328
+ if (!changeEvent.blockId) return;
10329
+ const block = this.workspace.getBlockById(changeEvent.blockId);
10330
+ if (!block) return;
10331
+ if (changeEvent.element === "field" && changeEvent.name === "NAME") {
10332
+ if (changeEvent.oldValue === this.getProcedureName_()) this.setProcedureName_(changeEvent.newValue);
10333
+ }
10334
+ const [name, args, withReturn] = block.getProcedureDef();
10335
+ if (name !== this.getProcedureName_()) return;
10336
+ if (changeEvent.element === "disabled") {
10337
+ Events.setGroup(changeEvent.group);
10338
+ this.setDisabledReason(!!changeEvent.newValue, "");
10339
+ Events.setGroup(false);
10340
+ }
10341
+ if (this.withReturn !== withReturn) {
10342
+ if (this.getParent()) this.unplug();
10343
+ }
10344
+ this.setProcedureReturnArgs_(withReturn, args, []);
10345
+ }
10346
+ },
10347
+ updateShape_: function() {
10348
+ if (this.withReturn) {
10349
+ this.setOutput(true);
10350
+ this.setPreviousStatement(false);
10351
+ this.setNextStatement(false);
10352
+ } else {
10353
+ this.setOutput(false);
10354
+ this.setPreviousStatement(true);
10355
+ this.setNextStatement(true);
10356
+ }
10357
+ for (let i = 0; i < this.args.length; i++) {
10358
+ const arg = this.args[i];
10359
+ if (this.getInput("ARG" + i)) try {
10360
+ Events.disable();
10361
+ this.setFieldValue(arg, "ARGNAME");
10362
+ } finally {
10363
+ Events.enable();
10364
+ }
10365
+ else this.appendValueInput("ARG" + i).setAlign(inputs.Align.RIGHT).appendField(new FieldLabel(arg), "ARGNAME" + i);
10366
+ }
10367
+ for (let i = this.args.length; this.getInput("ARG" + i); i++) this.removeInput("ARG" + i);
10368
+ }
10369
+ };
10370
+ Blocks.procedure_call_v1 = PROCEDURE_CALL_V1;
10371
+ javascriptGenerator.forBlock["procedure_call_v1"] = function() {
10372
+ return "";
10373
+ };
10374
+
10244
10375
  //#endregion
10245
10376
  //#region src/core/blocks/procedure/procedureReturn/v1/index.ts
10246
10377
  const xmlUtils$4 = utils.xml;
@@ -13401,7 +13532,7 @@ const jsonToolboxV1 = {
13401
13532
  kind: "categoryToolbox",
13402
13533
  contents: [{
13403
13534
  kind: "category",
13404
- name: "%{BKY_CATEGORY_JSON}",
13535
+ name: "%{BKY_CATEGORY_TYPE}",
13405
13536
  colour: "330",
13406
13537
  contents: [
13407
13538
  {
@@ -308,6 +308,7 @@ var zhHans_default = {
308
308
  CATEGORY_RESOURCE: "资源",
309
309
  CATEGORY_TEXT: "文本",
310
310
  CATEGORY_TIME: "时间",
311
+ CATEGORY_TYPE: "类型",
311
312
  CATEGORY_VARIABLE: "变量",
312
313
  LABEL_ARGUMENT: "参数",
313
314
  LABEL_BOOLEAN: "布尔",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-block-lib",
3
- "version": "0.11.9",
3
+ "version": "0.11.10",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -52,7 +52,7 @@
52
52
  "vuetify": "^4.2.1",
53
53
  "x-error-lib": "^0.6.5",
54
54
  "x-essential-lib": "^0.10.40",
55
- "x-runtime-lib": "^0.10.3",
55
+ "x-runtime-lib": "^0.10.4",
56
56
  "x-state-lib": "^0.4.5"
57
57
  }
58
58
  }