@absolutejs/absolute 0.19.0-beta.154 → 0.19.0-beta.155

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/dist/build.js CHANGED
@@ -171721,6 +171721,86 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171721
171721
  writeFileSync3(outputPath, content);
171722
171722
  }
171723
171723
  }
171724
+ if (hmr && vueDirectory) {
171725
+ const vueOutputs = nonReactClientOutputs.map((a) => a.path).filter((p) => p.includes("/vue/"));
171726
+ for (const outputPath of vueOutputs) {
171727
+ let content = readFileSync5(outputPath, "utf-8");
171728
+ const usePattern = /^var\s+(use[A-Z]\w*)\s*=/gm;
171729
+ const useNames = [];
171730
+ let m;
171731
+ while ((m = usePattern.exec(content)) !== null) {
171732
+ if (m[1])
171733
+ useNames.push(m[1]);
171734
+ }
171735
+ if (useNames.length === 0)
171736
+ continue;
171737
+ let runtimeId = JSON.stringify(outputPath);
171738
+ const firstUseName = useNames[0];
171739
+ const commentPattern = new RegExp(`\\/\\/\\s*(src\\/[^\\n]*\\.js)\\s*\\n[^]*?var\\s+${firstUseName}\\s*=`);
171740
+ const srcMatch = commentPattern.exec(content);
171741
+ if (srcMatch?.[1]) {
171742
+ const srcPath = resolve10(projectRoot, srcMatch[1].replace("/client/", "/").replace(/\.js$/, ".ts"));
171743
+ runtimeId = JSON.stringify(srcPath);
171744
+ }
171745
+ const runtime = [
171746
+ `var __hmr_cs=(globalThis.__HMR_COMPOSABLE_STATE__??={});`,
171747
+ `var __hmr_mid=${runtimeId};`,
171748
+ `var __hmr_prev_refs=__hmr_cs[__hmr_mid];`,
171749
+ `var __hmr_idx={};`,
171750
+ `__hmr_cs[__hmr_mid]={};`,
171751
+ `function __hmr_wrap(n,fn){return function(){`,
171752
+ `var i=(__hmr_idx[n]=(__hmr_idx[n]??-1)+1);`,
171753
+ `var r=fn.apply(this,arguments);`,
171754
+ `if(r&&typeof r==="object"){`,
171755
+ `var refs={};for(var k in r){var v=r[k];`,
171756
+ `if(v&&typeof v==="object"&&"value"in v&&!v.effect&&typeof v.value!=="function")refs[k]=v;}`,
171757
+ `(__hmr_cs[__hmr_mid][n]??=[])[i]=refs;`,
171758
+ `if(__hmr_prev_refs&&__hmr_prev_refs[n]&&__hmr_prev_refs[n][i]){`,
171759
+ `var old=__hmr_prev_refs[n][i];`,
171760
+ `for(var k in old){var nv=r[k],ov=old[k];`,
171761
+ `if(nv&&ov&&typeof nv==="object"&&"value"in nv&&!nv.effect&&typeof nv.value===typeof ov.value)nv.value=ov.value;}`,
171762
+ `}}return r;};}`
171763
+ ].join("");
171764
+ const firstUseIdx = content.indexOf(`var ${useNames[0]} =`);
171765
+ if (firstUseIdx === -1)
171766
+ continue;
171767
+ content = content.slice(0, firstUseIdx) + runtime + `
171768
+ ` + content.slice(firstUseIdx);
171769
+ for (const name of useNames) {
171770
+ const marker = `var ${name} = `;
171771
+ const pos = content.indexOf(marker);
171772
+ if (pos === -1)
171773
+ continue;
171774
+ const afterMarker = pos + marker.length;
171775
+ let depth = 0;
171776
+ let inStr = false;
171777
+ let endPos = afterMarker;
171778
+ for (let i = afterMarker;i < content.length; i++) {
171779
+ const ch = content[i];
171780
+ if (inStr) {
171781
+ if (ch === inStr && content[i - 1] !== "\\")
171782
+ inStr = false;
171783
+ continue;
171784
+ }
171785
+ if (ch === '"' || ch === "'" || ch === "`") {
171786
+ inStr = ch;
171787
+ continue;
171788
+ }
171789
+ if (ch === "{" || ch === "(")
171790
+ depth++;
171791
+ if (ch === "}" || ch === ")")
171792
+ depth--;
171793
+ if (depth === 0 && ch === ";") {
171794
+ endPos = i;
171795
+ break;
171796
+ }
171797
+ }
171798
+ const funcBody = content.slice(afterMarker, endPos);
171799
+ content = content.slice(0, afterMarker) + `__hmr_wrap(${JSON.stringify(name)}, ${funcBody})` + content.slice(endPos);
171800
+ }
171801
+ writeFileSync3(outputPath, content);
171802
+ }
171803
+ }
171724
171804
  const allLogs = [
171725
171805
  ...serverLogs,
171726
171806
  ...reactClientLogs,
@@ -205172,5 +205252,5 @@ export {
205172
205252
  build
205173
205253
  };
205174
205254
 
205175
- //# debugId=3ABFF28C4EC11D9964756E2164756E21
205255
+ //# debugId=FD07AFEFC0D2D2FA64756E2164756E21
205176
205256
  //# sourceMappingURL=build.js.map