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

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,91 @@ 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
+ if (firstUseName) {
171740
+ const varIdx = content.indexOf(`var ${firstUseName} =`);
171741
+ if (varIdx > 0) {
171742
+ const before = content.slice(0, varIdx);
171743
+ const commentMatch = before.match(/\/\/\s*(src\/[^\n]*\.js)\s*\n[^/]*$/);
171744
+ if (commentMatch?.[1]) {
171745
+ const srcPath = resolve10(projectRoot, commentMatch[1].replace("/client/", "/").replace(/\.js$/, ".ts"));
171746
+ runtimeId = JSON.stringify(srcPath);
171747
+ }
171748
+ }
171749
+ }
171750
+ const runtime = [
171751
+ `var __hmr_cs=(globalThis.__HMR_COMPOSABLE_STATE__??={});`,
171752
+ `var __hmr_mid=${runtimeId};`,
171753
+ `var __hmr_prev_refs=__hmr_cs[__hmr_mid];`,
171754
+ `var __hmr_idx={};`,
171755
+ `__hmr_cs[__hmr_mid]={};`,
171756
+ `function __hmr_wrap(n,fn){return function(){`,
171757
+ `var i=(__hmr_idx[n]=(__hmr_idx[n]??-1)+1);`,
171758
+ `var r=fn.apply(this,arguments);`,
171759
+ `if(r&&typeof r==="object"){`,
171760
+ `var refs={};for(var k in r){var v=r[k];`,
171761
+ `if(v&&typeof v==="object"&&"value"in v&&!v.effect&&typeof v.value!=="function")refs[k]=v;}`,
171762
+ `(__hmr_cs[__hmr_mid][n]??=[])[i]=refs;`,
171763
+ `if(__hmr_prev_refs&&__hmr_prev_refs[n]&&__hmr_prev_refs[n][i]){`,
171764
+ `var old=__hmr_prev_refs[n][i];`,
171765
+ `for(var k in old){var nv=r[k],ov=old[k];`,
171766
+ `if(nv&&ov&&typeof nv==="object"&&"value"in nv&&!nv.effect&&typeof nv.value===typeof ov.value)nv.value=ov.value;}`,
171767
+ `}}return r;};}`
171768
+ ].join("");
171769
+ const firstUseIdx = content.indexOf(`var ${useNames[0]} =`);
171770
+ if (firstUseIdx === -1)
171771
+ continue;
171772
+ content = content.slice(0, firstUseIdx) + runtime + `
171773
+ ` + content.slice(firstUseIdx);
171774
+ for (const name of useNames) {
171775
+ const marker = `var ${name} = `;
171776
+ const pos = content.indexOf(marker);
171777
+ if (pos === -1)
171778
+ continue;
171779
+ const afterMarker = pos + marker.length;
171780
+ let depth = 0;
171781
+ let inStr = false;
171782
+ let endPos = afterMarker;
171783
+ for (let i = afterMarker;i < content.length; i++) {
171784
+ const ch = content[i];
171785
+ if (inStr) {
171786
+ if (ch === inStr && content[i - 1] !== "\\")
171787
+ inStr = false;
171788
+ continue;
171789
+ }
171790
+ if (ch === '"' || ch === "'" || ch === "`") {
171791
+ inStr = ch;
171792
+ continue;
171793
+ }
171794
+ if (ch === "{" || ch === "(")
171795
+ depth++;
171796
+ if (ch === "}" || ch === ")")
171797
+ depth--;
171798
+ if (depth === 0 && ch === ";") {
171799
+ endPos = i;
171800
+ break;
171801
+ }
171802
+ }
171803
+ const funcBody = content.slice(afterMarker, endPos);
171804
+ content = content.slice(0, afterMarker) + `__hmr_wrap(${JSON.stringify(name)}, ${funcBody})` + content.slice(endPos);
171805
+ }
171806
+ writeFileSync3(outputPath, content);
171807
+ }
171808
+ }
171724
171809
  const allLogs = [
171725
171810
  ...serverLogs,
171726
171811
  ...reactClientLogs,
@@ -205172,5 +205257,5 @@ export {
205172
205257
  build
205173
205258
  };
205174
205259
 
205175
- //# debugId=3ABFF28C4EC11D9964756E2164756E21
205260
+ //# debugId=D8F0DB0810AF6A7564756E2164756E21
205176
205261
  //# sourceMappingURL=build.js.map