phase 0.0.4 → 0.0.6
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/README.md +32 -18
- package/dist/{index-BynP-ee0.d.ts → index-tRHsbTE2.d.ts} +35 -2
- package/dist/index-tRHsbTE2.d.ts.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{mutation-BDx6r5D3.js → pointer-D5F7_Jjs.js} +148 -2
- package/dist/pointer-D5F7_Jjs.js.map +1 -0
- package/dist/react.d.ts +60 -46
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +105 -45
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/dist/index-BynP-ee0.d.ts.map +0 -1
- package/dist/mutation-BDx6r5D3.js.map +0 -1
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { ComponentProps, JSX, ReactNode, Ref, RefObject } from "react";
|
|
1
|
+
import { A as LifecycleReason, C as LoopReason, F as SightPhase, I as SightReason, R as FrameState, S as LoopPhase, T as ReducedMotionBehavior, a as PointerState, f as IdleOptions, i as PointerReason, j as LifecycleReducedMotion, k as LifecyclePhase, l as MutationPhase, m as RenderPhase, r as PointerPhase, u as MutationReason, v as DegradedBehavior, w as Quality, y as DegradedReason } from "./index-tRHsbTE2.js";
|
|
2
|
+
import { ComponentProps, ElementType, HTMLAttributes, JSX, ReactNode, Ref, RefObject } from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/react/use-synced-ref/index.d.ts
|
|
5
5
|
/**
|
|
@@ -451,7 +451,6 @@ declare function useCanvas(options: UseCanvasOptions): UseCanvasResult;
|
|
|
451
451
|
//#endregion
|
|
452
452
|
//#region src/react/use-mutation/index.d.ts
|
|
453
453
|
type MutationRecordsCallback = (records: MutationRecord[]) => void;
|
|
454
|
-
type MutationPhaseCallback = (phase: MutationPhase, phaseReason: MutationReason) => void;
|
|
455
454
|
interface UseMutationOptions<T extends Element = HTMLDivElement> {
|
|
456
455
|
/**
|
|
457
456
|
* Element to observe. When omitted, attach the returned `ref`.
|
|
@@ -465,11 +464,6 @@ interface UseMutationOptions<T extends Element = HTMLDivElement> {
|
|
|
465
464
|
mutation: MutationObserverInit;
|
|
466
465
|
/** Called once per rAF frame with coalesced records. Never per-record. */
|
|
467
466
|
onMutations: MutationRecordsCallback;
|
|
468
|
-
/**
|
|
469
|
-
* Called on every phase transition. When provided, `phase` and `phaseReason`
|
|
470
|
-
* stay at initial values and no re-renders occur (transient mode).
|
|
471
|
-
*/
|
|
472
|
-
onPhaseChange?: MutationPhaseCallback;
|
|
473
467
|
/** Pause when off-screen or ignore visibility. Default `'pause'`. */
|
|
474
468
|
visibility?: 'pause' | 'ignore';
|
|
475
469
|
/** When `false`, tears down the observer entirely. Default `true`. */
|
|
@@ -477,7 +471,7 @@ interface UseMutationOptions<T extends Element = HTMLDivElement> {
|
|
|
477
471
|
/** IO options forwarded to the visibility observer. */
|
|
478
472
|
intersectionOptions?: IntersectionObserverInit;
|
|
479
473
|
}
|
|
480
|
-
interface
|
|
474
|
+
interface UseMutationResult<T extends Element = HTMLDivElement> {
|
|
481
475
|
ref: RefObject<T | null>;
|
|
482
476
|
phase: MutationPhase;
|
|
483
477
|
phaseReason: MutationReason;
|
|
@@ -486,25 +480,55 @@ interface UseMutationReactiveResult<T extends Element = HTMLDivElement> {
|
|
|
486
480
|
/** Reason via ref. Always current, never triggers re-render. */
|
|
487
481
|
phaseReasonRef: RefObject<MutationReason>;
|
|
488
482
|
}
|
|
489
|
-
|
|
483
|
+
/**
|
|
484
|
+
* Lifecycle-aware MutationObserver with rAF-coalesced callbacks.
|
|
485
|
+
* Auto-pauses off-screen and tears down on unmount.
|
|
486
|
+
*
|
|
487
|
+
* Records are always delivered imperatively via `onMutations` (never state).
|
|
488
|
+
* Phase transitions (observing/paused) are infrequent, so `phase`/`phaseReason`
|
|
489
|
+
* are reactive state; read `phaseRef`/`phaseReasonRef` for the latest value
|
|
490
|
+
* inside `onMutations` without closure staleness. For synchronous phase
|
|
491
|
+
* reactions, use the core `createMutation` primitive.
|
|
492
|
+
*/
|
|
493
|
+
declare function useMutation<T extends Element = HTMLDivElement>(options: UseMutationOptions<T>): UseMutationResult<T>;
|
|
494
|
+
//#endregion
|
|
495
|
+
//#region src/react/use-pointer/index.d.ts
|
|
496
|
+
type PointerCallback = (state: PointerState) => void;
|
|
497
|
+
interface UsePointerOptions<T extends Element = HTMLDivElement> {
|
|
498
|
+
/** Element to track. When omitted, attach the returned `ref`. */
|
|
499
|
+
ref?: RefObject<T | null>;
|
|
500
|
+
/** Called once per rAF frame with the latest pointer position. */
|
|
501
|
+
onPointer: PointerCallback;
|
|
502
|
+
/** Pause when off-screen or ignore visibility. Default `'pause'`. */
|
|
503
|
+
visibility?: 'pause' | 'ignore';
|
|
504
|
+
/** When `false`, tears down the tracker entirely. Default `true`. */
|
|
505
|
+
enabled?: boolean;
|
|
506
|
+
/** IO options forwarded to the visibility observer. */
|
|
507
|
+
intersectionOptions?: IntersectionObserverInit;
|
|
508
|
+
}
|
|
509
|
+
interface UsePointerResult<T extends Element = HTMLDivElement> {
|
|
490
510
|
ref: RefObject<T | null>;
|
|
511
|
+
phase: PointerPhase;
|
|
512
|
+
phaseReason: PointerReason;
|
|
491
513
|
/** Phase via ref. Always current, never triggers re-render. */
|
|
492
|
-
phaseRef: RefObject<
|
|
514
|
+
phaseRef: RefObject<PointerPhase>;
|
|
493
515
|
/** Reason via ref. Always current, never triggers re-render. */
|
|
494
|
-
phaseReasonRef: RefObject<
|
|
516
|
+
phaseReasonRef: RefObject<PointerReason>;
|
|
517
|
+
/** Latest pointer position via ref. Always current, never triggers re-render. */
|
|
518
|
+
stateRef: RefObject<PointerState>;
|
|
495
519
|
}
|
|
496
|
-
type UseMutationResult<T extends Element = HTMLDivElement> = UseMutationReactiveResult<T>;
|
|
497
520
|
/**
|
|
498
|
-
* Lifecycle-aware
|
|
521
|
+
* Lifecycle-aware pointer tracker with rAF-batched `getBoundingClientRect`.
|
|
499
522
|
* Auto-pauses off-screen and tears down on unmount.
|
|
500
523
|
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
524
|
+
* Position is always delivered imperatively via `onPointer` (never state) and
|
|
525
|
+
* mirrored in `stateRef` for on-demand reads (e.g. inside a `useLoop` tick).
|
|
526
|
+
* Phase transitions (tracking/idle) are infrequent, so `phase`/`phaseReason`
|
|
527
|
+
* are reactive state; read `phaseRef`/`phaseReasonRef` for the latest value
|
|
528
|
+
* without closure staleness. For synchronous phase reactions, use the core
|
|
529
|
+
* `createPointer` primitive.
|
|
503
530
|
*/
|
|
504
|
-
declare function
|
|
505
|
-
onPhaseChange: MutationPhaseCallback;
|
|
506
|
-
}): UseMutationTransientResult<T>;
|
|
507
|
-
declare function useMutation<T extends Element = HTMLDivElement>(options: UseMutationOptions<T>): UseMutationReactiveResult<T>;
|
|
531
|
+
declare function usePointer<T extends Element = HTMLDivElement>(options: UsePointerOptions<T>): UsePointerResult<T>;
|
|
508
532
|
//#endregion
|
|
509
533
|
//#region src/react/use-tween/index.d.ts
|
|
510
534
|
interface UseTweenOptions {
|
|
@@ -681,41 +705,31 @@ declare function WhenIdle({
|
|
|
681
705
|
}: WhenIdleProps): JSX.Element;
|
|
682
706
|
//#endregion
|
|
683
707
|
//#region src/react/defer/index.d.ts
|
|
684
|
-
interface DeferProps extends Omit<
|
|
708
|
+
interface DeferProps extends Omit<HTMLAttributes<HTMLElement>, 'style'> {
|
|
685
709
|
/**
|
|
686
|
-
*
|
|
687
|
-
*
|
|
710
|
+
* HTML element to render. Default `'div'`. Use `'li'`, `'tr'`, or any
|
|
711
|
+
* semantic element when a wrapper div would break document structure.
|
|
712
|
+
*/
|
|
713
|
+
as?: ElementType;
|
|
714
|
+
/**
|
|
715
|
+
* Approximate size reserved before first paint (any CSS length).
|
|
716
|
+
* After first render the browser remembers the real size. Default `'1000px'`.
|
|
688
717
|
*/
|
|
689
718
|
estimatedHeight?: string;
|
|
690
|
-
|
|
719
|
+
children?: ReactNode;
|
|
720
|
+
ref?: Ref<HTMLElement>;
|
|
691
721
|
}
|
|
692
722
|
/**
|
|
693
|
-
* Skip
|
|
694
|
-
*
|
|
695
|
-
*
|
|
696
|
-
* Children stay in the DOM and are server-rendered (SEO- and CLS-safe).
|
|
697
|
-
* `contain-intrinsic-size: auto <estimatedHeight>` reserves space so the
|
|
698
|
-
* scrollbar does not jump. Defers rendering only, not hydration or mounting.
|
|
699
|
-
*
|
|
700
|
-
* The render-skip styles are encapsulated and cannot be overridden. There is
|
|
701
|
-
* no `style` prop. Style the wrapper with `className`; this keeps the
|
|
702
|
-
* no-layout-shift guarantee intact.
|
|
703
|
-
*
|
|
704
|
-
* @example
|
|
705
|
-
* <Defer estimatedHeight="600px" className="my-section">
|
|
706
|
-
* <ArticleSection />
|
|
707
|
-
* </Defer>
|
|
708
|
-
*
|
|
709
|
-
* @remarks
|
|
710
|
-
* Animations inside a `Defer` keep running while paint is skipped. phase loops
|
|
711
|
-
* self-pause off-screen on their own; for raw rAF/interval work, gate it with
|
|
712
|
-
* `useRenderState`.
|
|
723
|
+
* Skip browser rendering (style, layout, paint) for off-screen content via
|
|
724
|
+
* `content-visibility: auto`. Pure CSS, no JS, no observer. Children stay
|
|
725
|
+
* in the DOM and are server-rendered (SEO- and CLS-safe).
|
|
713
726
|
*/
|
|
714
727
|
declare function Defer({
|
|
728
|
+
as: Component,
|
|
715
729
|
estimatedHeight,
|
|
716
730
|
children,
|
|
717
731
|
ref,
|
|
718
|
-
...
|
|
732
|
+
...rest
|
|
719
733
|
}: DeferProps): JSX.Element;
|
|
720
734
|
//#endregion
|
|
721
735
|
//#region src/react/swap/index.d.ts
|
|
@@ -761,5 +775,5 @@ declare const Swap: typeof SwapRoot & {
|
|
|
761
775
|
State: typeof SwapState;
|
|
762
776
|
};
|
|
763
777
|
//#endregion
|
|
764
|
-
export { type CanvasDrawFn, type ContainerBreakpoint, Defer, type DeferProps, type IdleOptions, type LifecyclePhase, type LifecycleReason, type LifecycleReducedMotion, type LoopTickFn, type
|
|
778
|
+
export { type CanvasDrawFn, type ContainerBreakpoint, Defer, type DeferProps, type IdleOptions, type LifecyclePhase, type LifecycleReason, type LifecycleReducedMotion, type LoopTickFn, type MutationRecordsCallback, type PointerCallback, Presence, type PresenceMode, type PresencePhase, type PresenceProps, type PresenceReason, type RenderPhase, type ScrollProgressCallback, type SightCallback, type Size, type SizeCallback, Swap, type SwapProps, type SwapStateProps, type UseCanvasOptions, type UseCanvasResult, type UseContainerQueryOptions, type UseContainerQueryResult, type UseLifecycleOptions, type UseLifecycleResult, type UseLoopOptions, type UseLoopResult, type UseMutationOptions, type UseMutationResult, type UsePointerOptions, type UsePointerResult, type UsePresenceOptions, type UsePresenceResult, type UseScrollProgressOptions, type UseScrollProgressReactiveResult, type UseScrollProgressResult, type UseScrollProgressTransientResult, type UseSightOptions, type UseSightReactiveResult, type UseSightResult, type UseSightTransientResult, type UseSizeOptions, type UseSizeReactiveResult, type UseSizeResult, type UseSizeTransientResult, type UseTweenOptions, WhenIdle, type WhenIdleProps, WhenVisible, type WhenVisibleProps, useCanvas, useContainerQuery, useDevicePixelRatio, useIdle, useLifecycle, useLoop, useMediaQuery, useMutation, usePointer, usePrefersReducedMotion, usePresence, useRenderState, useScrollProgress, useSight, useSize, useStableCallback, useSyncedRef, useTween, useWhenIdle };
|
|
765
779
|
//# sourceMappingURL=react.d.ts.map
|
package/dist/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","names":[],"sources":["../src/react/use-synced-ref/index.ts","../src/react/use-stable-callback/index.ts","../src/react/use-loop/index.ts","../src/react/use-lifecycle/index.ts","../src/react/use-device-pixel-ratio/index.ts","../src/react/use-media/index.ts","../src/react/use-reduced-motion/index.ts","../src/react/use-sight/index.ts","../src/react/use-size/index.ts","../src/react/use-container-query/index.ts","../src/react/use-scroll-progress/index.ts","../src/react/use-render-state/index.ts","../src/react/use-idle/index.ts","../src/react/use-when-idle/index.ts","../src/react/use-canvas/index.ts","../src/react/use-mutation/index.ts","../src/react/use-tween/index.ts","../src/react/use-presence/index.ts","../src/react/presence/index.tsx","../src/react/when-visible/index.tsx","../src/react/when-idle/index.tsx","../src/react/defer/index.tsx","../src/react/swap/index.tsx"],"mappings":";;;;;;;AAYA;;;;;;;iBAAgB,YAAA,GAAA,CAAgB,KAAA,EAAO,CAAA,GAAI,SAAA,CAAU,CAAA;;;;;;;AAArD;;;;;iBCDgB,iBAAA,2BAAA,CACd,QAAA,MAAc,IAAA,EAAM,IAAA,KAAS,CAAA,OACxB,IAAA,EAAM,IAAA,KAAS,CAAA;;;;ADDtB;;;;KEQY,UAAA,IAAc,KAAA,EAAO,UAAA;AAAA,UAEhB,cAAA,WAAyB,OAAA,GAAU,cAAA;EFVA;;;;EEelD,GAAA,GAAM,SAAA,CAAU,CAAA;EFfyB;;;;EEoBzC,MAAA,EAAQ,UAAA;EACR,GAAA;EACA,OAAA;EACA,aAAA,GAAgB,qBAAA;EDxBe;EC0B/B,QAAA,GAAW,gBAAA;EDzBS;EC2BpB,WAAA;EACA,mBAAA,GAAsB,wBAAA;AAAA;AAAA,UAGP,aAAA,WAAwB,OAAA,GAAU,cAAA;ED9B5B;ECgCrB,GAAA,EAAK,SAAA,CAAU,CAAA;EACf,KAAA,EAAO,SAAA;EACP,WAAA,EAAa,UAAA;EACb,OAAA,EAAS,OAAA;EACT,aAAA,EAAe,cAAA;AAAA;;;;;;;;;AA7BjB;;;iBAuDgB,OAAA,WAAkB,OAAA,GAAU,cAAA,CAAA,CAC1C,OAAA,EAAS,cAAA,CAAe,CAAA,IACvB,aAAA,CAAc,CAAA;;;UClEA,mBAAA,WAA8B,OAAA,GAAU,cAAA;;AHCzD;;;EGIE,GAAA,GAAM,SAAA,CAAU,CAAA;EHJmC;EGMnD,aAAA,GAAgB,sBAAA;EHNkC;EGQlD,MAAA;EHR2B;EGU3B,OAAA;EACA,mBAAA,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cAAA,WAAyB,OAAA,GAAU,cAAA,CAAA,CACjD,GAAA,EAAK,SAAA,CAAU,CAAA,WACd,WAAA;;;;;AXdH;;;;;;;;iBYIgB,OAAA,CAAQ,OAAA,GAAU,WAAA;;;;;AZJlC;;;;;;;;;;iBaOgB,WAAA,CAAY,QAAA,cAAsB,OAAA,GAAU,WAAA;;;UCI3C,MAAA;EACf,KAAA;EACA,MAAA;AAAA;;;;;;KAQU,YAAA,IACV,GAAA,EAAK,wBAAA,EACL,KAAA,EAAO,UAAA,EACP,IAAA,EAAM,MAAA;AAAA,UAGS,gBAAA;EACf,YAAA,EAAc,SAAA,CAAU,OAAA;EACxB,SAAA,EAAW,SAAA,CAAU,iBAAA;Ed7B8B;;;;EckCnD,IAAA,EAAM,YAAA;EACN,GAAA;EACA,OAAA;EACA,aAAA,GAAgB,qBAAA;EbtCe;EawC/B,QAAA,GAAW,gBAAA;EbvCkB;EayC7B,WAAA;AAAA;AAAA,UAGe,eAAA;EACf,OAAA;EACA,KAAA,EAAO,SAAA;EACP,WAAA,EAAa,UAAA;EACb,OAAA,EAAS,OAAA;EACT,aAAA,EAAe,cAAA;AAAA;;;;;;;;;;AZzCjB;;;;;iBYiEgB,SAAA,CAAU,OAAA,EAAS,gBAAA,GAAmB,eAAA;;;KCxE1C,uBAAA,IAA2B,OAAA,EAAS,cAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"react.d.ts","names":[],"sources":["../src/react/use-synced-ref/index.ts","../src/react/use-stable-callback/index.ts","../src/react/use-loop/index.ts","../src/react/use-lifecycle/index.ts","../src/react/use-device-pixel-ratio/index.ts","../src/react/use-media/index.ts","../src/react/use-reduced-motion/index.ts","../src/react/use-sight/index.ts","../src/react/use-size/index.ts","../src/react/use-container-query/index.ts","../src/react/use-scroll-progress/index.ts","../src/react/use-render-state/index.ts","../src/react/use-idle/index.ts","../src/react/use-when-idle/index.ts","../src/react/use-canvas/index.ts","../src/react/use-mutation/index.ts","../src/react/use-pointer/index.ts","../src/react/use-tween/index.ts","../src/react/use-presence/index.ts","../src/react/presence/index.tsx","../src/react/when-visible/index.tsx","../src/react/when-idle/index.tsx","../src/react/defer/index.tsx","../src/react/swap/index.tsx"],"mappings":";;;;;;;AAYA;;;;;;;iBAAgB,YAAA,GAAA,CAAgB,KAAA,EAAO,CAAA,GAAI,SAAA,CAAU,CAAA;;;;;;;AAArD;;;;;iBCDgB,iBAAA,2BAAA,CACd,QAAA,MAAc,IAAA,EAAM,IAAA,KAAS,CAAA,OACxB,IAAA,EAAM,IAAA,KAAS,CAAA;;;;ADDtB;;;;KEQY,UAAA,IAAc,KAAA,EAAO,UAAA;AAAA,UAEhB,cAAA,WAAyB,OAAA,GAAU,cAAA;EFVA;;;;EEelD,GAAA,GAAM,SAAA,CAAU,CAAA;EFfyB;;;;EEoBzC,MAAA,EAAQ,UAAA;EACR,GAAA;EACA,OAAA;EACA,aAAA,GAAgB,qBAAA;EDxBe;EC0B/B,QAAA,GAAW,gBAAA;EDzBS;EC2BpB,WAAA;EACA,mBAAA,GAAsB,wBAAA;AAAA;AAAA,UAGP,aAAA,WAAwB,OAAA,GAAU,cAAA;ED9B5B;ECgCrB,GAAA,EAAK,SAAA,CAAU,CAAA;EACf,KAAA,EAAO,SAAA;EACP,WAAA,EAAa,UAAA;EACb,OAAA,EAAS,OAAA;EACT,aAAA,EAAe,cAAA;AAAA;;;;;;;;;AA7BjB;;;iBAuDgB,OAAA,WAAkB,OAAA,GAAU,cAAA,CAAA,CAC1C,OAAA,EAAS,cAAA,CAAe,CAAA,IACvB,aAAA,CAAc,CAAA;;;UClEA,mBAAA,WAA8B,OAAA,GAAU,cAAA;;AHCzD;;;EGIE,GAAA,GAAM,SAAA,CAAU,CAAA;EHJmC;EGMnD,aAAA,GAAgB,sBAAA;EHNkC;EGQlD,MAAA;EHR2B;EGU3B,OAAA;EACA,mBAAA,GAAsB,wBAAA;EHXmB;;;;;EGiBzC,aAAA,IAAiB,KAAA,EAAO,cAAA,EAAgB,MAAA,EA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YrC,eAAA;EACA,QAAA,GAAW,SAAA;EACX,GAAA,GAAM,GAAA,CAAI,WAAA;AAAA;;;;;;iBAYI,KAAA,CAAA;EACd,EAAA,EAAI,SAAA;EACJ,eAAA;EACA,QAAA;EACA,GAAA;EAAA,GACG;AAAA,GACF,UAAA,GAAa,GAAA,CAAI,OAAA;;;UCPH,SAAA,SAAkB,cAAA;EACjC,MAAA;EACA,YAAA;EACA,QAAA,EAAU,SAAA;AAAA;;;;;;;;;;;;;;;;;AtB7BZ;iBsBiDS,QAAA,CAAA;EACP,MAAA;EACA,YAAA;EACA,QAAA;EAAA,GACG;AAAA,GACF,SAAA,GAAY,GAAA,CAAI,OAAA;AAAA,UA+BF,cAAA,SAAuB,cAAA;EACtC,EAAA;EACA,GAAA,GAAM,GAAA,CAAI,cAAA;AAAA;AAAA,iBAGH,SAAA,CAAA;EACP,EAAA;EACA,GAAA,EAAK,YAAA;EACL,QAAA;EAAA,GACG;AAAA,GACF,cAAA,GAAiB,GAAA,CAAI,OAAA;AAAA,cAwCX,IAAA,SAAa,QAAA;EAAa,KAAA,SAAc,SAAA;AAAA"}
|
package/dist/react.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { clamp01, easeOutCubic } from "./ease.js";
|
|
3
|
-
import { a as
|
|
4
|
-
import { createContext, use, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { _ as invalidDurationError, a as whenIdle, c as createRenderState, d as createLifecycle, f as readMediaQuery, i as prefersReducedMotion, l as createScrollProgress, m as createSight, n as createMutation, o as readDpr, p as subscribeMediaQuery, r as REDUCED_MOTION_QUERY, s as subscribeDpr, t as createPointer, u as createLoop, y as missingContextError } from "./pointer-D5F7_Jjs.js";
|
|
4
|
+
import { createContext, createElement, use, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
//#region src/react/use-synced-ref/index.ts
|
|
7
7
|
/**
|
|
@@ -53,7 +53,7 @@ function degradedConfig(degraded, degradedFps) {
|
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/react/use-loop/index.ts
|
|
56
|
-
const INITIAL_STATE$
|
|
56
|
+
const INITIAL_STATE$5 = {
|
|
57
57
|
phase: "idle",
|
|
58
58
|
phaseReason: "initial",
|
|
59
59
|
quality: "full",
|
|
@@ -75,12 +75,12 @@ function useLoop(options) {
|
|
|
75
75
|
const onTickRef = useSyncedRef(options.onTick);
|
|
76
76
|
const internalRef = useRef(null);
|
|
77
77
|
const ref = options.ref ?? internalRef;
|
|
78
|
-
const [state, setState] = useState(INITIAL_STATE$
|
|
78
|
+
const [state, setState] = useState(INITIAL_STATE$5);
|
|
79
79
|
const loopRef = useRef(null);
|
|
80
80
|
useEffect(() => {
|
|
81
81
|
const element = ref.current;
|
|
82
82
|
if (!element || !enabled) {
|
|
83
|
-
setState(INITIAL_STATE$
|
|
83
|
+
setState(INITIAL_STATE$5);
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
86
|
const loop = createLoop({
|
|
@@ -119,7 +119,7 @@ function useLoop(options) {
|
|
|
119
119
|
}
|
|
120
120
|
//#endregion
|
|
121
121
|
//#region src/react/use-lifecycle/index.ts
|
|
122
|
-
const INITIAL_STATE$
|
|
122
|
+
const INITIAL_STATE$4 = {
|
|
123
123
|
phase: "idle",
|
|
124
124
|
phaseReason: "initial"
|
|
125
125
|
};
|
|
@@ -148,12 +148,12 @@ function useLifecycle(options) {
|
|
|
148
148
|
const onPhaseChangeRef = useSyncedRef(options?.onPhaseChange);
|
|
149
149
|
const internalRef = useRef(null);
|
|
150
150
|
const ref = options?.ref ?? internalRef;
|
|
151
|
-
const [state, setState] = useState(INITIAL_STATE$
|
|
151
|
+
const [state, setState] = useState(INITIAL_STATE$4);
|
|
152
152
|
const lifecycleRef = useRef(null);
|
|
153
153
|
useEffect(() => {
|
|
154
154
|
const element = ref.current;
|
|
155
155
|
if (!element || !enabled) {
|
|
156
|
-
setState(INITIAL_STATE$
|
|
156
|
+
setState(INITIAL_STATE$4);
|
|
157
157
|
return;
|
|
158
158
|
}
|
|
159
159
|
const lifecycle = createLifecycle({
|
|
@@ -235,12 +235,12 @@ function usePrefersReducedMotion() {
|
|
|
235
235
|
}
|
|
236
236
|
//#endregion
|
|
237
237
|
//#region src/react/use-sight/index.ts
|
|
238
|
-
const INITIAL_STATE$
|
|
238
|
+
const INITIAL_STATE$3 = {
|
|
239
239
|
phase: "unknown",
|
|
240
240
|
phaseReason: "initial"
|
|
241
241
|
};
|
|
242
242
|
function useSight(options) {
|
|
243
|
-
const [state, setState] = useState(INITIAL_STATE$
|
|
243
|
+
const [state, setState] = useState(INITIAL_STATE$3);
|
|
244
244
|
const observe = options?.observe ?? "continuous";
|
|
245
245
|
const phaseRef = useRef("unknown");
|
|
246
246
|
const phaseReasonRef = useRef("initial");
|
|
@@ -512,7 +512,7 @@ function useWhenIdle(callback, options) {
|
|
|
512
512
|
}
|
|
513
513
|
//#endregion
|
|
514
514
|
//#region src/react/use-canvas/index.ts
|
|
515
|
-
const INITIAL_STATE$
|
|
515
|
+
const INITIAL_STATE$2 = {
|
|
516
516
|
phase: "idle",
|
|
517
517
|
phaseReason: "initial",
|
|
518
518
|
quality: "full",
|
|
@@ -535,7 +535,7 @@ const INITIAL_STATE$1 = {
|
|
|
535
535
|
function useCanvas(options) {
|
|
536
536
|
const { containerRef, canvasRef, fps, enabled = true, reducedMotion, degraded, degradedFps } = options;
|
|
537
537
|
const drawRef = useSyncedRef(options.draw);
|
|
538
|
-
const [state, setState] = useState(INITIAL_STATE$
|
|
538
|
+
const [state, setState] = useState(INITIAL_STATE$2);
|
|
539
539
|
const [restartNonce, setRestartNonce] = useState(0);
|
|
540
540
|
const ctxRef = useRef(null);
|
|
541
541
|
const sizeRef = useRef({
|
|
@@ -647,23 +647,32 @@ function useCanvas(options) {
|
|
|
647
647
|
}
|
|
648
648
|
//#endregion
|
|
649
649
|
//#region src/react/use-mutation/index.ts
|
|
650
|
-
const INITIAL_STATE = {
|
|
650
|
+
const INITIAL_STATE$1 = {
|
|
651
651
|
phase: "paused",
|
|
652
652
|
phaseReason: "initial"
|
|
653
653
|
};
|
|
654
|
+
/**
|
|
655
|
+
* Lifecycle-aware MutationObserver with rAF-coalesced callbacks.
|
|
656
|
+
* Auto-pauses off-screen and tears down on unmount.
|
|
657
|
+
*
|
|
658
|
+
* Records are always delivered imperatively via `onMutations` (never state).
|
|
659
|
+
* Phase transitions (observing/paused) are infrequent, so `phase`/`phaseReason`
|
|
660
|
+
* are reactive state; read `phaseRef`/`phaseReasonRef` for the latest value
|
|
661
|
+
* inside `onMutations` without closure staleness. For synchronous phase
|
|
662
|
+
* reactions, use the core `createMutation` primitive.
|
|
663
|
+
*/
|
|
654
664
|
function useMutation(options) {
|
|
655
|
-
const [state, setState] = useState(INITIAL_STATE);
|
|
665
|
+
const [state, setState] = useState(INITIAL_STATE$1);
|
|
656
666
|
const { mutation: mutationInit, visibility = "pause", enabled = true, intersectionOptions } = options;
|
|
657
667
|
const phaseRef = useRef("paused");
|
|
658
668
|
const phaseReasonRef = useRef("initial");
|
|
659
669
|
const onMutationsRef = useSyncedRef(options.onMutations);
|
|
660
|
-
const onPhaseChangeRef = useSyncedRef(options.onPhaseChange);
|
|
661
670
|
const internalRef = useRef(null);
|
|
662
671
|
const ref = options.ref ?? internalRef;
|
|
663
672
|
useEffect(() => {
|
|
664
673
|
const element = ref.current;
|
|
665
674
|
if (!element || !enabled) {
|
|
666
|
-
setState(INITIAL_STATE);
|
|
675
|
+
setState(INITIAL_STATE$1);
|
|
667
676
|
phaseRef.current = "paused";
|
|
668
677
|
phaseReasonRef.current = "initial";
|
|
669
678
|
return;
|
|
@@ -675,8 +684,7 @@ function useMutation(options) {
|
|
|
675
684
|
onPhaseChange: (phase, reason) => {
|
|
676
685
|
phaseRef.current = phase;
|
|
677
686
|
phaseReasonRef.current = reason;
|
|
678
|
-
|
|
679
|
-
else setState({
|
|
687
|
+
setState({
|
|
680
688
|
phase,
|
|
681
689
|
phaseReason: reason
|
|
682
690
|
});
|
|
@@ -694,6 +702,76 @@ function useMutation(options) {
|
|
|
694
702
|
};
|
|
695
703
|
}
|
|
696
704
|
//#endregion
|
|
705
|
+
//#region src/react/use-pointer/index.ts
|
|
706
|
+
const INITIAL_STATE = {
|
|
707
|
+
phase: "idle",
|
|
708
|
+
phaseReason: "initial"
|
|
709
|
+
};
|
|
710
|
+
/**
|
|
711
|
+
* Lifecycle-aware pointer tracker with rAF-batched `getBoundingClientRect`.
|
|
712
|
+
* Auto-pauses off-screen and tears down on unmount.
|
|
713
|
+
*
|
|
714
|
+
* Position is always delivered imperatively via `onPointer` (never state) and
|
|
715
|
+
* mirrored in `stateRef` for on-demand reads (e.g. inside a `useLoop` tick).
|
|
716
|
+
* Phase transitions (tracking/idle) are infrequent, so `phase`/`phaseReason`
|
|
717
|
+
* are reactive state; read `phaseRef`/`phaseReasonRef` for the latest value
|
|
718
|
+
* without closure staleness. For synchronous phase reactions, use the core
|
|
719
|
+
* `createPointer` primitive.
|
|
720
|
+
*/
|
|
721
|
+
function usePointer(options) {
|
|
722
|
+
const [state, setState] = useState(INITIAL_STATE);
|
|
723
|
+
const { visibility = "pause", enabled = true, intersectionOptions } = options;
|
|
724
|
+
const phaseRef = useRef("idle");
|
|
725
|
+
const phaseReasonRef = useRef("initial");
|
|
726
|
+
const stateRef = useRef({
|
|
727
|
+
x: 0,
|
|
728
|
+
y: 0,
|
|
729
|
+
active: false
|
|
730
|
+
});
|
|
731
|
+
const onPointerRef = useSyncedRef(options.onPointer);
|
|
732
|
+
const internalRef = useRef(null);
|
|
733
|
+
const ref = options.ref ?? internalRef;
|
|
734
|
+
useEffect(() => {
|
|
735
|
+
const element = ref.current;
|
|
736
|
+
if (!element || !enabled) {
|
|
737
|
+
setState(INITIAL_STATE);
|
|
738
|
+
phaseRef.current = "idle";
|
|
739
|
+
phaseReasonRef.current = "initial";
|
|
740
|
+
stateRef.current = {
|
|
741
|
+
x: 0,
|
|
742
|
+
y: 0,
|
|
743
|
+
active: false
|
|
744
|
+
};
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
const instance = createPointer({
|
|
748
|
+
element,
|
|
749
|
+
onPointer: (pointerState) => {
|
|
750
|
+
stateRef.current = pointerState;
|
|
751
|
+
onPointerRef.current(pointerState);
|
|
752
|
+
},
|
|
753
|
+
onPhaseChange: (phase, reason) => {
|
|
754
|
+
phaseRef.current = phase;
|
|
755
|
+
phaseReasonRef.current = reason;
|
|
756
|
+
setState({
|
|
757
|
+
phase,
|
|
758
|
+
phaseReason: reason
|
|
759
|
+
});
|
|
760
|
+
},
|
|
761
|
+
visibility,
|
|
762
|
+
intersectionOptions
|
|
763
|
+
});
|
|
764
|
+
return () => instance.stop();
|
|
765
|
+
}, [enabled, visibility]);
|
|
766
|
+
return {
|
|
767
|
+
ref,
|
|
768
|
+
...state,
|
|
769
|
+
phaseRef,
|
|
770
|
+
phaseReasonRef,
|
|
771
|
+
stateRef
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
//#endregion
|
|
697
775
|
//#region src/react/use-tween/index.ts
|
|
698
776
|
/**
|
|
699
777
|
* Animate a value from its current position to `target` over `duration`.
|
|
@@ -996,38 +1074,20 @@ function WhenIdle({ timeout, fallback, children, ref: forwardedRef, ...divProps
|
|
|
996
1074
|
//#endregion
|
|
997
1075
|
//#region src/react/defer/index.tsx
|
|
998
1076
|
/**
|
|
999
|
-
* Skip
|
|
1000
|
-
*
|
|
1001
|
-
*
|
|
1002
|
-
* Children stay in the DOM and are server-rendered (SEO- and CLS-safe).
|
|
1003
|
-
* `contain-intrinsic-size: auto <estimatedHeight>` reserves space so the
|
|
1004
|
-
* scrollbar does not jump. Defers rendering only, not hydration or mounting.
|
|
1005
|
-
*
|
|
1006
|
-
* The render-skip styles are encapsulated and cannot be overridden. There is
|
|
1007
|
-
* no `style` prop. Style the wrapper with `className`; this keeps the
|
|
1008
|
-
* no-layout-shift guarantee intact.
|
|
1009
|
-
*
|
|
1010
|
-
* @example
|
|
1011
|
-
* <Defer estimatedHeight="600px" className="my-section">
|
|
1012
|
-
* <ArticleSection />
|
|
1013
|
-
* </Defer>
|
|
1014
|
-
*
|
|
1015
|
-
* @remarks
|
|
1016
|
-
* Animations inside a `Defer` keep running while paint is skipped. phase loops
|
|
1017
|
-
* self-pause off-screen on their own; for raw rAF/interval work, gate it with
|
|
1018
|
-
* `useRenderState`.
|
|
1077
|
+
* Skip browser rendering (style, layout, paint) for off-screen content via
|
|
1078
|
+
* `content-visibility: auto`. Pure CSS, no JS, no observer. Children stay
|
|
1079
|
+
* in the DOM and are server-rendered (SEO- and CLS-safe).
|
|
1019
1080
|
*/
|
|
1020
|
-
function Defer({ estimatedHeight = "1000px", children, ref, ...
|
|
1081
|
+
function Defer({ as: Component = "div", estimatedHeight = "1000px", children, ref, ...rest }) {
|
|
1021
1082
|
const deferStyle = {
|
|
1022
1083
|
contentVisibility: "auto",
|
|
1023
1084
|
containIntrinsicSize: `auto ${estimatedHeight}`
|
|
1024
1085
|
};
|
|
1025
|
-
return
|
|
1026
|
-
...
|
|
1086
|
+
return createElement(Component, {
|
|
1087
|
+
...rest,
|
|
1027
1088
|
ref,
|
|
1028
|
-
style: deferStyle
|
|
1029
|
-
|
|
1030
|
-
});
|
|
1089
|
+
style: deferStyle
|
|
1090
|
+
}, children);
|
|
1031
1091
|
}
|
|
1032
1092
|
//#endregion
|
|
1033
1093
|
//#region src/react/swap/index.tsx
|
|
@@ -1111,6 +1171,6 @@ function SwapState({ id, ref: forwardedRef, children, ...divProps }) {
|
|
|
1111
1171
|
}
|
|
1112
1172
|
const Swap = Object.assign(SwapRoot, { State: SwapState });
|
|
1113
1173
|
//#endregion
|
|
1114
|
-
export { Defer, Presence, Swap, WhenIdle, WhenVisible, useCanvas, useContainerQuery, useDevicePixelRatio, useIdle, useLifecycle, useLoop, useMediaQuery, useMutation, usePrefersReducedMotion, usePresence, useRenderState, useScrollProgress, useSight, useSize, useStableCallback, useSyncedRef, useTween, useWhenIdle };
|
|
1174
|
+
export { Defer, Presence, Swap, WhenIdle, WhenVisible, useCanvas, useContainerQuery, useDevicePixelRatio, useIdle, useLifecycle, useLoop, useMediaQuery, useMutation, usePointer, usePrefersReducedMotion, usePresence, useRenderState, useScrollProgress, useSight, useSize, useStableCallback, useSyncedRef, useTween, useWhenIdle };
|
|
1115
1175
|
|
|
1116
1176
|
//# sourceMappingURL=react.js.map
|