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

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.4.0",
3
+ "version": "1.4.1",
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",
@@ -158,12 +158,7 @@ export default {
158
158
  // Load componentStats from parent
159
159
  getParentLocalStorage('componentStats').then((data) => {
160
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 {}
161
+ this.loadParentComponentStats(data)
167
162
  }
168
163
  })
169
164
  }
@@ -182,11 +177,32 @@ export default {
182
177
  sendToParent({ type: 'setRocketMode', value: restore })
183
178
  }
184
179
  },
185
- handleBack() {
180
+ findPreviousPage() {
181
+ return this.sortedItems.find(item => item.name !== this.trackPageName)
182
+ },
183
+ loadParentComponentStats(data) {
184
+ try {
185
+ const parsed = typeof data === 'string' ? JSON.parse(data) : data
186
+ if (parsed?.pages) {
187
+ this.localStorageItems = Object.values(parsed.pages)
188
+ }
189
+ } catch {}
190
+ },
191
+ async handleBack() {
186
192
  if (this.backEvent) return this.backEvent()
187
193
 
188
194
  // Navigate to the last visited page that isn't the current one
189
- const previousPage = this.sortedItems.find(item => item.name !== this.$props.trackPageName)
195
+ let previousPage = this.findPreviousPage()
196
+
197
+ // If history not loaded yet, try fetching from parent
198
+ if (!previousPage && isInIframe()) {
199
+ const data = await getParentLocalStorage('componentStats')
200
+ if (data) {
201
+ this.loadParentComponentStats(data)
202
+ previousPage = this.findPreviousPage()
203
+ }
204
+ }
205
+
190
206
  if (previousPage) {
191
207
  this.restoreRocketMode()
192
208
  sendToParent({ type: 'navigate', path: previousPage.path })
@@ -265,11 +265,25 @@ const restoreRocketMode = () => {
265
265
  }
266
266
  }
267
267
 
268
- const handleBack = () => {
268
+ const findPreviousPage = () => {
269
+ return sortedItems.value.find(item => item.name !== props.trackPageName)
270
+ }
271
+
272
+ const handleBack = async () => {
269
273
  if (props.backEvent) return props.backEvent()
270
274
 
271
275
  // Navigate to the last visited page that isn't the current one
272
- const previousPage = sortedItems.value.find(item => item.name !== props.trackPageName)
276
+ let previousPage = findPreviousPage()
277
+
278
+ // If history not loaded yet, try fetching from parent
279
+ if (!previousPage && isInIframe()) {
280
+ const data = await getParentLocalStorage('componentStats')
281
+ if (data) {
282
+ loadComponentStats(data)
283
+ previousPage = findPreviousPage()
284
+ }
285
+ }
286
+
273
287
  if (previousPage) {
274
288
  restoreRocketMode()
275
289
  sendToParent({ type: 'navigate', path: previousPage.path })