@khanacademy/wonder-blocks-timing
Advanced tools
Comparing version 4.0.1 to 4.0.2
# @khanacademy/wonder-blocks-timing | ||
## 4.0.2 | ||
### Patch Changes | ||
- 695f2567: Provide a friendly name (for dev tools) for withActionScheduler | ||
## 4.0.1 | ||
@@ -4,0 +10,0 @@ |
@@ -13,3 +13,6 @@ import * as React from "react"; | ||
*/ | ||
export default function withActionScheduler<Props extends WithActionSchedulerProps>(WrappedComponent: React.ComponentType<Props>): (props: WithoutActionScheduler<Props>) => JSX.Element; | ||
export default function withActionScheduler<Props extends WithActionSchedulerProps>(WrappedComponent: React.ComponentType<Props>): { | ||
(props: WithoutActionScheduler<Props>): JSX.Element; | ||
displayName: string; | ||
}; | ||
export {}; |
@@ -204,5 +204,8 @@ import * as React from 'react'; | ||
function withActionScheduler(WrappedComponent) { | ||
return props => React.createElement(ActionSchedulerProvider, null, schedule => React.createElement(WrappedComponent, _extends({}, props, { | ||
const displayName = `withActionScheduler(${WrappedComponent.displayName || WrappedComponent.name})`; | ||
const C = props => React.createElement(ActionSchedulerProvider, null, schedule => React.createElement(WrappedComponent, _extends({}, props, { | ||
schedule: schedule | ||
}))); | ||
C.displayName = displayName; | ||
return C; | ||
} | ||
@@ -209,0 +212,0 @@ |
@@ -227,5 +227,8 @@ 'use strict'; | ||
function withActionScheduler(WrappedComponent) { | ||
return props => React__namespace.createElement(ActionSchedulerProvider, null, schedule => React__namespace.createElement(WrappedComponent, _extends({}, props, { | ||
const displayName = `withActionScheduler(${WrappedComponent.displayName || WrappedComponent.name})`; | ||
const C = props => React__namespace.createElement(ActionSchedulerProvider, null, schedule => React__namespace.createElement(WrappedComponent, _extends({}, props, { | ||
schedule: schedule | ||
}))); | ||
C.displayName = displayName; | ||
return C; | ||
} | ||
@@ -232,0 +235,0 @@ |
@@ -12,3 +12,3 @@ import type { IInterval, SchedulePolicy, ClearPolicy } from "./types"; | ||
export default class Interval implements IInterval { | ||
_intervalId: number | null | undefined; | ||
_intervalId: ReturnType<typeof setInterval> | null | undefined; | ||
_action: () => unknown; | ||
@@ -15,0 +15,0 @@ _intervalMs: number; |
@@ -12,3 +12,3 @@ import type { ITimeout, SchedulePolicy, ClearPolicy } from "./types"; | ||
export default class Timeout implements ITimeout { | ||
_timeoutId: number | null | undefined; | ||
_timeoutId: ReturnType<typeof setTimeout> | null | undefined; | ||
_action: () => unknown; | ||
@@ -15,0 +15,0 @@ _timeoutMs: number; |
{ | ||
"name": "@khanacademy/wonder-blocks-timing", | ||
"private": false, | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"design": "v1", | ||
@@ -20,6 +20,6 @@ "publishConfig": { | ||
"devDependencies": { | ||
"wb-dev-build-settings": "^0.9.7" | ||
"@khanacademy/wb-dev-build-settings": "^1.0.0" | ||
}, | ||
"author": "", | ||
"license": "MIT" | ||
} | ||
} |
@@ -12,4 +12,3 @@ import AnimationFrame from "../animation-frame"; | ||
jest.spyOn(global, "requestAnimationFrame").mockImplementation( | ||
// @ts-expect-error [FEI-5019] - TS2345 - Argument of type '(fn: any, ...args: any) => NodeJS.Timeout' is not assignable to parameter of type '(callback: FrameRequestCallback) => number'. | ||
(fn: any, ...args: any) => setTimeout(fn, 0), | ||
(fn: any, ...args: any) => setTimeout(fn, 0) as any, | ||
); | ||
@@ -50,2 +49,3 @@ jest.spyOn(global, "cancelAnimationFrame").mockImplementation( | ||
// Arrange | ||
const spy = jest.spyOn(global, "requestAnimationFrame"); | ||
@@ -57,3 +57,3 @@ // Act | ||
// Assert | ||
expect(requestAnimationFrame).toHaveBeenCalledTimes(1); | ||
expect(spy).toHaveBeenCalledTimes(1); | ||
}); | ||
@@ -104,2 +104,3 @@ }); | ||
// Arrange | ||
const spy = jest.spyOn(global, "requestAnimationFrame"); | ||
const animationFrame = new AnimationFrame(() => {}); | ||
@@ -111,6 +112,3 @@ | ||
// Assert | ||
expect(requestAnimationFrame).toHaveBeenNthCalledWith( | ||
1, | ||
expect.any(Function), | ||
); | ||
expect(spy).toHaveBeenNthCalledWith(1, expect.any(Function)); | ||
}); | ||
@@ -120,2 +118,3 @@ | ||
// Arrange | ||
const spy = jest.spyOn(global, "requestAnimationFrame"); | ||
const action = jest.fn(); | ||
@@ -126,4 +125,3 @@ const animationFrame = new AnimationFrame((time: any) => | ||
animationFrame.set(); | ||
// @ts-expect-error [FEI-5019] - TS2339 - Property 'mock' does not exist on type '(callback: FrameRequestCallback) => number'. | ||
const scheduledAction = requestAnimationFrame.mock.calls[0][0]; | ||
const scheduledAction = spy.mock.calls[0][0]; | ||
@@ -154,2 +152,3 @@ // Act | ||
// Arrange | ||
const spy = jest.spyOn(global, "requestAnimationFrame"); | ||
const action = jest.fn(); | ||
@@ -167,3 +166,3 @@ const animationFrame = new AnimationFrame( | ||
// Assert | ||
expect(requestAnimationFrame).toHaveBeenCalledTimes(2); | ||
expect(spy).toHaveBeenCalledTimes(2); | ||
}); | ||
@@ -170,0 +169,0 @@ }); |
@@ -18,3 +18,3 @@ import { | ||
export default class Interval implements IInterval { | ||
_intervalId: number | null | undefined; | ||
_intervalId: ReturnType<typeof setInterval> | null | undefined; | ||
_action: () => unknown; | ||
@@ -79,3 +79,2 @@ _intervalMs: number; | ||
} | ||
// @ts-expect-error [FEI-5019] - TS2322 - Type 'Timer' is not assignable to type 'number'. | ||
this._intervalId = setInterval(() => this._action(), this._intervalMs); | ||
@@ -82,0 +81,0 @@ } |
@@ -18,3 +18,3 @@ import { | ||
export default class Timeout implements ITimeout { | ||
_timeoutId: number | null | undefined; | ||
_timeoutId: ReturnType<typeof setTimeout> | null | undefined; | ||
_action: () => unknown; | ||
@@ -81,3 +81,2 @@ _timeoutMs: number; | ||
} | ||
// @ts-expect-error [FEI-5019] - TS2322 - Type 'Timeout' is not assignable to type 'number'. | ||
this._timeoutId = setTimeout( | ||
@@ -84,0 +83,0 @@ () => this.clear(ClearPolicies.Resolve), |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3966
193409
46