@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/index.js CHANGED
@@ -171800,6 +171800,91 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171800
171800
  writeFileSync3(outputPath, content);
171801
171801
  }
171802
171802
  }
171803
+ if (hmr && vueDirectory) {
171804
+ const vueOutputs = nonReactClientOutputs.map((a) => a.path).filter((p) => p.includes("/vue/"));
171805
+ for (const outputPath of vueOutputs) {
171806
+ let content = readFileSync5(outputPath, "utf-8");
171807
+ const usePattern = /^var\s+(use[A-Z]\w*)\s*=/gm;
171808
+ const useNames = [];
171809
+ let m;
171810
+ while ((m = usePattern.exec(content)) !== null) {
171811
+ if (m[1])
171812
+ useNames.push(m[1]);
171813
+ }
171814
+ if (useNames.length === 0)
171815
+ continue;
171816
+ let runtimeId = JSON.stringify(outputPath);
171817
+ const firstUseName = useNames[0];
171818
+ if (firstUseName) {
171819
+ const varIdx = content.indexOf(`var ${firstUseName} =`);
171820
+ if (varIdx > 0) {
171821
+ const before = content.slice(0, varIdx);
171822
+ const commentMatch = before.match(/\/\/\s*(src\/[^\n]*\.js)\s*\n[^/]*$/);
171823
+ if (commentMatch?.[1]) {
171824
+ const srcPath = resolve11(projectRoot, commentMatch[1].replace("/client/", "/").replace(/\.js$/, ".ts"));
171825
+ runtimeId = JSON.stringify(srcPath);
171826
+ }
171827
+ }
171828
+ }
171829
+ const runtime = [
171830
+ `var __hmr_cs=(globalThis.__HMR_COMPOSABLE_STATE__??={});`,
171831
+ `var __hmr_mid=${runtimeId};`,
171832
+ `var __hmr_prev_refs=__hmr_cs[__hmr_mid];`,
171833
+ `var __hmr_idx={};`,
171834
+ `__hmr_cs[__hmr_mid]={};`,
171835
+ `function __hmr_wrap(n,fn){return function(){`,
171836
+ `var i=(__hmr_idx[n]=(__hmr_idx[n]??-1)+1);`,
171837
+ `var r=fn.apply(this,arguments);`,
171838
+ `if(r&&typeof r==="object"){`,
171839
+ `var refs={};for(var k in r){var v=r[k];`,
171840
+ `if(v&&typeof v==="object"&&"value"in v&&!v.effect&&typeof v.value!=="function")refs[k]=v;}`,
171841
+ `(__hmr_cs[__hmr_mid][n]??=[])[i]=refs;`,
171842
+ `if(__hmr_prev_refs&&__hmr_prev_refs[n]&&__hmr_prev_refs[n][i]){`,
171843
+ `var old=__hmr_prev_refs[n][i];`,
171844
+ `for(var k in old){var nv=r[k],ov=old[k];`,
171845
+ `if(nv&&ov&&typeof nv==="object"&&"value"in nv&&!nv.effect&&typeof nv.value===typeof ov.value)nv.value=ov.value;}`,
171846
+ `}}return r;};}`
171847
+ ].join("");
171848
+ const firstUseIdx = content.indexOf(`var ${useNames[0]} =`);
171849
+ if (firstUseIdx === -1)
171850
+ continue;
171851
+ content = content.slice(0, firstUseIdx) + runtime + `
171852
+ ` + content.slice(firstUseIdx);
171853
+ for (const name of useNames) {
171854
+ const marker = `var ${name} = `;
171855
+ const pos = content.indexOf(marker);
171856
+ if (pos === -1)
171857
+ continue;
171858
+ const afterMarker = pos + marker.length;
171859
+ let depth = 0;
171860
+ let inStr = false;
171861
+ let endPos = afterMarker;
171862
+ for (let i = afterMarker;i < content.length; i++) {
171863
+ const ch = content[i];
171864
+ if (inStr) {
171865
+ if (ch === inStr && content[i - 1] !== "\\")
171866
+ inStr = false;
171867
+ continue;
171868
+ }
171869
+ if (ch === '"' || ch === "'" || ch === "`") {
171870
+ inStr = ch;
171871
+ continue;
171872
+ }
171873
+ if (ch === "{" || ch === "(")
171874
+ depth++;
171875
+ if (ch === "}" || ch === ")")
171876
+ depth--;
171877
+ if (depth === 0 && ch === ";") {
171878
+ endPos = i;
171879
+ break;
171880
+ }
171881
+ }
171882
+ const funcBody = content.slice(afterMarker, endPos);
171883
+ content = content.slice(0, afterMarker) + `__hmr_wrap(${JSON.stringify(name)}, ${funcBody})` + content.slice(endPos);
171884
+ }
171885
+ writeFileSync3(outputPath, content);
171886
+ }
171887
+ }
171803
171888
  const allLogs = [
171804
171889
  ...serverLogs,
171805
171890
  ...reactClientLogs,
@@ -205834,5 +205919,5 @@ export {
205834
205919
  ANGULAR_INIT_TIMEOUT_MS
205835
205920
  };
205836
205921
 
205837
- //# debugId=CEF3BEB6DC7B1BFE64756E2164756E21
205922
+ //# debugId=EF82615725380F1B64756E2164756E21
205838
205923
  //# sourceMappingURL=index.js.map