@aerobuilt/core 0.2.7 → 0.2.8

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.
Files changed (2) hide show
  1. package/dist/entry-dev.js +17 -3
  2. package/package.json +2 -2
package/dist/entry-dev.js CHANGED
@@ -15,6 +15,7 @@ function extractDocumentParts(html) {
15
15
  const body = doc.body?.innerHTML ?? html;
16
16
  return { head, body };
17
17
  }
18
+ var rendering = false;
18
19
  var PERSISTENT_SELECTORS = [
19
20
  'script[src*="/@vite/client"]',
20
21
  "[data-vite-dev-id]"
@@ -44,17 +45,30 @@ function updateHead(headContent) {
44
45
  headEl.appendChild(document.importNode(node, true));
45
46
  }
46
47
  }
48
+ var DOCS_PATH_PREFIX = "/docs";
47
49
  async function renderPage(appEl, renderFn) {
48
- const pageName = resolvePageName(window.location.pathname);
50
+ if (rendering) return;
51
+ rendering = true;
52
+ const pathname = window.location.pathname;
53
+ const pageName = resolvePageName(pathname);
49
54
  try {
50
- const html = await renderFn(pageName);
55
+ let html;
56
+ const useFetch = typeof window !== "undefined" && (pathname === DOCS_PATH_PREFIX || pathname.startsWith(DOCS_PATH_PREFIX + "/")) && import.meta.hot;
57
+ if (useFetch) {
58
+ const res = await fetch(pathname, { headers: { Accept: "text/html" } });
59
+ if (!res.ok) throw new Error(`Fetch failed: ${res.status}`);
60
+ html = await res.text();
61
+ } else {
62
+ html = await renderFn(pageName);
63
+ }
51
64
  const { head, body } = extractDocumentParts(html);
52
65
  if (head) updateHead(head);
53
66
  appEl.innerHTML = body;
54
- console.log(`[aero] Rendered: ${pageName}`);
55
67
  } catch (err) {
56
68
  appEl.innerHTML = `<h1>Error rendering page: ${pageName}</h1><pre>${String(err)}</pre>`;
57
69
  console.error("[aero] Render Error:", err);
70
+ } finally {
71
+ rendering = false;
58
72
  }
59
73
  }
60
74
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aerobuilt/core",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Jamie Wilson",
@@ -55,7 +55,7 @@
55
55
  "sharp": "^0.34.5",
56
56
  "svgo": "^4.0.0",
57
57
  "vite-plugin-image-optimizer": "^2.0.3",
58
- "@aerobuilt/interpolation": "0.2.7"
58
+ "@aerobuilt/interpolation": "0.2.8"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "vite": "^8.0.0-0"