@skyservice-developers/vue-dev-kit 1.3.9 → 1.4.0

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.9",
3
+ "version": "1.4.0",
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",
@@ -108,6 +108,14 @@ export default {
108
108
  type: String,
109
109
  default: 'Останнє відвідування'
110
110
  },
111
+ trackPageName: {
112
+ type: String,
113
+ default: ''
114
+ },
115
+ trackPagePath: {
116
+ type: String,
117
+ default: ''
118
+ },
111
119
  appId: {
112
120
  type: String,
113
121
  default: ''
@@ -116,12 +124,14 @@ export default {
116
124
  data() {
117
125
  return {
118
126
  isDropdownOpen: false,
119
- previousRocketMode: null
127
+ previousRocketMode: null,
128
+ localStorageItems: []
120
129
  }
121
130
  },
122
131
  computed: {
123
132
  sortedItems() {
124
- return [...this.dropdownItems].sort((a, b) => b.lastVisit - a.lastVisit)
133
+ const items = this.dropdownItems.length ? this.dropdownItems : this.localStorageItems
134
+ return [...items].sort((a, b) => b.lastVisit - a.lastVisit)
125
135
  },
126
136
  shouldShowBackButton() {
127
137
  return this.backEvent || (this.showBackButton && isInIframe())
@@ -130,10 +140,32 @@ export default {
130
140
  created() {
131
141
  setSenderId(this.appId || getSenderId())
132
142
  if (isInIframe()) {
143
+ // Track page visit
144
+ if (this.trackPageName) {
145
+ sendToParent({
146
+ type: 'trackVisit',
147
+ name: this.trackPageName,
148
+ path: this.trackPagePath || `/${this.trackPageName}`,
149
+ })
150
+ }
151
+
152
+ // Set rocketMode
133
153
  getParentLocalStorage('rocketMode').then((value) => {
134
154
  this.previousRocketMode = value
135
155
  sendToParent({ type: 'setRocketMode', value: true })
136
156
  })
157
+
158
+ // Load componentStats from parent
159
+ getParentLocalStorage('componentStats').then((data) => {
160
+ if (data != null) {
161
+ try {
162
+ const parsed = typeof data === 'string' ? JSON.parse(data) : data
163
+ if (parsed?.pages) {
164
+ this.localStorageItems = Object.values(parsed.pages)
165
+ }
166
+ } catch {}
167
+ }
168
+ })
137
169
  }
138
170
  },
139
171
  mounted() {
@@ -153,6 +185,14 @@ export default {
153
185
  handleBack() {
154
186
  if (this.backEvent) return this.backEvent()
155
187
 
188
+ // Navigate to the last visited page that isn't the current one
189
+ const previousPage = this.sortedItems.find(item => item.name !== this.$props.trackPageName)
190
+ if (previousPage) {
191
+ this.restoreRocketMode()
192
+ sendToParent({ type: 'navigate', path: previousPage.path })
193
+ return
194
+ }
195
+
156
196
  this.restoreRocketMode()
157
197
  sendToParent({ type: 'exit' })
158
198
  },
@@ -166,6 +206,9 @@ export default {
166
206
  },
167
207
  selectItem(item) {
168
208
  this.$emit('navigate', item.path)
209
+ if (isInIframe()) {
210
+ sendToParent({ type: 'navigate', path: item.path })
211
+ }
169
212
  this.closeDropdown()
170
213
  },
171
214
  capitalize(str) {
@@ -268,6 +268,14 @@ const restoreRocketMode = () => {
268
268
  const handleBack = () => {
269
269
  if (props.backEvent) return props.backEvent()
270
270
 
271
+ // Navigate to the last visited page that isn't the current one
272
+ const previousPage = sortedItems.value.find(item => item.name !== props.trackPageName)
273
+ if (previousPage) {
274
+ restoreRocketMode()
275
+ sendToParent({ type: 'navigate', path: previousPage.path })
276
+ return
277
+ }
278
+
271
279
  restoreRocketMode()
272
280
  sendToParent({ type: 'exit' })
273
281
  }