@skyservice-developers/vue-dev-kit 1.3.5 → 1.3.6

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyservice-developers/vue-dev-kit",
3
- "version": "1.3.5",
3
+ "version": "1.3.6",
4
4
  "description": "Vue 2 and Vue 3 developer toolkit - components and helpers",
5
5
  "type": "module",
6
6
  "main": "./dist/vue3/vue-dev-kit.cjs",
@@ -71,6 +71,7 @@
71
71
 
72
72
  <script>
73
73
  import { isInIframe } from '../../shared/utils/webviewCheck'
74
+ import { getParentLocalStorage, sendToParent, setSenderId, getSenderId } from '../../shared/utils/parentBridge'
74
75
 
75
76
  export default {
76
77
  name: 'Header',
@@ -106,11 +107,16 @@ export default {
106
107
  visitLabel: {
107
108
  type: String,
108
109
  default: 'Останнє відвідування'
110
+ },
111
+ appId: {
112
+ type: String,
113
+ default: ''
109
114
  }
110
115
  },
111
116
  data() {
112
117
  return {
113
- isDropdownOpen: false
118
+ isDropdownOpen: false,
119
+ previousRocketMode: null
114
120
  }
115
121
  },
116
122
  computed: {
@@ -121,17 +127,34 @@ export default {
121
127
  return this.backEvent || (this.showBackButton && isInIframe())
122
128
  }
123
129
  },
130
+ created() {
131
+ setSenderId(this.appId || getSenderId())
132
+ if (isInIframe()) {
133
+ getParentLocalStorage('rocketMode').then((value) => {
134
+ this.previousRocketMode = value
135
+ sendToParent({ type: 'setRocketMode', value: true })
136
+ })
137
+ }
138
+ },
124
139
  mounted() {
125
140
  document.addEventListener('click', this.handleClickOutside, true)
126
141
  },
127
142
  beforeDestroy() {
128
143
  document.removeEventListener('click', this.handleClickOutside, true)
144
+ this.restoreRocketMode()
129
145
  },
130
146
  methods: {
147
+ restoreRocketMode() {
148
+ if (isInIframe() && this.previousRocketMode !== null) {
149
+ const restore = this.previousRocketMode === 'true'
150
+ sendToParent({ type: 'setRocketMode', value: restore })
151
+ }
152
+ },
131
153
  handleBack() {
132
154
  if (this.backEvent) return this.backEvent()
133
155
 
134
- window.parent.postMessage({ type: 'exit' }, '*')
156
+ this.restoreRocketMode()
157
+ sendToParent({ type: 'exit' })
135
158
  },
136
159
  toggleDropdown() {
137
160
  if (this.sortedItems.length) {
@@ -160,10 +160,7 @@ if (isInIframe()) {
160
160
  }
161
161
 
162
162
  onUnmounted(() => {
163
- if (isInIframe() && previousRocketMode.value !== null) {
164
- const restore = previousRocketMode.value === 'true'
165
- sendToParent({ type: 'setRocketMode', value: restore })
166
- }
163
+ restoreRocketMode()
167
164
  })
168
165
 
169
166
  // Load translations from parent
@@ -261,9 +258,17 @@ const shouldShowBackButton = computed(() => {
261
258
  return props.backEvent || (props.showBackButton && isInIframe());
262
259
  });
263
260
 
261
+ const restoreRocketMode = () => {
262
+ if (previousRocketMode.value !== null) {
263
+ const restore = previousRocketMode.value === 'true'
264
+ sendToParent({ type: 'setRocketMode', value: restore })
265
+ }
266
+ }
267
+
264
268
  const handleBack = () => {
265
269
  if (props.backEvent) return props.backEvent()
266
270
 
271
+ restoreRocketMode()
267
272
  sendToParent({ type: 'exit' })
268
273
  }
269
274
  </script>