@extscreen/es-core 2.2.46 → 2.2.48

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.
Files changed (2) hide show
  1. package/dist/index.js +70 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2590,6 +2590,8 @@ var ESBroadcastModule$1 = new ESBroadcastModule();
2590
2590
 
2591
2591
  class ESBroadcastManager {
2592
2592
 
2593
+ __broadcastReceiverSet = new Map();
2594
+
2593
2595
  init() {
2594
2596
  return Promise.resolve();
2595
2597
  }
@@ -2599,14 +2601,39 @@ class ESBroadcastManager {
2599
2601
  }
2600
2602
 
2601
2603
  registerReceiver(receiver, paramsArray) {
2602
- if (receiver && receiver.broadcastReceiverActionArray) {
2603
- receiver.broadcastReceiverActionArray.push(...paramsArray);
2604
+ let has = this.__broadcastReceiverSet.has(paramsArray);
2605
+ if (has) {
2606
+ return Promise.resolve();
2604
2607
  }
2605
- return ESBroadcastModule$1.registerReceiver(paramsArray);
2608
+ return ESBroadcastModule$1.registerReceiver(paramsArray)
2609
+ .then((receiverId) => {
2610
+ if (receiverId >= 0) {
2611
+ if (receiver && receiver.__registerReceiver) {
2612
+ receiver.__registerReceiver(paramsArray, receiverId);
2613
+ }
2614
+ this.__broadcastReceiverSet.set(paramsArray, receiverId);
2615
+ return Promise.resolve();
2616
+ }
2617
+ return Promise.reject();
2618
+ });
2606
2619
  }
2607
2620
 
2608
- unregisterReceiver(receiverId) {
2609
- return ESBroadcastModule$1.unregisterReceiver(receiverId);
2621
+ unregisterReceiver(receiver, paramsArray) {
2622
+ let receiverId = this.__broadcastReceiverSet.get(paramsArray);
2623
+ if (receiverId < 0) {
2624
+ return Promise.reject();
2625
+ }
2626
+ return ESBroadcastModule$1.unregisterReceiver(receiverId)
2627
+ .then((receiverId) => {
2628
+ if (receiverId >= 0) {
2629
+ if (receiver && receiver.__unregisterReceiver) {
2630
+ receiver.__unregisterReceiver(paramsArray);
2631
+ }
2632
+ this.__broadcastReceiverSet.delete(paramsArray);
2633
+ return Promise.resolve();
2634
+ }
2635
+ return Promise.reject();
2636
+ });
2610
2637
  }
2611
2638
  }
2612
2639
 
@@ -2620,33 +2647,60 @@ var ESBroadcast = {
2620
2647
  },
2621
2648
  data() {
2622
2649
  return {
2623
- broadcastReceiverActionArray: [],
2650
+ broadcastReceiverSet: new Map()
2624
2651
  }
2625
2652
  },
2626
2653
  beforeDestroy() {
2627
2654
  ESApp.$off('onESBroadcastReceive', this.__onBroadcastReceive);
2628
2655
  },
2629
2656
  methods: {
2657
+ __registerReceiver(paramsArray, receiverId) {
2658
+ this.broadcastReceiverSet.set(paramsArray, receiverId);
2659
+ this.__traceBroadcastReceiverList();
2660
+ },
2661
+ __unregisterReceiver(paramsArray) {
2662
+ this.broadcastReceiverSet.delete(paramsArray);
2663
+ this.__traceBroadcastReceiverList();
2664
+ },
2665
+ __traceBroadcastReceiverList() {
2666
+ if (this.broadcastReceiverSet) {
2667
+ this.broadcastReceiverSet.forEach(function (value, key) {
2668
+ if (ESLog.isLoggable(ESLog.DEBUG)) {
2669
+ ESLog.d(TAG$6, key + '#-------TraceAction--->>>>>' + value);
2670
+ }
2671
+ });
2672
+ }
2673
+ },
2630
2674
  __onBroadcastReceive(intent) {
2631
2675
  if (ESLog.isLoggable(ESLog.DEBUG)) {
2632
2676
  ESLog.d(TAG$6, '#-------onBroadcastReceive----->>>>>' + JSON.stringify(intent));
2633
2677
  }
2634
- if (!this.broadcastReceiverActionArray
2635
- || this.broadcastReceiverActionArray.length <= 0) {
2678
+ if (!this.broadcastReceiverSet || this.broadcastReceiverSet.size <= 0) {
2636
2679
  if (ESLog.isLoggable(ESLog.DEBUG)) {
2637
- ESLog.d(TAG$6, '#-------onBroadcastReceive---broadcastReceiverActionArray为空-->>>>>');
2680
+ ESLog.d(TAG$6, '#-------onBroadcastReceive---broadcastReceiverSet为空-->>>>>');
2638
2681
  }
2639
2682
  return;
2640
2683
  }
2641
-
2684
+ //
2685
+ else {
2686
+ if (ESLog.isLoggable(ESLog.DEBUG)) {
2687
+ ESLog.d(TAG$6, '#-------onBroadcastReceive---broadcastReceiverSet不为空-->>>>>');
2688
+ }
2689
+ }
2642
2690
  let action = intent.action;
2643
2691
  let enable = false;
2644
- for (let i = 0; i < this.broadcastReceiverActionArray.length; i++) {
2645
- let ba = this.broadcastReceiverActionArray[i];
2646
- if (ba === action) {
2647
- enable = true;
2692
+
2693
+ this.broadcastReceiverSet.forEach(function (value, key) {
2694
+ if (key && key.length > 0) {
2695
+ for (let i = 0; i < key.length; i++) {
2696
+ let ba = key[i];
2697
+ if (ba === action) {
2698
+ enable = true;
2699
+ }
2700
+ }
2648
2701
  }
2649
- }
2702
+ });
2703
+
2650
2704
  if (!enable) {
2651
2705
  if (ESLog.isLoggable(ESLog.DEBUG)) {
2652
2706
  ESLog.d(TAG$6, '#-------onBroadcastReceive---disable-->>>>>');
@@ -3135,7 +3189,6 @@ var ESPage = {
3135
3189
  onESRestoreInstanceState(savedInstanceState) {
3136
3190
 
3137
3191
  },
3138
-
3139
3192
  //--------------------------------------------
3140
3193
  startNativePage(intent) {
3141
3194
  ESLaunchManager$1.launchNativePage(intent);
@@ -3149,6 +3202,7 @@ var ESPage = {
3149
3202
  startAfterFinishESPage(intent) {
3150
3203
  ESLaunchManager$1.startAfterFinishESPage(intent);
3151
3204
  },
3205
+ //--------------------------------------------
3152
3206
  },
3153
3207
  };
3154
3208
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extscreen/es-core",
3
- "version": "2.2.46",
3
+ "version": "2.2.48",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {