@absolutejs/absolute 0.19.0-beta.150 → 0.19.0-beta.151
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/.absolutejs/tsconfig.tsbuildinfo +1 -1
- package/dist/build.js +57 -4
- package/dist/build.js.map +3 -3
- package/dist/dev/client/handlers/vue.ts +0 -30
- package/dist/index.js +57 -4
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
|
@@ -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,59 @@ ${stubs}
|
|
|
202733
202733
|
if (isTS) {
|
|
202734
202734
|
transpiled = preserveTypeExports(raw, transpiled, valueExports);
|
|
202735
202735
|
}
|
|
202736
|
-
|
|
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 exportPattern = new RegExp(`(export\\s+var\\s+${name}\\s*=\\s*)`, "g");
|
|
202784
|
+
result = result.replace(exportPattern, `$1__hmr_wrap(${JSON.stringify(name)}, `);
|
|
202785
|
+
const closingPattern = new RegExp(`(export\\s+var\\s+${name}\\s*=\\s*__hmr_wrap\\([^)]+,\\s*)([\\s\\S]*?)(;\\s*(?:export\\s|$))`, "");
|
|
202786
|
+
result = result.replace(closingPattern, `$1$2)$3`);
|
|
202787
|
+
}
|
|
202788
|
+
return result;
|
|
202737
202789
|
}, svelteExternalCss, svelteCompiler = null, vueCompiler = null, warmCompilers = async (frameworks) => {
|
|
202738
202790
|
const [sc, vc] = await Promise.all([
|
|
202739
202791
|
frameworks.svelte ? import("svelte/compiler") : undefined,
|
|
@@ -203060,7 +203112,8 @@ export default {};
|
|
|
203060
203112
|
if (cached)
|
|
203061
203113
|
return jsResponse(cached);
|
|
203062
203114
|
const stat2 = statSync2(filePath);
|
|
203063
|
-
const
|
|
203115
|
+
const vueDir = frameworkDirs?.vue ? resolve18(frameworkDirs.vue) : undefined;
|
|
203116
|
+
const content = REACT_EXTENSIONS.has(ext) ? transformReactFile(filePath, projectRoot, rewriter) : transformPlainFile(filePath, projectRoot, rewriter, vueDir);
|
|
203064
203117
|
setTransformed(filePath, content, stat2.mtimeMs, extractImportedFiles(content, projectRoot));
|
|
203065
203118
|
return jsResponse(content);
|
|
203066
203119
|
} catch (err) {
|
|
@@ -205754,5 +205807,5 @@ export {
|
|
|
205754
205807
|
ANGULAR_INIT_TIMEOUT_MS
|
|
205755
205808
|
};
|
|
205756
205809
|
|
|
205757
|
-
//# debugId=
|
|
205810
|
+
//# debugId=BA74A87B2B45F5CB64756E2164756E21
|
|
205758
205811
|
//# sourceMappingURL=index.js.map
|