x-block-lib 0.9.20 → 0.9.22

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 +1,42 @@
1
+ import * as Blockly from 'blockly/core';
2
+ import { PropertyKind } from 'x-runtime-lib';
3
+ type GetAppPropertyV1Type = typeof GET_APP_PROPERTY_V1;
4
+ interface GetAppPropertyV1 extends GetAppPropertyV1Type {
5
+ node: {
6
+ id: string;
7
+ key: string;
8
+ alias: string;
9
+ };
10
+ property: {
11
+ id: string;
12
+ kind: PropertyKind | '';
13
+ names: string[];
14
+ };
15
+ }
16
+ export type GetAppPropertyBlockV1 = Blockly.Block & GetAppPropertyV1;
17
+ declare const GET_APP_PROPERTY_V1: {
18
+ init: (this: GetAppPropertyBlockV1) => void;
19
+ initData_: (this: GetAppPropertyBlockV1) => void;
20
+ saveExtraState: (this: GetAppPropertyBlockV1) => {
21
+ node: {
22
+ id: string;
23
+ key: string;
24
+ alias: string;
25
+ };
26
+ property: {
27
+ id: string;
28
+ kind: PropertyKind | "";
29
+ names: string[];
30
+ };
31
+ };
32
+ loadExtraState: (this: GetAppPropertyBlockV1, state: any) => void;
33
+ genNodeOpts_: (this: GetAppPropertyBlockV1) => Blockly.MenuOption[];
34
+ genPropertyOpts_: (this: GetAppPropertyBlockV1) => Blockly.MenuOption[];
35
+ onchange: (this: GetAppPropertyBlockV1, event: Blockly.Events.Abstract) => void;
36
+ onNodeChange_: (this: GetAppPropertyBlockV1, value: string) => void;
37
+ onPropertyChange_: (this: GetAppPropertyBlockV1, value: string) => void;
38
+ updateShape_: (this: GetAppPropertyBlockV1) => void;
39
+ updateShadow_: (this: GetAppPropertyBlockV1) => void;
40
+ checkWarning_: (this: GetAppPropertyBlockV1) => void;
41
+ };
1
42
  export {};
@@ -1 +1,28 @@
1
+ import * as Blockly from 'blockly/core';
2
+ import { Type } from 'x-essential-lib';
3
+ type GetAppStateV1Type = typeof GET_APP_STATE_V1;
4
+ interface GetAppStateV1 extends GetAppStateV1Type {
5
+ state: {
6
+ id: string;
7
+ name: string;
8
+ type: Type;
9
+ };
10
+ }
11
+ export type GetAppStateBlockV1 = Blockly.Block & GetAppStateV1;
12
+ declare const GET_APP_STATE_V1: {
13
+ init: (this: GetAppStateBlockV1) => void;
14
+ initData_: (this: GetAppStateBlockV1) => void;
15
+ saveExtraState: (this: GetAppStateBlockV1) => {
16
+ state: {
17
+ id: string;
18
+ name: string;
19
+ type: Type;
20
+ };
21
+ };
22
+ loadExtraState: (this: GetAppStateBlockV1, state: any) => void;
23
+ genStateOpts_: (this: GetAppStateBlockV1) => Blockly.MenuOption[];
24
+ onchange: (this: GetAppStateBlockV1, event: Blockly.Events.Abstract) => void;
25
+ onStateChange_: (this: GetAppStateBlockV1, value: string) => void;
26
+ checkWarning_: (this: GetAppStateBlockV1) => void;
27
+ };
1
28
  export {};
package/dist/index.js CHANGED
@@ -2491,7 +2491,7 @@ ${addIndent(S, 2)} } catch (e) {
2491
2491
  tooltip: "%{BKY_APP_V1_WATCH_EFFECT_TOOLTIP}",
2492
2492
  helpUrl: "%{BKY_APP_V1_WATCH_EFFECT_HELPURL}"
2493
2493
  }]), javascriptGenerator.forBlock.watch_effect_v1 = function(e) {
2494
- return `function __watchEffect$${encodeString(e.id)}__() {
2494
+ return `async function __watchEffect$${encodeString(e.id)}__() {
2495
2495
  ${javascriptGenerator.statementToCode(e, "HANDLE")}};
2496
2496
  `;
2497
2497
  }, defineBlocksWithJsonArray([{
@@ -8649,44 +8649,31 @@ function setTheme(e) {
8649
8649
  break;
8650
8650
  }
8651
8651
  }
8652
- var reactivity_types = ["get_app_property_v1", "get_app_state_v1"];
8653
8652
  function addUnique(e, y) {
8654
- return e.find((e) => e === y) === void 0 ? (e.push(y), !0) : !1;
8653
+ e.find((e) => e === y) || e.push(y);
8655
8654
  }
8655
+ var watchEffectTypes = ["get_app_property_v1", "get_app_state_v1"];
8656
8656
  function gatherWatchEffectBlocks(e) {
8657
8657
  let y = [];
8658
8658
  function b(e) {
8659
- for (let x of e.getChildren(!0)) reactivity_types.includes(x.type) && y.push(x), b(x);
8659
+ for (let x of e.getChildren(!0)) watchEffectTypes.includes(x.type) && y.push(x), b(x);
8660
8660
  }
8661
8661
  return b(e), y;
8662
8662
  }
8663
8663
  function makeWatchEffectBlocks(e) {
8664
8664
  let y = [];
8665
- for (let b of e) if (b.type === "get_app_property_v1") {
8666
- let e = b;
8667
- addUnique(y, makeTriggerId({
8668
- type: "elementProperty",
8669
- nodeId: e.node.id,
8670
- propertyKeys: e.property.key
8671
- }));
8672
- } else b.type === "get_app_state_v1" ? addUnique(y, makeTriggerId({
8673
- type: "state",
8674
- stateId: b.state.id
8675
- })) : console.assert(!1);
8665
+ for (let b of e) b.type === "get_app_property_v1" ? addUnique(y, makeTriggerId("propertyTrigger", b.property.id)) : b.type === "get_app_state_v1" ? addUnique(y, makeTriggerId("stateTrigger", b.state.id)) : console.assert(!1);
8676
8666
  return y;
8677
8667
  }
8678
- function gatherAppBindBlocks(e) {
8668
+ function makeAppBindBlocks(e) {
8679
8669
  let y = [];
8680
- for (let b of e.getChildren(!0)) if (reactivity_types.includes(b.type)) y.push(b);
8681
- else if (b.type === "object_get_v1") {
8682
- let e = b.getInputTargetBlock("OBJECT");
8683
- e && reactivity_types.includes(e.type) && y.push(b);
8670
+ for (let b of e) {
8671
+ if (b.type !== "app_bind_entry_v1") continue;
8672
+ let e = b;
8673
+ e.bindType === "property" ? addUnique(y, makeTriggerId("propertyTrigger", e.property.id)) : e.bindType === "state" ? addUnique(y, makeTriggerId("stateTrigger", e.state.id)) : console.assert(!1);
8684
8674
  }
8685
8675
  return y;
8686
8676
  }
8687
- function makeAppBindBlocks(e) {
8688
- return console.assert(!!e), [];
8689
- }
8690
8677
  function buildReactivity(e) {
8691
8678
  let y = {
8692
8679
  watchEffect: {},
@@ -8700,12 +8687,9 @@ function buildReactivity(e) {
8700
8687
  let b = makeWatchEffectBlocks(gatherWatchEffectBlocks(e));
8701
8688
  for (let x of b) y.watchEffect[x] || (y.watchEffect[x] = []), addUnique(y.watchEffect[x], e.id);
8702
8689
  } else if (e.type === "app_bind_v1") {
8703
- let b = makeAppBindBlocks(gatherAppBindBlocks(e));
8690
+ let b = makeAppBindBlocks(e.getChildren(!0));
8704
8691
  y.bind.sets[e.id] = b;
8705
- for (let x of b) {
8706
- let b = makeTriggerId(x);
8707
- y.bind.triggers[b] || (y.bind.triggers[b] = []), addUnique(y.bind.triggers[b], e.id);
8708
- }
8692
+ for (let x of b) y.bind.triggers[x] || (y.bind.triggers[x] = []), addUnique(y.bind.triggers[x], e.id);
8709
8693
  }
8710
8694
  return y;
8711
8695
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "x-block-lib",
3
3
  "private": false,
4
- "version": "0.9.20",
4
+ "version": "0.9.22",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",