@absolutejs/absolute 0.19.0-beta.97 → 0.19.0-beta.99

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.
@@ -67,16 +67,7 @@ const applyRefreshImport = (
67
67
  const clientStart = performance.now();
68
68
  import(`${moduleUrl}?t=${Date.now()}`)
69
69
  .then(() => {
70
- const result = refreshRuntime.performReactRefresh();
71
-
72
- // If no components were refreshed (data file HMR), force a
73
- // re-render. The mutable store (globalThis.__HMR_DATA__) has
74
- // fresh values — components just need to re-execute their
75
- // render functions to read them.
76
- if (!result) {
77
- forceReactRerender();
78
- }
79
-
70
+ refreshRuntime.performReactRefresh();
80
71
  sendTiming(clientStart, serverDuration);
81
72
 
82
73
  return undefined;
@@ -90,18 +81,6 @@ const applyRefreshImport = (
90
81
  });
91
82
  };
92
83
 
93
- // Force React to re-render the entire tree. Components read from
94
- // the mutable HMR data store (destructured at render time via
95
- // rewriteDataImports), so re-rendering picks up fresh values.
96
- const forceReactRerender = () => {
97
- const boundary = window.__ERROR_BOUNDARY__ as
98
- | { hmrUpdate?: () => void }
99
- | undefined;
100
- if (boundary?.hmrUpdate) {
101
- boundary.hmrUpdate();
102
- }
103
- };
104
-
105
84
  const reloadReactCSS = (cssPath: string) => {
106
85
  const existingCSSLinks = document.head.querySelectorAll<HTMLLinkElement>(
107
86
  'link[rel="stylesheet"]'
package/dist/index.js CHANGED
@@ -278,9 +278,6 @@ var indexContentCache, resolveDevClientDir = () => {
278
278
  ` reset() {`,
279
279
  ` this.setState({ hasError: false });`,
280
280
  ` }`,
281
- ` hmrUpdate() {`,
282
- ` this.forceUpdate();`,
283
- ` }`,
284
281
  ` render() {`,
285
282
  ` if (this.state.hasError) return null;`,
286
283
  ``,
@@ -202328,8 +202325,6 @@ var init_pageHandler = __esm(() => {
202328
202325
  var exports_transformCache = {};
202329
202326
  __export(exports_transformCache, {
202330
202327
  setTransformed: () => setTransformed,
202331
- markAsDataFile: () => markAsDataFile,
202332
- isDataFile: () => isDataFile,
202333
202328
  invalidateAll: () => invalidateAll,
202334
202329
  invalidate: () => invalidate,
202335
202330
  getTransformed: () => getTransformed,
@@ -202357,9 +202352,7 @@ var globalStore, cache, importers, getTransformed = (filePath) => cache.get(file
202357
202352
  }, invalidateAll = () => {
202358
202353
  cache.clear();
202359
202354
  importers.clear();
202360
- }, dataFiles, markAsDataFile = (filePath) => {
202361
- dataFiles.add(filePath);
202362
- }, isDataFile = (filePath) => dataFiles.has(filePath), findNearestComponent = (filePath) => {
202355
+ }, findNearestComponent = (filePath) => {
202363
202356
  const visited = new Set;
202364
202357
  const queue = [filePath];
202365
202358
  while (queue.length > 0) {
@@ -202387,8 +202380,6 @@ var init_transformCache = __esm(() => {
202387
202380
  globalStore.__transformImporters = importers;
202388
202381
  invalidationVersions = globalStore.__transformInvalidationVersions ?? new Map;
202389
202382
  globalStore.__transformInvalidationVersions = invalidationVersions;
202390
- dataFiles = globalStore.__transformDataFiles ?? new Set;
202391
- globalStore.__transformDataFiles = dataFiles;
202392
202383
  });
202393
202384
 
202394
202385
  // src/dev/moduleServer.ts
@@ -202532,20 +202523,6 @@ ${stubs}
202532
202523
  return _match;
202533
202524
  });
202534
202525
  return result;
202535
- }, NAMED_IMPORT_RE, rewriteDataImports = (code, projectRoot) => {
202536
- let counter = 0;
202537
- return code.replace(NAMED_IMPORT_RE, (_match, names, q1, srcUrl2, q2) => {
202538
- const urlPath = srcUrl2.replace(/^\/\@src\//, "").split("?")[0];
202539
- if (!urlPath)
202540
- return _match;
202541
- const absPath = resolve18(projectRoot, urlPath);
202542
- if (!isDataFile(absPath))
202543
- return _match;
202544
- const alias = `__hmr_${counter++}`;
202545
- const trimmedNames = names.trim();
202546
- return `import ${alias} from ${q1}${srcUrl2}${q2};
202547
- const { ${trimmedNames} } = ${alias}`;
202548
- });
202549
202526
  }, HOOK_NAMES, REFRESH_PREAMBLE, JSX_AUTO_RE, JSXS_AUTO_RE, JSX_PROD_RE, FRAGMENT_RE, addJsxImport = (code) => {
202550
202527
  const imports = [];
202551
202528
  const jsxDevMatch = JSX_AUTO_RE.exec(code);
@@ -202583,34 +202560,7 @@ const { ${trimmedNames} } = ${alias}`;
202583
202560
  ` + transpiled;
202584
202561
  const relPath = relative7(projectRoot, filePath).replace(/\\/g, "/");
202585
202562
  transpiled = transpiled.replace(/\binput\.tsx:/g, `${relPath}:`);
202586
- let result = rewriteImports2(transpiled, filePath, projectRoot, rewriter);
202587
- result = rewriteDataImports(result, projectRoot);
202588
- return result;
202589
- }, isDataOnlyFile = (exports, transpiled) => {
202590
- if (exports.length === 0)
202591
- return false;
202592
- if (exports.some((e) => /^[A-Z]/.test(e) && /^(use|[A-Z])/.test(e)))
202593
- return false;
202594
- if (/export\s+(function|class|async\s+function)\s/.test(transpiled))
202595
- return false;
202596
- return true;
202597
- }, wrapDataExports = (transpiled, filePath, exports) => {
202598
- const storeKey = filePath.replace(/\\/g, "/");
202599
- let result = transpiled;
202600
- const preamble = `const __hmr = ((globalThis.__HMR_DATA__ ??= {})[${JSON.stringify(storeKey)}] ??= {});
202601
- `;
202602
- for (const name of exports) {
202603
- result = result.replace(new RegExp(`export\\s+const\\s+${name}\\s*=`), `__hmr.${name} =`);
202604
- result = result.replace(new RegExp(`export\\s+var\\s+${name}\\s*=`), `__hmr.${name} =`);
202605
- result = result.replace(new RegExp(`export\\s+let\\s+${name}\\s*=`), `__hmr.${name} =`);
202606
- }
202607
- const defaultExport = `
202608
- export default __hmr;
202609
- `;
202610
- const namedExports = exports.map((name) => `export const ${name} = __hmr.${name};`).join(`
202611
- `);
202612
- return preamble + result + `
202613
- ` + namedExports + defaultExport;
202563
+ return rewriteImports2(transpiled, filePath, projectRoot, rewriter);
202614
202564
  }, transformPlainFile = (filePath, projectRoot, rewriter) => {
202615
202565
  const raw = readFileSync9(filePath, "utf-8");
202616
202566
  const ext = extname3(filePath);
@@ -202622,13 +202572,7 @@ export default __hmr;
202622
202572
  if (isTS) {
202623
202573
  transpiled = preserveTypeExports(raw, transpiled, valueExports);
202624
202574
  }
202625
- if (isTS && !isTSX && isDataOnlyFile(valueExports, transpiled)) {
202626
- transpiled = wrapDataExports(transpiled, filePath, valueExports);
202627
- markAsDataFile(filePath);
202628
- }
202629
- let result = rewriteImports2(transpiled, filePath, projectRoot, rewriter);
202630
- result = rewriteDataImports(result, projectRoot);
202631
- return result;
202575
+ return rewriteImports2(transpiled, filePath, projectRoot, rewriter);
202632
202576
  }, svelteExternalCss, svelteCompiler = null, vueCompiler = null, warmCompilers = async (frameworks) => {
202633
202577
  const [sc, vc] = await Promise.all([
202634
202578
  frameworks.svelte ? import("svelte/compiler") : undefined,
@@ -202770,12 +202714,16 @@ ${code}`;
202770
202714
  if (existsSync13(`${path}.js`))
202771
202715
  return `${path}.js`;
202772
202716
  return path;
202773
- }, jsResponse = (body) => new Response(body, {
202774
- headers: {
202775
- "Cache-Control": "no-cache",
202776
- "Content-Type": "application/javascript"
202777
- }
202778
- }), handleCssRequest = (filePath) => {
202717
+ }, jsResponse = (body) => {
202718
+ const etag = `"${Bun.hash(body).toString(36)}"`;
202719
+ return new Response(body, {
202720
+ headers: {
202721
+ "Cache-Control": "no-cache",
202722
+ "Content-Type": "application/javascript",
202723
+ ETag: etag
202724
+ }
202725
+ });
202726
+ }, handleCssRequest = (filePath) => {
202779
202727
  const raw = readFileSync9(filePath, "utf-8");
202780
202728
  const escaped = raw.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
202781
202729
  return [
@@ -203006,7 +202954,6 @@ var init_moduleServer = __esm(() => {
203006
202954
  STRING_CONTENTS_RE = /`(?:[^`\\]|\\.)*`|'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/gs;
203007
202955
  REACT_EXTENSIONS = new Set([".tsx", ".jsx"]);
203008
202956
  mtimeCache = new Map;
203009
- NAMED_IMPORT_RE = /import\s*\{([^}]+)\}\s*from\s*(["'])(\/\@src\/[^"']+)(["']);?/g;
203010
202957
  HOOK_NAMES = new Set([
203011
202958
  "useState",
203012
202959
  "useReducer",
@@ -205020,8 +204967,19 @@ var STORE_KEY = "__elysiaStore", getGlobalValue = (key) => Reflect.get(globalThi
205020
204967
  const pathname = rawUrl.slice(pathStart, pathEnd);
205021
204968
  if (moduleServerHandler) {
205022
204969
  const moduleResponse = await moduleServerHandler(pathname);
205023
- if (moduleResponse)
204970
+ if (moduleResponse) {
204971
+ const etag = moduleResponse.headers.get("ETag");
204972
+ if (etag) {
204973
+ const ifNoneMatch = request.headers.get("If-None-Match");
204974
+ if (ifNoneMatch === etag) {
204975
+ return new Response(null, {
204976
+ headers: { ETag: etag },
204977
+ status: 304
204978
+ });
204979
+ }
204980
+ }
205024
204981
  return moduleResponse;
204982
+ }
205025
204983
  }
205026
204984
  const bytes = lookupAsset(hmrState2.assetStore, pathname);
205027
204985
  if (!bytes) {
@@ -205365,5 +205323,5 @@ export {
205365
205323
  ANGULAR_INIT_TIMEOUT_MS
205366
205324
  };
205367
205325
 
205368
- //# debugId=961251AD68B6490564756E2164756E21
205326
+ //# debugId=8B0D6BD8707201AE64756E2164756E21
205369
205327
  //# sourceMappingURL=index.js.map