@ecopages/react-router 0.2.0-beta.2 → 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 -46
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecopages/react-router",
3
- "version": "0.2.0-beta.2",
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.2",
36
- "@ecopages/react": "0.2.0-beta.2"
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,35 +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
- queuedNavigationHrefRef.current = link.getAttribute("href");
410
- });
411
381
  const handlePointerDown = useEffectEvent((event) => {
412
382
  if (!runtimeActiveRef.current) {
413
383
  pendingPointerNavigationRef.current = null;
@@ -430,14 +400,12 @@ const EcoRouter = ({ page, pageProps, options: userOptions, children }) => {
430
400
  const handleClick = useEffectEvent((event) => {
431
401
  if (!runtimeActiveRef.current) {
432
402
  pendingPointerNavigationRef.current = null;
433
- pendingHoverNavigationRef.current = null;
434
403
  return;
435
404
  }
436
405
  const link = getLinkFromEvent(event);
437
406
  if (!link) {
438
- const recoveredHref = getRecoveredPointerHref() ?? getRecoveredHoverHref();
407
+ const recoveredHref = getRecoveredPointerHref();
439
408
  pendingPointerNavigationRef.current = null;
440
- pendingHoverNavigationRef.current = null;
441
409
  if (!recoveredHref) {
442
410
  return;
443
411
  }
@@ -459,11 +427,9 @@ const EcoRouter = ({ page, pageProps, options: userOptions, children }) => {
459
427
  }
460
428
  }
461
429
  pendingPointerNavigationRef.current = null;
462
- pendingHoverNavigationRef.current = null;
463
430
  return;
464
431
  }
465
432
  pendingPointerNavigationRef.current = null;
466
- pendingHoverNavigationRef.current = null;
467
433
  event.preventDefault();
468
434
  queuedNavigationHrefRef.current = null;
469
435
  const href = link.getAttribute("href");
@@ -480,9 +446,6 @@ const EcoRouter = ({ page, pageProps, options: userOptions, children }) => {
480
446
  navigate(window.location.pathname + window.location.search, { isPopState: true });
481
447
  });
482
448
  useEffect(() => {
483
- const onHoverIntent = (event) => {
484
- handleHoverIntent(event);
485
- };
486
449
  const onPointerDown = (event) => {
487
450
  handlePointerDown(event);
488
451
  };
@@ -492,18 +455,10 @@ const EcoRouter = ({ page, pageProps, options: userOptions, children }) => {
492
455
  const onPopState = () => {
493
456
  handlePopState();
494
457
  };
495
- document.addEventListener("mouseover", onHoverIntent, true);
496
- document.addEventListener("pointerover", onHoverIntent, true);
497
- document.addEventListener("mousemove", onHoverIntent, true);
498
- document.addEventListener("pointermove", onHoverIntent, true);
499
458
  document.addEventListener("pointerdown", onPointerDown, true);
500
459
  document.addEventListener("click", onClick, true);
501
460
  window.addEventListener("popstate", onPopState);
502
461
  return () => {
503
- document.removeEventListener("mouseover", onHoverIntent, true);
504
- document.removeEventListener("pointerover", onHoverIntent, true);
505
- document.removeEventListener("mousemove", onHoverIntent, true);
506
- document.removeEventListener("pointermove", onHoverIntent, true);
507
462
  document.removeEventListener("pointerdown", onPointerDown, true);
508
463
  document.removeEventListener("click", onClick, true);
509
464
  window.removeEventListener("popstate", onPopState);