@elurjs/kit 2.4.8 → 2.4.9

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/CHANGELOG.md CHANGED
@@ -5,6 +5,17 @@ All notable changes to Elur Kit are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.4.9]
9
+
10
+ ### Fixed
11
+
12
+ - **Revert dynamic hydrator import** — 2.4.8 split the hydrator into a
13
+ separate chunk via dynamic `import()`, but the `elur:rendered` event
14
+ listener was registered inside the async function, so SPA navigations
15
+ fired before the listener was attached. Islands never re-hydrated
16
+ after navigation, causing broken pages and double-click issues.
17
+ Restored the static import; `requestIdleCallback` deferral is kept.
18
+
8
19
  ## [2.4.8]
9
20
 
10
21
  ### Changed
package/dist/lib/cli.cjs CHANGED
@@ -211,23 +211,19 @@ function buildEntrySource(islands, outFile, hydrateImport = "@elurjs/kit/island"
211
211
  const islandHydration = registryLines ? `const registry = {
212
212
  ${registryLines}
213
213
  };
214
- // Dynamically import the hydrator so Vite splits it into a separate chunk.
215
- // This keeps the initial entry-client bundle small (router only) — the
216
- // hydrator loads on idle, after the first paint.
217
- const hydrate = async () => {
218
- const { hydrateIslands, cleanupHydratedIslands } = await import(${JSON.stringify(hydrateImport)});
219
- cleanupHydratedIslands();
220
- hydrateIslands(registry);
221
- document.addEventListener("elur:rendered", () => {
222
- cleanupHydratedIslands();
223
- hydrateIslands(registry);
224
- });
225
- };
214
+ // Defer hydration until the browser is idle so the first paint is not
215
+ // blocked. Islands with directive "load" already have SSR-rendered DOM,
216
+ // so the user sees content immediately hydration only adds interactivity.
217
+ const hydrate = () => hydrateIslands(registry);
226
218
  if ("requestIdleCallback" in window) {
227
219
  requestIdleCallback(hydrate, { timeout: 2000 });
228
220
  } else {
229
221
  setTimeout(hydrate, 0);
230
222
  }
223
+ document.addEventListener("elur:rendered", () => {
224
+ cleanupHydratedIslands();
225
+ hydrateIslands(registry);
226
+ });
231
227
 
232
228
  // Vite HMR: when an island module (or the entry itself) updates, dispose the
233
229
  // current islands and re-hydrate from the updated modules — the registry's
@@ -235,7 +231,8 @@ if ("requestIdleCallback" in window) {
235
231
  // needed (progressive enhancement, audit §10.2 / §12.2).
236
232
  if (import.meta.hot) {
237
233
  import.meta.hot.accept((newModule) => {
238
- hydrate();
234
+ cleanupHydratedIslands();
235
+ hydrateIslands(registry);
239
236
  if (newModule) {
240
237
  // Re-run the module so its side effects (router, listeners) apply.
241
238
  }
@@ -243,6 +240,7 @@ if (import.meta.hot) {
243
240
  }` : "";
244
241
  return `// AUTO-GENERATED by @elurjs/kit. Do not edit.
245
242
  import { startClientRouter } from ${JSON.stringify(routerImport)};
243
+ import { hydrateIslands, cleanupHydratedIslands } from ${JSON.stringify(hydrateImport)};
246
244
 
247
245
  startClientRouter();
248
246
  ${islandHydration}