@react-spring/shared
Advanced tools
Comparing version 9.0.0-canary.808.12.11b2708 to 9.0.0-canary.808.13.719834d
@@ -10,3 +10,2 @@ import { FrameRequestCallback } from './types'; | ||
export declare class FrameLoop { | ||
idle: boolean; | ||
/** | ||
@@ -33,3 +32,5 @@ * Start a new animation, or reorder an active animation in | ||
onWrite: (cb: FrameRequestCallback) => void; | ||
protected _idle: boolean; | ||
protected _animations: OpaqueAnimation[]; | ||
constructor(requestFrame?: RequestFrameFn); | ||
} |
@@ -17,5 +17,4 @@ "use strict"; | ||
requestFrame) { | ||
var _this = this; | ||
if (requestFrame === void 0) { requestFrame = function (fn) { return (void 0, G.requestAnimationFrame)(fn); }; } | ||
this.idle = true; | ||
var idle = true; | ||
var writing = false; | ||
@@ -47,4 +46,4 @@ // The most recent framestamp | ||
var kickoff = function () { | ||
if (_this.idle) { | ||
_this.idle = false; | ||
if (idle) { | ||
idle = false; | ||
lastTime = G.performanceNow(); | ||
@@ -56,3 +55,3 @@ requestFrame(update); | ||
var update = (this.update = function (time) { | ||
if (_this.idle) | ||
if (idle) | ||
return; | ||
@@ -98,3 +97,3 @@ if (helpers_1.is.und(time)) { | ||
if (!animations.length) { | ||
_this.idle = true; | ||
idle = true; | ||
return; | ||
@@ -128,2 +127,9 @@ } | ||
}; | ||
// Expose internals for testing. | ||
if (process.env.NODE_ENV !== 'production') { | ||
Object.defineProperties(this, { | ||
_idle: { get: function () { return idle; } }, | ||
_animations: { get: function () { return animations; } }, | ||
}); | ||
} | ||
} | ||
@@ -130,0 +136,0 @@ return FrameLoop; |
@@ -29,2 +29,3 @@ /// <reference types="react" /> | ||
export declare const useOnce: (effect: import("react").EffectCallback) => void; | ||
/** Return a function that re-renders this component, if still mounted */ | ||
export declare const useForceUpdate: () => () => void; | ||
@@ -31,0 +32,0 @@ /** Use a value from the previous render */ |
@@ -60,3 +60,15 @@ "use strict"; | ||
exports.useOnce = function (effect) { return react_1.useEffect(effect, []); }; | ||
exports.useForceUpdate = function () { return react_1.useReducer(function () { return ({}); }, 0)[1]; }; | ||
/** Return a function that re-renders this component, if still mounted */ | ||
exports.useForceUpdate = function () { | ||
var update = react_1.useState(0)[1]; | ||
var unmounted = react_1.useRef(false); | ||
exports.useOnce(function () { return function () { | ||
unmounted.current = true; | ||
}; }); | ||
return function () { | ||
if (!unmounted.current) { | ||
update({}); | ||
} | ||
}; | ||
}; | ||
/** Use a value from the previous render */ | ||
@@ -63,0 +75,0 @@ function usePrev(value) { |
{ | ||
"name": "@react-spring/shared", | ||
"version": "9.0.0-canary.808.12.11b2708", | ||
"version": "9.0.0-canary.808.13.719834d", | ||
"description": "Globals and shared modules", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/react-spring/react-spring/tree/master/packages/shared#readme", |
@@ -17,5 +17,5 @@ export declare type Indexable<T = any> = { | ||
/** Override the property types of `A` with `B` and merge any new properties */ | ||
export declare type Merge<A, B> = { | ||
export declare type Merge<A, B> = Remap<{ | ||
[P in keyof A]: P extends keyof B ? B[P] : A[P]; | ||
} & Omit<B, keyof A>; | ||
} & Omit<B, keyof A>>; | ||
/** Same as `Merge<A, B>` except the property descriptions from `B` override those of `A` */ | ||
@@ -41,3 +41,3 @@ export declare type Overwrite<A, B> = Omit<A, keyof B> & B; | ||
export declare type UnknownProps = Indexable<unknown>; | ||
export declare type UnknownPartial<T> = UnknownProps & Partial<T>; | ||
export declare type UnknownPartial<T = {}> = UnknownProps & Partial<T>; | ||
/** Extract string keys from an object type */ | ||
@@ -44,0 +44,0 @@ export declare type StringKeys<T> = T extends object ? Extract<keyof T, string> : string; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
110822
1271
2