x-block-lib 0.11.8 → 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",
@@ -4,13 +4,13 @@ import { n as __exportAll } from "./rolldown-runtime.d6iwd7kf.js";
4
4
  var en_exports = /* @__PURE__ */ __exportAll({ default: () => en_default });
5
5
  var en_default = { "x-block-lib": {
6
6
  bind: "Bind",
7
- dlg: { source: { title: "Source" } },
8
7
  funcEntry: "Func Entry",
9
8
  implementMethod: "Implement Method",
10
9
  msg: { cannotOperateInLockedState: "Cannot operate in locked state" },
11
10
  navigator: "Navigator",
12
11
  noOption: "No Option",
13
12
  procedure: "Procedure",
13
+ source: "Source",
14
14
  temporaryBlock: "Temporary Block",
15
15
  tip: {
16
16
  hotkeyCtrlE: "Press 'Ctrl W' to navigate",
@@ -4,13 +4,13 @@ import { n as __exportAll } from "./rolldown-runtime.d6iwd7kf.js";
4
4
  var zhHans_exports = /* @__PURE__ */ __exportAll({ default: () => zhHans_default });
5
5
  var zhHans_default = { "x-block-lib": {
6
6
  bind: "绑定",
7
- dlg: { source: { title: "源代码" } },
8
7
  funcEntry: "函数入口",
9
8
  implementMethod: "实现方法",
10
9
  msg: { cannotOperateInLockedState: "锁定状态下不能操作" },
11
10
  navigator: "导航器",
12
11
  noOption: "没有选项",
13
12
  procedure: "过程",
13
+ source: "源代码",
14
14
  temporaryBlock: "临时块",
15
15
  tip: {
16
16
  hotkeyCtrlE: "按「Ctrl E」导航",
package/dist/index.d.ts CHANGED
@@ -68,6 +68,12 @@ type __VLS_Props = {
68
68
  locale: string;
69
69
  dark: boolean;
70
70
  };
71
+ declare function load(state: any): void;
72
+ declare function save(): any;
73
+ declare function appendBlock(state: any): void;
74
+ declare function generateCode(): string | undefined;
75
+ declare function generateReactivity(): import("x-runtime-lib").Reactivity;
76
+ declare function fireStateChange(): void;
71
77
  type __VLS_ModelProps = {
72
78
  'lock': boolean;
73
79
  'scale': number;
@@ -79,12 +85,12 @@ type __VLS_Slots = {} & {
79
85
  };
80
86
  declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
81
87
  loading: import("vue").Ref<boolean, boolean>;
82
- load: (state: any) => void;
83
- save: () => any;
84
- appendBlock: (state: any) => void;
85
- generateCode: () => string | undefined;
86
- generateReactivity: () => import("x-runtime-lib").Reactivity;
87
- fireStateChange: () => void;
88
+ load: typeof load;
89
+ save: typeof save;
90
+ appendBlock: typeof appendBlock;
91
+ generateCode: typeof generateCode;
92
+ generateReactivity: typeof generateReactivity;
93
+ fireStateChange: typeof fireStateChange;
88
94
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
89
95
  "update:lock": (value: boolean) => any;
90
96
  "update:scale": (value: number) => any;
@@ -107,11 +113,6 @@ declare const install: (app: App) => void;
107
113
  export declare function loadLocaleMessageBlock(locale: string): Promise<{
108
114
  'x-block-lib': {
109
115
  bind: string;
110
- dlg: {
111
- source: {
112
- title: string;
113
- };
114
- };
115
116
  funcEntry: string;
116
117
  implementMethod: string;
117
118
  msg: {
@@ -120,6 +121,7 @@ export declare function loadLocaleMessageBlock(locale: string): Promise<{
120
121
  navigator: string;
121
122
  noOption: string;
122
123
  procedure: string;
124
+ source: string;
123
125
  temporaryBlock: string;
124
126
  tip: {
125
127
  hotkeyCtrlE: string;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function(){try{document.getElementById(`x-block-lib`)?.remove();const e = document.createElement(`style`);e.setAttribute(`id`, `x-block-lib`);const t = document.createTextNode(`.ghost[data-v-x-block-lib-ca7316a0]{opacity:.4;pointer-events:none}.blocklyToolbox{width:56px;overflow-x:hidden}.blocklyMainBackground{stroke-width:0}.blocklyToolboxCategory{margin-bottom:12px!important}.blocklyToolboxCategoryIcon{display:none!important}.blocklyTreeRowContentContainer{place-items:center;height:28px;display:flex;overflow:hidden}.blocklyFlyout{z-index:21}pre code.hljs{padding:1em;display:block;overflow-x:auto}code.hljs{padding:3px 5px}.hljs{color:#444;background:#f3f3f3}.hljs-comment{color:#697070}.hljs-punctuation,.hljs-tag{color:#444a}.hljs-tag .hljs-attr,.hljs-tag .hljs-name{color:#444}.hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-selector-tag{font-weight:700}.hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type{color:#800}.hljs-section,.hljs-title{color:#800;font-weight:700}.hljs-link,.hljs-operator,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#ab5656}.hljs-literal{color:#695}.hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code{color:#397300}.hljs-meta{color:#1f7199}.hljs-meta .hljs-string{color:#38a}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}`);e.appendChild(t);document.head.appendChild(e);}catch(e){console.error('rolldown-plugin-inject-css', e);}})()
2
- import { A as Names, B as defineBlocksWithJsonArray, C as FieldCheckbox, D as FieldNumber, E as FieldLabel, F as Themes, G as inject$1, H as getMainWorkspace, I as Variables, J as serialization, K as inputs, L as WorkspaceSvg, M as ShortcutItems, N as ShortcutRegistry, O as FieldTextInput, P as Theme, Q as utils, R as Xml, S as Extensions, T as FieldImage, U as getSelected, V as dialog, W as icons, X as setParentContainer, Y as setLocale$1, Z as svgResize, _ as javascriptGenerator, a as lo, b as ContextMenuRegistry, c as encodeString, d as snakeCase, f as parseInt$1, g as Order, h as cloneDeep, i as require_dist$2, j as Procedures, k as Msg, l as require_dist, m as debounce, n as o, o as useResizeObserver, p as isEqual, q as registry, r as core_default, s as require_dist$1, t as javascript, u as upperCase, v as Blocks, w as FieldDropdown, x as Events, y as ContextMenu, z as common } from "./vendor.k3ftbehq.js";
2
+ import { A as Names, B as defineBlocksWithJsonArray, C as FieldCheckbox, D as FieldNumber, E as FieldLabel, F as Themes, G as inject$1, H as getMainWorkspace, I as Variables, J as serialization, K as inputs, L as WorkspaceSvg, M as ShortcutItems, N as ShortcutRegistry, O as FieldTextInput, P as Theme, R as Xml, S as Extensions, T as FieldImage, U as getSelected, V as dialog, W as icons, X as svgResize, Y as setLocale$1, Z as utils, _ as javascriptGenerator, a as lo, b as ContextMenuRegistry, c as encodeString, d as snakeCase, f as parseInt$1, g as Order, h as cloneDeep, i as require_dist$2, j as Procedures, k as Msg, l as require_dist, m as debounce, n as o, o as useResizeObserver, p as isEqual, q as registry, r as core_default, s as require_dist$1, t as javascript, u as upperCase, v as Blocks, w as FieldDropdown, x as Events, y as ContextMenu, z as common } from "./vendor.eb5jfwqa.js";
3
3
  import { eventBus, globalObjects, messageWarning, openConfirmDlg, openPromptDlg, useColor, useSystem, useViewStack } from "x-essential-lib";
4
4
  import { globalState } from "x-state-lib";
5
5
  import { addIndent, finalProperties, getElement, getImplementMethodName, getItems, getTag, getTypes, makeEventId, makeEventKeyOfCustomSlot, makeEventKeyOfElementSlot, makeMethodId, makeMethodKeyOfCustomSlot, makeMethodKeyOfElementSlot, makePropertyId, makePropertyKeyOfCustomSlot, makePropertyKeyOfElementSlot, makeTriggerId, parseNumberUnit, pkgs, themeColors, toEventName, toMethodName, toPropertyName, unwrapEventId, unwrapEventKeyOfCustomSlot, unwrapEventKeyOfElementSlot, unwrapMethodId, unwrapMethodKeyOfCustomSlot, unwrapMethodKeyOfElementSlot, unwrapPropertyId, unwrapPropertyKeyOfCustomSlot, unwrapPropertyKeyOfElementSlot, unwrapSlotId } from "x-runtime-lib";
@@ -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;
@@ -11388,42 +11519,9 @@ WorkspaceSvg.prototype.cleanUp = function() {
11388
11519
  this.setResizesEnabled(true);
11389
11520
  };
11390
11521
 
11391
- //#endregion
11392
- //#region src/core/plugins/disableTopBlocks/index.ts
11393
- var import_dist$1 = require_dist$1();
11394
- function isOrphan(block) {
11395
- const parent = block.getParent();
11396
- if (parent && isOrphan(parent)) return true;
11397
- return !parent && !!(block.outputConnection || block.previousConnection);
11398
- }
11399
- var DisableTopBlocks = class {
11400
- init() {
11401
- const disableMenuItem = ContextMenuRegistry.registry.getItem("blockDisable");
11402
- if (!disableMenuItem) return;
11403
- disableMenuItem.preconditionFn = function(scope) {
11404
- const block = scope.block;
11405
- if (!block) return "hidden";
11406
- if (!block.isInFlyout && block.workspace.options.disable && block.isEditable()) {
11407
- if (block.getInheritedDisabled() || isOrphan(block)) return "disabled";
11408
- return "enabled";
11409
- }
11410
- return "hidden";
11411
- };
11412
- }
11413
- };
11414
-
11415
- //#endregion
11416
- //#region src/core/plugins/index.ts
11417
- (0, import_dist$2.registerFieldColour)();
11418
- ShortcutRegistry.registry.unregister(ShortcutItems.names.ESCAPE);
11419
- new import_dist$1.CrossTabCopyPaste().init({
11420
- contextMenu: true,
11421
- shortcut: true
11422
- });
11423
- new DisableTopBlocks().init();
11424
-
11425
11522
  //#endregion
11426
11523
  //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
11524
+ var import_dist$1 = require_dist$1();
11427
11525
  function _typeof(o) {
11428
11526
  "@babel/helpers - typeof";
11429
11527
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -11464,6 +11562,48 @@ function _defineProperty(e, r, t) {
11464
11562
  }) : e[r] = t, e;
11465
11563
  }
11466
11564
 
11565
+ //#endregion
11566
+ //#region src/core/plugins/disableTopBlocks/index.ts
11567
+ function isOrphan(block) {
11568
+ const parent = block.getParent();
11569
+ if (parent && isOrphan(parent)) return true;
11570
+ return !parent && !!(block.outputConnection || block.previousConnection);
11571
+ }
11572
+ var DisableTopBlocks = class {
11573
+ constructor() {
11574
+ _defineProperty(this, "oldPreconditionFn", void 0);
11575
+ }
11576
+ init() {
11577
+ const disableMenuItem = ContextMenuRegistry.registry.getItem("blockDisable");
11578
+ if (!disableMenuItem) return;
11579
+ this.oldPreconditionFn = disableMenuItem.preconditionFn;
11580
+ disableMenuItem.preconditionFn = function(scope) {
11581
+ const block = scope.block;
11582
+ if (!block) return "hidden";
11583
+ if (!block.isInFlyout && block.workspace.options.disable && block.isEditable()) {
11584
+ if (block.getInheritedDisabled() || isOrphan(block)) return "disabled";
11585
+ return "enabled";
11586
+ }
11587
+ return "hidden";
11588
+ };
11589
+ }
11590
+ dispose() {
11591
+ const disableMenuItem = ContextMenuRegistry.registry.getItem("blockDisable");
11592
+ if (!disableMenuItem) return;
11593
+ disableMenuItem.preconditionFn = this.oldPreconditionFn;
11594
+ }
11595
+ };
11596
+
11597
+ //#endregion
11598
+ //#region src/core/plugins/index.ts
11599
+ (0, import_dist$2.registerFieldColour)();
11600
+ ShortcutRegistry.registry.unregister(ShortcutItems.names.ESCAPE);
11601
+ new import_dist$1.CrossTabCopyPaste().init({
11602
+ contextMenu: true,
11603
+ shortcut: true
11604
+ });
11605
+ new DisableTopBlocks().init();
11606
+
11467
11607
  //#endregion
11468
11608
  //#region src/core/events/index.ts
11469
11609
  var StateChange = class extends Events.Abstract {
@@ -11744,7 +11884,7 @@ var index_vue_vue_type_script_setup_true_lang_default$7 = /*@__PURE__*/ defineCo
11744
11884
  const disabled = computed(() => {
11745
11885
  return display.smAndDown.value;
11746
11886
  });
11747
- const cleanWorkspace = () => {
11887
+ function cleanWorkspace() {
11748
11888
  if (!context.workspace) {
11749
11889
  console.assert(false);
11750
11890
  return;
@@ -11754,10 +11894,10 @@ var index_vue_vue_type_script_setup_true_lang_default$7 = /*@__PURE__*/ defineCo
11754
11894
  return;
11755
11895
  }
11756
11896
  context.workspace.cleanUp();
11757
- };
11758
- const onClick = () => {
11897
+ }
11898
+ function onClick() {
11759
11899
  cleanWorkspace();
11760
- };
11900
+ }
11761
11901
  __expose({ cleanWorkspace });
11762
11902
  return (_ctx, _cache) => {
11763
11903
  const _component_v_btn = resolveComponent("v-btn");
@@ -12582,7 +12722,7 @@ function callback$4() {
12582
12722
  });
12583
12723
  root.push(button);
12584
12724
  }
12585
- const variables = workspace.getVariablesOfType("");
12725
+ const variables = workspace.getVariableMap().getAllVariables();
12586
12726
  if (variables.length <= 0) return root;
12587
12727
  variables.sort(Variables.compareByName);
12588
12728
  {
@@ -13392,7 +13532,7 @@ const jsonToolboxV1 = {
13392
13532
  kind: "categoryToolbox",
13393
13533
  contents: [{
13394
13534
  kind: "category",
13395
- name: "%{BKY_CATEGORY_JSON}",
13535
+ name: "%{BKY_CATEGORY_TYPE}",
13396
13536
  colour: "330",
13397
13537
  contents: [
13398
13538
  {
@@ -13499,15 +13639,18 @@ const options = {
13499
13639
  maxScale: 1,
13500
13640
  minScale: .1,
13501
13641
  scaleSpeed: 1.25,
13502
- startScale: 1,
13503
- wheel: true
13642
+ startScale: 1
13504
13643
  }
13505
13644
  };
13506
13645
  function createWorkspace(container, type, version, dark) {
13507
13646
  options.theme = dark ? "dark" : "light";
13508
13647
  options.toolbox = getToolbox(type, version);
13509
13648
  const workspace = inject$1(container, options);
13649
+ workspace.addChangeListener(Events.disableOrphans);
13510
13650
  workspace.addChangeListener((event) => {
13651
+ setTimeout(() => {
13652
+ (0, import_dist.shadowBlockConversionChangeListener)(event);
13653
+ }, 0);
13511
13654
  if (event.type === "state_change") {
13512
13655
  const blocks = workspace.getAllBlocks();
13513
13656
  for (const block of blocks) {
@@ -13515,9 +13658,6 @@ function createWorkspace(container, type, version, dark) {
13515
13658
  if (b.checkWarning_) b.checkWarning_();
13516
13659
  }
13517
13660
  }
13518
- setTimeout(() => {
13519
- (0, import_dist.shadowBlockConversionChangeListener)(event);
13520
- }, 0);
13521
13661
  });
13522
13662
  regCustomCategory(workspace, type, version);
13523
13663
  regButtonCallback(workspace);
@@ -13641,7 +13781,6 @@ var index_vue_vue_type_script_setup_true_lang_default$2 = /*@__PURE__*/ defineCo
13641
13781
  const emit = __emit;
13642
13782
  const blocklyEditor = `blocklyEditor${useId()}`;
13643
13783
  const blocklyDiv = ref();
13644
- const parentContainer = useTemplateRef("parentContainer");
13645
13784
  const clean = useTemplateRef("clean");
13646
13785
  const navigator = useTemplateRef("navigator");
13647
13786
  const context = {};
@@ -13707,24 +13846,11 @@ var index_vue_vue_type_script_setup_true_lang_default$2 = /*@__PURE__*/ defineCo
13707
13846
  zIndex: 999
13708
13847
  };
13709
13848
  });
13710
- const parentContStyle = computed(() => {
13711
- return {
13712
- position: "fixed",
13713
- top: 0,
13714
- left: 0,
13715
- zIndex: 3e3
13716
- };
13717
- });
13718
13849
  const { open: flyoutOpen } = useViewStack(`blocklyEditorFlyout${useId()}`);
13719
13850
  onMounted(async () => {
13720
- if (!blocklyDiv.value || !parentContainer.value) {
13721
- console.assert(false);
13722
- return;
13723
- }
13724
- setParentContainer(parentContainer.value);
13851
+ if (!blocklyDiv.value) throw new Error(`invalid blocklyDiv`);
13725
13852
  await setLocale(__props.locale);
13726
13853
  context.workspace = createWorkspace(blocklyDiv.value, __props.type, __props.version, __props.dark);
13727
- context.workspace.addChangeListener(Events.disableOrphans);
13728
13854
  context.workspace.addChangeListener(onChange);
13729
13855
  const flyoutDiv = document.querySelector(`#${blocklyEditor} .blocklyFlyout`);
13730
13856
  new MutationObserver((mutations) => {
@@ -13766,45 +13892,45 @@ var index_vue_vue_type_script_setup_true_lang_default$2 = /*@__PURE__*/ defineCo
13766
13892
  navigator.value?.update();
13767
13893
  }, 0);
13768
13894
  }
13769
- const load = (state) => {
13895
+ function load(state) {
13770
13896
  loading.value = true;
13771
13897
  if (__props.type === "json") loadFromJson(state, context.workspace);
13772
13898
  else serialization.workspaces.load(state, context.workspace);
13773
- };
13774
- const save = () => {
13899
+ }
13900
+ function save() {
13775
13901
  if (__props.type === "json") return saveToJson(context.workspace);
13776
13902
  else return serialization.workspaces.save(context.workspace);
13777
- };
13778
- const appendBlock = (state) => {
13903
+ }
13904
+ function appendBlock(state) {
13779
13905
  serialization.blocks.append(state, context.workspace);
13780
- };
13781
- const generateCode = () => {
13906
+ }
13907
+ function generateCode() {
13782
13908
  if (__props.type === "json") console.assert(false);
13783
13909
  else return javascriptGenerator.workspaceToCode(context.workspace);
13784
- };
13785
- const generateReactivity = () => {
13910
+ }
13911
+ function generateReactivity() {
13786
13912
  return buildReactivity(context.workspace);
13787
- };
13788
- const applyLock = () => {
13913
+ }
13914
+ function applyLock() {
13789
13915
  context.workspace.setIsReadOnly(lock.value);
13790
13916
  if (context.workspace.isReadOnly()) flyoutOpen.value = false;
13791
- };
13792
- const applyScale = () => {
13917
+ }
13918
+ function applyScale() {
13793
13919
  context.workspace.setScale(scale.value);
13794
- };
13795
- const fireStateChange = () => {
13920
+ }
13921
+ function fireStateChange() {
13796
13922
  Events.fire(new (Events.get("state_change"))(context.workspace));
13797
- };
13798
- const onCleanWorkspace = () => {
13923
+ }
13924
+ function onCleanWorkspace() {
13799
13925
  clean.value?.cleanWorkspace();
13800
- };
13801
- const onToggleBlocklyLock = () => {
13926
+ }
13927
+ function onToggleBlocklyLock() {
13802
13928
  lock.value = !lock.value;
13803
- };
13804
- const onOpenBlocklyNavigator = () => {
13929
+ }
13930
+ function onOpenBlocklyNavigator() {
13805
13931
  if (!navigator.value) return;
13806
13932
  navigator.value.open = true;
13807
- };
13933
+ }
13808
13934
  onMounted(() => {
13809
13935
  eventBus.on("cleanWorkspace", onCleanWorkspace);
13810
13936
  eventBus.on("toggleBlocklyLock", onToggleBlocklyLock);
@@ -13887,11 +14013,6 @@ var index_vue_vue_type_script_setup_true_lang_default$2 = /*@__PURE__*/ defineCo
13887
14013
  key: 3,
13888
14014
  style: normalizeStyle(mainMaskStyle.value)
13889
14015
  }, null, 4)) : createCommentVNode("v-if", true),
13890
- createElementVNode("div", {
13891
- ref_key: "parentContainer",
13892
- ref: parentContainer,
13893
- style: normalizeStyle(parentContStyle.value)
13894
- }, null, 4),
13895
14016
  createVNode(_component_x_loading, {
13896
14017
  open: loading.value,
13897
14018
  "z-index": 99
@@ -13998,7 +14119,7 @@ var index_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComp
13998
14119
  variant: "text",
13999
14120
  onClick: _cache[0] || (_cache[0] = ($event) => open.value = false)
14000
14121
  }),
14001
- createElementVNode("span", _hoisted_1, toDisplayString(unref(t)("x-block-lib.dlg.source.title")), 1),
14122
+ createElementVNode("span", _hoisted_1, toDisplayString(unref(t)("x-block-lib.source")), 1),
14002
14123
  createVNode(_component_v_spacer)
14003
14124
  ]),
14004
14125
  _: 1
@@ -14027,8 +14148,8 @@ const install = (app) => {
14027
14148
  //#endregion
14028
14149
  //#region src/i18n/index.ts
14029
14150
  async function loadLocaleMessageBlock(locale) {
14030
- if (locale === "en") return (await import("./i18n-en.c3uxu3r5.js").then((n) => n.t)).default;
14031
- else if (locale === "zhHans") return (await import("./i18n-zhHans.hyv14btt.js").then((n) => n.t)).default;
14151
+ if (locale === "en") return (await import("./i18n-en.o4ueycrn.js").then((n) => n.t)).default;
14152
+ else if (locale === "zhHans") return (await import("./i18n-zhHans.b2uuecq7.js").then((n) => n.t)).default;
14032
14153
  else throw new Error(`invalid locale=${locale}`);
14033
14154
  }
14034
14155
 
@@ -36959,4 +36959,4 @@ function javascript(hljs) {
36959
36959
  }
36960
36960
 
36961
36961
  //#endregion
36962
- export { Names as A, defineBlocksWithJsonArray as B, FieldCheckbox as C, FieldNumber as D, FieldLabel as E, Themes as F, inject$1 as G, getMainWorkspace as H, Variables as I, serialization as J, inputs as K, WorkspaceSvg as L, ShortcutItems as M, ShortcutRegistry as N, FieldTextInput as O, Theme as P, utils as Q, Xml as R, Extensions as S, FieldImage as T, getSelected as U, dialog as V, icons as W, setParentContainer as X, setLocale as Y, svgResize as Z, javascriptGenerator as _, lo as a, ContextMenuRegistry as b, encodeString as c, snakeCase as d, parseInt$1 as f, Order as g, cloneDeep as h, require_dist as i, Procedures as j, Msg as k, require_dist$2 as l, debounce as m, o as n, useResizeObserver as o, isEqual as p, registry as q, core_default as r, require_dist$1 as s, javascript as t, upperCase as u, Blocks as v, FieldDropdown as w, Events as x, ContextMenu as y, common as z };
36962
+ export { Names as A, defineBlocksWithJsonArray as B, FieldCheckbox as C, FieldNumber as D, FieldLabel as E, Themes as F, inject$1 as G, getMainWorkspace as H, Variables as I, serialization as J, inputs as K, WorkspaceSvg as L, ShortcutItems as M, ShortcutRegistry as N, FieldTextInput as O, Theme as P, Xml as R, Extensions as S, FieldImage as T, getSelected as U, dialog as V, icons as W, svgResize as X, setLocale as Y, utils as Z, javascriptGenerator as _, lo as a, ContextMenuRegistry as b, encodeString as c, snakeCase as d, parseInt$1 as f, Order as g, cloneDeep as h, require_dist as i, Procedures as j, Msg as k, require_dist$2 as l, debounce as m, o as n, useResizeObserver as o, isEqual as p, registry as q, core_default as r, require_dist$1 as s, javascript as t, upperCase as u, Blocks as v, FieldDropdown as w, Events as x, ContextMenu as y, common as z };
@@ -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.8",
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
  }