phase 0.0.3 → 0.0.5
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 +54 -18
- package/dist/{index-D3epuj2x.d.ts → index-BynP-ee0.d.ts} +28 -2
- package/dist/index-BynP-ee0.d.ts.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{reduced-motion-CEJtegNG.js → mutation-BDx6r5D3.js} +120 -2
- package/dist/mutation-BDx6r5D3.js.map +1 -0
- package/dist/react.d.ts +75 -28
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +69 -39
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/dist/index-D3epuj2x.d.ts.map +0 -1
- package/dist/reduced-motion-CEJtegNG.js.map +0 -1
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ComponentProps, JSX, ReactNode, Ref, RefObject } from "react";
|
|
1
|
+
import { A as SightReason, C as LifecyclePhase, M as FrameState, T as LifecycleReducedMotion, _ as LoopReason, c as RenderPhase, f as DegradedBehavior, g as LoopPhase, i as MutationReason, k as SightPhase, o as IdleOptions, p as DegradedReason, r as MutationPhase, v as Quality, w as LifecycleReason, y as ReducedMotionBehavior } from "./index-BynP-ee0.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
|
/**
|
|
@@ -449,6 +449,63 @@ interface UseCanvasResult {
|
|
|
449
449
|
*/
|
|
450
450
|
declare function useCanvas(options: UseCanvasOptions): UseCanvasResult;
|
|
451
451
|
//#endregion
|
|
452
|
+
//#region src/react/use-mutation/index.d.ts
|
|
453
|
+
type MutationRecordsCallback = (records: MutationRecord[]) => void;
|
|
454
|
+
type MutationPhaseCallback = (phase: MutationPhase, phaseReason: MutationReason) => void;
|
|
455
|
+
interface UseMutationOptions<T extends Element = HTMLDivElement> {
|
|
456
|
+
/**
|
|
457
|
+
* Element to observe. When omitted, attach the returned `ref`.
|
|
458
|
+
* Must be set before the first effect commit (standard React ref contract).
|
|
459
|
+
*/
|
|
460
|
+
ref?: RefObject<T | null>;
|
|
461
|
+
/**
|
|
462
|
+
* Standard MutationObserver configuration. Must be stable across renders
|
|
463
|
+
* (define outside the component or memoize). Changes are not tracked.
|
|
464
|
+
*/
|
|
465
|
+
mutation: MutationObserverInit;
|
|
466
|
+
/** Called once per rAF frame with coalesced records. Never per-record. */
|
|
467
|
+
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
|
+
/** Pause when off-screen or ignore visibility. Default `'pause'`. */
|
|
474
|
+
visibility?: 'pause' | 'ignore';
|
|
475
|
+
/** When `false`, tears down the observer entirely. Default `true`. */
|
|
476
|
+
enabled?: boolean;
|
|
477
|
+
/** IO options forwarded to the visibility observer. */
|
|
478
|
+
intersectionOptions?: IntersectionObserverInit;
|
|
479
|
+
}
|
|
480
|
+
interface UseMutationReactiveResult<T extends Element = HTMLDivElement> {
|
|
481
|
+
ref: RefObject<T | null>;
|
|
482
|
+
phase: MutationPhase;
|
|
483
|
+
phaseReason: MutationReason;
|
|
484
|
+
/** Phase via ref. Always current, never triggers re-render. */
|
|
485
|
+
phaseRef: RefObject<MutationPhase>;
|
|
486
|
+
/** Reason via ref. Always current, never triggers re-render. */
|
|
487
|
+
phaseReasonRef: RefObject<MutationReason>;
|
|
488
|
+
}
|
|
489
|
+
interface UseMutationTransientResult<T extends Element = HTMLDivElement> {
|
|
490
|
+
ref: RefObject<T | null>;
|
|
491
|
+
/** Phase via ref. Always current, never triggers re-render. */
|
|
492
|
+
phaseRef: RefObject<MutationPhase>;
|
|
493
|
+
/** Reason via ref. Always current, never triggers re-render. */
|
|
494
|
+
phaseReasonRef: RefObject<MutationReason>;
|
|
495
|
+
}
|
|
496
|
+
type UseMutationResult<T extends Element = HTMLDivElement> = UseMutationReactiveResult<T>;
|
|
497
|
+
/**
|
|
498
|
+
* Lifecycle-aware MutationObserver with rAF-coalesced callbacks.
|
|
499
|
+
* Auto-pauses off-screen and tears down on unmount.
|
|
500
|
+
*
|
|
501
|
+
* Pass `onPhaseChange` for zero-re-render mode (transient). Without it,
|
|
502
|
+
* `phase` and `phaseReason` update via state on every transition.
|
|
503
|
+
*/
|
|
504
|
+
declare function useMutation<T extends Element = HTMLDivElement>(options: UseMutationOptions<T> & {
|
|
505
|
+
onPhaseChange: MutationPhaseCallback;
|
|
506
|
+
}): UseMutationTransientResult<T>;
|
|
507
|
+
declare function useMutation<T extends Element = HTMLDivElement>(options: UseMutationOptions<T>): UseMutationReactiveResult<T>;
|
|
508
|
+
//#endregion
|
|
452
509
|
//#region src/react/use-tween/index.d.ts
|
|
453
510
|
interface UseTweenOptions {
|
|
454
511
|
target: number;
|
|
@@ -624,41 +681,31 @@ declare function WhenIdle({
|
|
|
624
681
|
}: WhenIdleProps): JSX.Element;
|
|
625
682
|
//#endregion
|
|
626
683
|
//#region src/react/defer/index.d.ts
|
|
627
|
-
interface DeferProps extends Omit<
|
|
684
|
+
interface DeferProps extends Omit<HTMLAttributes<HTMLElement>, 'style'> {
|
|
628
685
|
/**
|
|
629
|
-
*
|
|
630
|
-
*
|
|
686
|
+
* HTML element to render. Default `'div'`. Use `'li'`, `'tr'`, or any
|
|
687
|
+
* semantic element when a wrapper div would break document structure.
|
|
688
|
+
*/
|
|
689
|
+
as?: ElementType;
|
|
690
|
+
/**
|
|
691
|
+
* Approximate size reserved before first paint (any CSS length).
|
|
692
|
+
* After first render the browser remembers the real size. Default `'1000px'`.
|
|
631
693
|
*/
|
|
632
694
|
estimatedHeight?: string;
|
|
633
|
-
|
|
695
|
+
children?: ReactNode;
|
|
696
|
+
ref?: Ref<HTMLElement>;
|
|
634
697
|
}
|
|
635
698
|
/**
|
|
636
|
-
* Skip
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
* Children stay in the DOM and are server-rendered (SEO- and CLS-safe).
|
|
640
|
-
* `contain-intrinsic-size: auto <estimatedHeight>` reserves space so the
|
|
641
|
-
* scrollbar does not jump. Defers rendering only, not hydration or mounting.
|
|
642
|
-
*
|
|
643
|
-
* The render-skip styles are encapsulated and cannot be overridden. There is
|
|
644
|
-
* no `style` prop. Style the wrapper with `className`; this keeps the
|
|
645
|
-
* no-layout-shift guarantee intact.
|
|
646
|
-
*
|
|
647
|
-
* @example
|
|
648
|
-
* <Defer estimatedHeight="600px" className="my-section">
|
|
649
|
-
* <ArticleSection />
|
|
650
|
-
* </Defer>
|
|
651
|
-
*
|
|
652
|
-
* @remarks
|
|
653
|
-
* Animations inside a `Defer` keep running while paint is skipped. phase loops
|
|
654
|
-
* self-pause off-screen on their own; for raw rAF/interval work, gate it with
|
|
655
|
-
* `useRenderState`.
|
|
699
|
+
* Skip browser rendering (style, layout, paint) for off-screen content via
|
|
700
|
+
* `content-visibility: auto`. Pure CSS, no JS, no observer. Children stay
|
|
701
|
+
* in the DOM and are server-rendered (SEO- and CLS-safe).
|
|
656
702
|
*/
|
|
657
703
|
declare function Defer({
|
|
704
|
+
as: Component,
|
|
658
705
|
estimatedHeight,
|
|
659
706
|
children,
|
|
660
707
|
ref,
|
|
661
|
-
...
|
|
708
|
+
...rest
|
|
662
709
|
}: DeferProps): JSX.Element;
|
|
663
710
|
//#endregion
|
|
664
711
|
//#region src/react/swap/index.d.ts
|
|
@@ -704,5 +751,5 @@ declare const Swap: typeof SwapRoot & {
|
|
|
704
751
|
State: typeof SwapState;
|
|
705
752
|
};
|
|
706
753
|
//#endregion
|
|
707
|
-
export { type CanvasDrawFn, type ContainerBreakpoint, Defer, type DeferProps, type IdleOptions, type LifecyclePhase, type LifecycleReason, type LifecycleReducedMotion, type LoopTickFn, 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 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, usePrefersReducedMotion, usePresence, useRenderState, useScrollProgress, useSight, useSize, useStableCallback, useSyncedRef, useTween, useWhenIdle };
|
|
754
|
+
export { type CanvasDrawFn, type ContainerBreakpoint, Defer, type DeferProps, type IdleOptions, type LifecyclePhase, type LifecycleReason, type LifecycleReducedMotion, type LoopTickFn, type MutationPhaseCallback, type MutationRecordsCallback, 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 UseMutationReactiveResult, type UseMutationResult, type UseMutationTransientResult, 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, usePrefersReducedMotion, usePresence, useRenderState, useScrollProgress, useSight, useSize, useStableCallback, useSyncedRef, useTween, useWhenIdle };
|
|
708
755
|
//# 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-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,g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AAA;EACT,aAAA,EAAe,cAAA;AAAA;;;;;;;;;;AZzCjB;;;;;iBYiEgB,SAAA,CAAU,OAAA,EAAS,gBAAA,GAAmB,eAAA;;;
|
|
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,CAA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,SAAsB,cAAA;;EAErC,OAAA;EpBCc;EoBCd,QAAA,GAAW,SAAA;EACX,GAAA,GAAM,GAAA,CAAI,cAAA;AAAA;;;;;;;;;;;;;;;AnBHZ;;;iBmB2BgB,QAAA,CAAA;EACd,OAAA;EACA,QAAA;EACA,QAAA;EACA,GAAA,EAAK,YAAA;EAAA,GACF;AAAA,GACF,aAAA,GAAgB,GAAA,CAAI,OAAA;;;UC9BN,UAAA,SAAmB,IAAA,CAAK,cAAA,CAAe,WAAA;;;ArBFxD;;EqBOE,EAAA,GAAK,WAAA;ErBPgC;;;;EqBYrC,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;;;;;;;;;;;;;;;;;ArB7BZ;iBqBiDS,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 {
|
|
4
|
-
import { createContext, use, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { a as readDpr, c as createScrollProgress, d as readMediaQuery, f as subscribeMediaQuery, g as invalidDurationError, i as whenIdle, l as createLoop, n as REDUCED_MOTION_QUERY, o as subscribeDpr, p as createSight, r as prefersReducedMotion, s as createRenderState, t as createMutation, u as createLifecycle, v as missingContextError } from "./mutation-BDx6r5D3.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$4 = {
|
|
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$4);
|
|
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$4);
|
|
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$3 = {
|
|
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$3);
|
|
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$3);
|
|
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$2 = {
|
|
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$2);
|
|
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$1 = {
|
|
516
516
|
phase: "idle",
|
|
517
517
|
phaseReason: "initial",
|
|
518
518
|
quality: "full",
|
|
@@ -535,7 +535,7 @@ const INITIAL_STATE = {
|
|
|
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$1);
|
|
539
539
|
const [restartNonce, setRestartNonce] = useState(0);
|
|
540
540
|
const ctxRef = useRef(null);
|
|
541
541
|
const sizeRef = useRef({
|
|
@@ -646,6 +646,54 @@ function useCanvas(options) {
|
|
|
646
646
|
};
|
|
647
647
|
}
|
|
648
648
|
//#endregion
|
|
649
|
+
//#region src/react/use-mutation/index.ts
|
|
650
|
+
const INITIAL_STATE = {
|
|
651
|
+
phase: "paused",
|
|
652
|
+
phaseReason: "initial"
|
|
653
|
+
};
|
|
654
|
+
function useMutation(options) {
|
|
655
|
+
const [state, setState] = useState(INITIAL_STATE);
|
|
656
|
+
const { mutation: mutationInit, visibility = "pause", enabled = true, intersectionOptions } = options;
|
|
657
|
+
const phaseRef = useRef("paused");
|
|
658
|
+
const phaseReasonRef = useRef("initial");
|
|
659
|
+
const onMutationsRef = useSyncedRef(options.onMutations);
|
|
660
|
+
const onPhaseChangeRef = useSyncedRef(options.onPhaseChange);
|
|
661
|
+
const internalRef = useRef(null);
|
|
662
|
+
const ref = options.ref ?? internalRef;
|
|
663
|
+
useEffect(() => {
|
|
664
|
+
const element = ref.current;
|
|
665
|
+
if (!element || !enabled) {
|
|
666
|
+
setState(INITIAL_STATE);
|
|
667
|
+
phaseRef.current = "paused";
|
|
668
|
+
phaseReasonRef.current = "initial";
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
const instance = createMutation({
|
|
672
|
+
element,
|
|
673
|
+
mutation: mutationInit,
|
|
674
|
+
onMutations: (records) => onMutationsRef.current(records),
|
|
675
|
+
onPhaseChange: (phase, reason) => {
|
|
676
|
+
phaseRef.current = phase;
|
|
677
|
+
phaseReasonRef.current = reason;
|
|
678
|
+
if (onPhaseChangeRef.current) onPhaseChangeRef.current(phase, reason);
|
|
679
|
+
else setState({
|
|
680
|
+
phase,
|
|
681
|
+
phaseReason: reason
|
|
682
|
+
});
|
|
683
|
+
},
|
|
684
|
+
visibility,
|
|
685
|
+
intersectionOptions
|
|
686
|
+
});
|
|
687
|
+
return () => instance.stop();
|
|
688
|
+
}, [enabled, visibility]);
|
|
689
|
+
return {
|
|
690
|
+
ref,
|
|
691
|
+
...state,
|
|
692
|
+
phaseRef,
|
|
693
|
+
phaseReasonRef
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
//#endregion
|
|
649
697
|
//#region src/react/use-tween/index.ts
|
|
650
698
|
/**
|
|
651
699
|
* Animate a value from its current position to `target` over `duration`.
|
|
@@ -948,38 +996,20 @@ function WhenIdle({ timeout, fallback, children, ref: forwardedRef, ...divProps
|
|
|
948
996
|
//#endregion
|
|
949
997
|
//#region src/react/defer/index.tsx
|
|
950
998
|
/**
|
|
951
|
-
* Skip
|
|
952
|
-
*
|
|
953
|
-
*
|
|
954
|
-
* Children stay in the DOM and are server-rendered (SEO- and CLS-safe).
|
|
955
|
-
* `contain-intrinsic-size: auto <estimatedHeight>` reserves space so the
|
|
956
|
-
* scrollbar does not jump. Defers rendering only, not hydration or mounting.
|
|
957
|
-
*
|
|
958
|
-
* The render-skip styles are encapsulated and cannot be overridden. There is
|
|
959
|
-
* no `style` prop. Style the wrapper with `className`; this keeps the
|
|
960
|
-
* no-layout-shift guarantee intact.
|
|
961
|
-
*
|
|
962
|
-
* @example
|
|
963
|
-
* <Defer estimatedHeight="600px" className="my-section">
|
|
964
|
-
* <ArticleSection />
|
|
965
|
-
* </Defer>
|
|
966
|
-
*
|
|
967
|
-
* @remarks
|
|
968
|
-
* Animations inside a `Defer` keep running while paint is skipped. phase loops
|
|
969
|
-
* self-pause off-screen on their own; for raw rAF/interval work, gate it with
|
|
970
|
-
* `useRenderState`.
|
|
999
|
+
* Skip browser rendering (style, layout, paint) for off-screen content via
|
|
1000
|
+
* `content-visibility: auto`. Pure CSS, no JS, no observer. Children stay
|
|
1001
|
+
* in the DOM and are server-rendered (SEO- and CLS-safe).
|
|
971
1002
|
*/
|
|
972
|
-
function Defer({ estimatedHeight = "1000px", children, ref, ...
|
|
1003
|
+
function Defer({ as: Component = "div", estimatedHeight = "1000px", children, ref, ...rest }) {
|
|
973
1004
|
const deferStyle = {
|
|
974
1005
|
contentVisibility: "auto",
|
|
975
1006
|
containIntrinsicSize: `auto ${estimatedHeight}`
|
|
976
1007
|
};
|
|
977
|
-
return
|
|
978
|
-
...
|
|
1008
|
+
return createElement(Component, {
|
|
1009
|
+
...rest,
|
|
979
1010
|
ref,
|
|
980
|
-
style: deferStyle
|
|
981
|
-
|
|
982
|
-
});
|
|
1011
|
+
style: deferStyle
|
|
1012
|
+
}, children);
|
|
983
1013
|
}
|
|
984
1014
|
//#endregion
|
|
985
1015
|
//#region src/react/swap/index.tsx
|
|
@@ -1063,6 +1093,6 @@ function SwapState({ id, ref: forwardedRef, children, ...divProps }) {
|
|
|
1063
1093
|
}
|
|
1064
1094
|
const Swap = Object.assign(SwapRoot, { State: SwapState });
|
|
1065
1095
|
//#endregion
|
|
1066
|
-
export { Defer, Presence, Swap, WhenIdle, WhenVisible, useCanvas, useContainerQuery, useDevicePixelRatio, useIdle, useLifecycle, useLoop, useMediaQuery, usePrefersReducedMotion, usePresence, useRenderState, useScrollProgress, useSight, useSize, useStableCallback, useSyncedRef, useTween, useWhenIdle };
|
|
1096
|
+
export { Defer, Presence, Swap, WhenIdle, WhenVisible, useCanvas, useContainerQuery, useDevicePixelRatio, useIdle, useLifecycle, useLoop, useMediaQuery, useMutation, usePrefersReducedMotion, usePresence, useRenderState, useScrollProgress, useSight, useSize, useStableCallback, useSyncedRef, useTween, useWhenIdle };
|
|
1067
1097
|
|
|
1068
1098
|
//# sourceMappingURL=react.js.map
|