@absolutejs/absolute 0.19.0-beta.150 → 0.19.0-beta.152

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.
@@ -208,36 +208,6 @@ export const handleVueUpdate = (message: {
208
208
  const component = mod?.default ?? Object.values(mod ?? {})[0];
209
209
  if (component?.__hmrId) {
210
210
  hmrRuntime.reload(component.__hmrId, component);
211
-
212
- // Restore preserved ref values after Vue re-renders.
213
- // reload() schedules an async unmount/remount, so we
214
- // wait for the next animation frame when the new
215
- // instance is fully mounted with its setupState.
216
- if (Object.keys(vuePreservedState).length > 0) {
217
- requestAnimationFrame(() => {
218
- try {
219
- const inst = window.__VUE_APP__?._instance;
220
- const ss = inst?.setupState;
221
- if (!ss) return;
222
- for (const key of Object.keys(vuePreservedState)) {
223
- const newVal = ss[key];
224
- const oldVal = vuePreservedState[key];
225
- // Only restore into refs (objects with .value)
226
- // and only if types match
227
- if (
228
- newVal &&
229
- typeof newVal === 'object' &&
230
- 'value' in newVal &&
231
- typeof newVal.value === typeof oldVal
232
- ) {
233
- newVal.value = oldVal;
234
- }
235
- }
236
- } catch {
237
- // State shape mismatch — let it reset naturally
238
- }
239
- });
240
- }
241
211
  }
242
212
  }
243
213
  sessionStorage.removeItem('__HMR_ACTIVE__');
package/dist/index.js CHANGED
@@ -202722,7 +202722,7 @@ ${stubs}
202722
202722
  const relPath = relative8(projectRoot, filePath).replace(/\\/g, "/");
202723
202723
  transpiled = transpiled.replace(/\binput\.tsx:/g, `${relPath}:`);
202724
202724
  return rewriteImports2(transpiled, filePath, projectRoot, rewriter);
202725
- }, transformPlainFile = (filePath, projectRoot, rewriter) => {
202725
+ }, transformPlainFile = (filePath, projectRoot, rewriter, vueDir) => {
202726
202726
  const raw = readFileSync9(filePath, "utf-8");
202727
202727
  const ext = extname3(filePath);
202728
202728
  const isTS = ext === ".ts" || ext === ".tsx";
@@ -202733,7 +202733,85 @@ ${stubs}
202733
202733
  if (isTS) {
202734
202734
  transpiled = preserveTypeExports(raw, transpiled, valueExports);
202735
202735
  }
202736
- return rewriteImports2(transpiled, filePath, projectRoot, rewriter);
202736
+ transpiled = rewriteImports2(transpiled, filePath, projectRoot, rewriter);
202737
+ if (vueDir && filePath.startsWith(vueDir) && isTS) {
202738
+ const useExports = valueExports.filter((e) => e.startsWith("use"));
202739
+ if (useExports.length > 0) {
202740
+ transpiled = injectComposableTracking(transpiled, filePath, useExports);
202741
+ }
202742
+ }
202743
+ return transpiled;
202744
+ }, injectComposableTracking = (code, filePath, useExports) => {
202745
+ const moduleId = JSON.stringify(filePath);
202746
+ const runtime = [
202747
+ `var __hmr_cs = (globalThis.__HMR_COMPOSABLE_STATE__ ??= {});`,
202748
+ `var __hmr_mid = ${moduleId};`,
202749
+ `var __hmr_prev = __hmr_cs[__hmr_mid];`,
202750
+ `var __hmr_idx = {};`,
202751
+ `__hmr_cs[__hmr_mid] = {};`,
202752
+ `function __hmr_wrap(name, fn) {`,
202753
+ ` return function() {`,
202754
+ ` var idx = (__hmr_idx[name] = (__hmr_idx[name] ?? -1) + 1);`,
202755
+ ` var result = fn.apply(this, arguments);`,
202756
+ ` if (result && typeof result === "object") {`,
202757
+ ` var snap = {};`,
202758
+ ` for (var k in result) {`,
202759
+ ` var v = result[k];`,
202760
+ ` if (v && typeof v === "object" && "value" in v && typeof v.value !== "function") {`,
202761
+ ` snap[k] = v.value;`,
202762
+ ` }`,
202763
+ ` }`,
202764
+ ` (__hmr_cs[__hmr_mid][name] ??= [])[idx] = snap;`,
202765
+ ` if (__hmr_prev && __hmr_prev[name] && __hmr_prev[name][idx]) {`,
202766
+ ` var old = __hmr_prev[name][idx];`,
202767
+ ` for (var k in old) {`,
202768
+ ` var nv = result[k];`,
202769
+ ` if (nv && typeof nv === "object" && "value" in nv && typeof nv.value === typeof old[k]) {`,
202770
+ ` nv.value = old[k];`,
202771
+ ` }`,
202772
+ ` }`,
202773
+ ` }`,
202774
+ ` }`,
202775
+ ` return result;`,
202776
+ ` };`,
202777
+ `}`
202778
+ ].join(`
202779
+ `);
202780
+ let result = runtime + `
202781
+ ` + code;
202782
+ for (const name of useExports) {
202783
+ const marker = new RegExp(`export\\s+(?:const|var|let)\\s+${name}\\s*=\\s*`);
202784
+ const match = marker.exec(result);
202785
+ if (!match)
202786
+ continue;
202787
+ const insertPos = match.index + match[0].length;
202788
+ let depth = 0;
202789
+ let inString = false;
202790
+ let endPos = insertPos;
202791
+ for (let i = insertPos;i < result.length; i++) {
202792
+ const ch = result[i];
202793
+ if (inString) {
202794
+ if (ch === inString && result[i - 1] !== "\\")
202795
+ inString = false;
202796
+ continue;
202797
+ }
202798
+ if (ch === '"' || ch === "'" || ch === "`") {
202799
+ inString = ch;
202800
+ continue;
202801
+ }
202802
+ if (ch === "{" || ch === "(")
202803
+ depth++;
202804
+ if (ch === "}" || ch === ")")
202805
+ depth--;
202806
+ if (depth === 0 && ch === ";") {
202807
+ endPos = i;
202808
+ break;
202809
+ }
202810
+ }
202811
+ const funcBody = result.slice(insertPos, endPos);
202812
+ result = result.slice(0, insertPos) + `__hmr_wrap(${JSON.stringify(name)}, ${funcBody})` + result.slice(endPos);
202813
+ }
202814
+ return result;
202737
202815
  }, svelteExternalCss, svelteCompiler = null, vueCompiler = null, warmCompilers = async (frameworks) => {
202738
202816
  const [sc, vc] = await Promise.all([
202739
202817
  frameworks.svelte ? import("svelte/compiler") : undefined,
@@ -203060,7 +203138,8 @@ export default {};
203060
203138
  if (cached)
203061
203139
  return jsResponse(cached);
203062
203140
  const stat2 = statSync2(filePath);
203063
- const content = REACT_EXTENSIONS.has(ext) ? transformReactFile(filePath, projectRoot, rewriter) : transformPlainFile(filePath, projectRoot, rewriter);
203141
+ const vueDir = frameworkDirs?.vue ? resolve18(frameworkDirs.vue) : undefined;
203142
+ const content = REACT_EXTENSIONS.has(ext) ? transformReactFile(filePath, projectRoot, rewriter) : transformPlainFile(filePath, projectRoot, rewriter, vueDir);
203064
203143
  setTransformed(filePath, content, stat2.mtimeMs, extractImportedFiles(content, projectRoot));
203065
203144
  return jsResponse(content);
203066
203145
  } catch (err) {
@@ -205754,5 +205833,5 @@ export {
205754
205833
  ANGULAR_INIT_TIMEOUT_MS
205755
205834
  };
205756
205835
 
205757
- //# debugId=AEAC9DD46352BA7B64756E2164756E21
205836
+ //# debugId=4644DA352AFC957E64756E2164756E21
205758
205837
  //# sourceMappingURL=index.js.map