@absolutejs/absolute 0.19.0-beta.148 → 0.19.0-beta.149

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.
@@ -205,10 +205,40 @@ export const handleVueUpdate = (message: {
205
205
  // Vue's rerender only swaps the template, not the setup closure.
206
206
  if (message.data.forceReload && (window as any).__VUE_HMR_RUNTIME__) {
207
207
  const hmrRuntime = (window as any).__VUE_HMR_RUNTIME__;
208
- // Find the component's hmrId from the imported module
209
208
  const component = mod?.default ?? Object.values(mod ?? {})[0];
210
209
  if (component?.__hmrId) {
211
210
  hmrRuntime.reload(component.__hmrId, component);
211
+
212
+ // Restore preserved ref values into the new component instance.
213
+ // Only restores refs that exist in both old and new state with
214
+ // matching types. Skips functions and computed to avoid stale closures.
215
+ if (
216
+ window.__VUE_APP__?._instance &&
217
+ Object.keys(vuePreservedState).length > 0
218
+ ) {
219
+ try {
220
+ const inst = window.__VUE_APP__._instance;
221
+ const ss = inst.setupState;
222
+ if (ss) {
223
+ for (const key of Object.keys(vuePreservedState)) {
224
+ const newVal = ss[key];
225
+ const oldVal = vuePreservedState[key];
226
+ // Only restore into refs (objects with .value)
227
+ // and only if types match
228
+ if (
229
+ newVal &&
230
+ typeof newVal === 'object' &&
231
+ 'value' in newVal &&
232
+ typeof newVal.value === typeof oldVal
233
+ ) {
234
+ newVal.value = oldVal;
235
+ }
236
+ }
237
+ }
238
+ } catch {
239
+ // State shape mismatch — let it reset naturally
240
+ }
241
+ }
212
242
  }
213
243
  }
214
244
  sessionStorage.removeItem('__HMR_ACTIVE__');
package/package.json CHANGED
@@ -164,5 +164,5 @@
164
164
  "typecheck": "bun run vue-tsc --noEmit"
165
165
  },
166
166
  "types": "./dist/src/index.d.ts",
167
- "version": "0.19.0-beta.148"
167
+ "version": "0.19.0-beta.149"
168
168
  }