@ecopages/react-router 0.2.0-beta.3 → 0.2.0-beta.4

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/package.json +3 -3
  2. package/src/router.js +1 -45
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecopages/react-router",
3
- "version": "0.2.0-beta.3",
3
+ "version": "0.2.0-beta.4",
4
4
  "description": "Client-side SPA router for EcoPages React applications",
5
5
  "keywords": [
6
6
  "ecopages",
@@ -32,8 +32,8 @@
32
32
  "directory": "packages/react-router"
33
33
  },
34
34
  "peerDependencies": {
35
- "@ecopages/core": "0.2.0-beta.3",
36
- "@ecopages/react": "0.2.0-beta.3"
35
+ "@ecopages/core": "0.2.0-beta.4",
36
+ "@ecopages/react": "0.2.0-beta.4"
37
37
  },
38
38
  "dependencies": {
39
39
  "react": "^19.2.6",
package/src/router.js CHANGED
@@ -174,7 +174,6 @@ const EcoRouter = ({ page, pageProps, options: userOptions, children }) => {
174
174
  const isNavigatingRef = useRef(false);
175
175
  const runtimeActiveRef = useRef(true);
176
176
  const pendingPointerNavigationRef = useRef(null);
177
- const pendingHoverNavigationRef = useRef(null);
178
177
  const queuedNavigationHrefRef = useRef(null);
179
178
  const committedPathRef = useRef(
180
179
  typeof window !== "undefined" ? window.location.pathname + window.location.search : ""
@@ -379,34 +378,6 @@ const EcoRouter = ({ page, pageProps, options: userOptions, children }) => {
379
378
  }
380
379
  return href;
381
380
  });
382
- const getRecoveredHoverHref = useEffectEvent(() => {
383
- const href = recoverPendingNavigationHref(
384
- pendingHoverNavigationRef.current,
385
- !!activeNavigationRef.current || isNavigatingRef.current,
386
- performance.now()
387
- );
388
- if (!href) {
389
- pendingHoverNavigationRef.current = null;
390
- }
391
- return href;
392
- });
393
- const handleHoverIntent = useEffectEvent((event) => {
394
- if (!runtimeActiveRef.current) {
395
- return;
396
- }
397
- const link = getLinkFromEvent(event);
398
- if (!link) {
399
- return;
400
- }
401
- const decision = getInterceptDecision(event, link, options);
402
- if (!decision.shouldIntercept) {
403
- return;
404
- }
405
- pendingHoverNavigationRef.current = {
406
- href: link.getAttribute("href"),
407
- timestamp: performance.now()
408
- };
409
- });
410
381
  const handlePointerDown = useEffectEvent((event) => {
411
382
  if (!runtimeActiveRef.current) {
412
383
  pendingPointerNavigationRef.current = null;
@@ -429,14 +400,12 @@ const EcoRouter = ({ page, pageProps, options: userOptions, children }) => {
429
400
  const handleClick = useEffectEvent((event) => {
430
401
  if (!runtimeActiveRef.current) {
431
402
  pendingPointerNavigationRef.current = null;
432
- pendingHoverNavigationRef.current = null;
433
403
  return;
434
404
  }
435
405
  const link = getLinkFromEvent(event);
436
406
  if (!link) {
437
- const recoveredHref = getRecoveredPointerHref() ?? getRecoveredHoverHref();
407
+ const recoveredHref = getRecoveredPointerHref();
438
408
  pendingPointerNavigationRef.current = null;
439
- pendingHoverNavigationRef.current = null;
440
409
  if (!recoveredHref) {
441
410
  return;
442
411
  }
@@ -458,11 +427,9 @@ const EcoRouter = ({ page, pageProps, options: userOptions, children }) => {
458
427
  }
459
428
  }
460
429
  pendingPointerNavigationRef.current = null;
461
- pendingHoverNavigationRef.current = null;
462
430
  return;
463
431
  }
464
432
  pendingPointerNavigationRef.current = null;
465
- pendingHoverNavigationRef.current = null;
466
433
  event.preventDefault();
467
434
  queuedNavigationHrefRef.current = null;
468
435
  const href = link.getAttribute("href");
@@ -479,9 +446,6 @@ const EcoRouter = ({ page, pageProps, options: userOptions, children }) => {
479
446
  navigate(window.location.pathname + window.location.search, { isPopState: true });
480
447
  });
481
448
  useEffect(() => {
482
- const onHoverIntent = (event) => {
483
- handleHoverIntent(event);
484
- };
485
449
  const onPointerDown = (event) => {
486
450
  handlePointerDown(event);
487
451
  };
@@ -491,18 +455,10 @@ const EcoRouter = ({ page, pageProps, options: userOptions, children }) => {
491
455
  const onPopState = () => {
492
456
  handlePopState();
493
457
  };
494
- document.addEventListener("mouseover", onHoverIntent, true);
495
- document.addEventListener("pointerover", onHoverIntent, true);
496
- document.addEventListener("mousemove", onHoverIntent, true);
497
- document.addEventListener("pointermove", onHoverIntent, true);
498
458
  document.addEventListener("pointerdown", onPointerDown, true);
499
459
  document.addEventListener("click", onClick, true);
500
460
  window.addEventListener("popstate", onPopState);
501
461
  return () => {
502
- document.removeEventListener("mouseover", onHoverIntent, true);
503
- document.removeEventListener("pointerover", onHoverIntent, true);
504
- document.removeEventListener("mousemove", onHoverIntent, true);
505
- document.removeEventListener("pointermove", onHoverIntent, true);
506
462
  document.removeEventListener("pointerdown", onPointerDown, true);
507
463
  document.removeEventListener("click", onClick, true);
508
464
  window.removeEventListener("popstate", onPopState);