@khanacademy/wonder-blocks-timing 6.0.1 → 7.0.1
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/CHANGELOG.md +59 -36
- package/LICENSE +21 -0
- package/dist/es/index.js +20 -25
- package/dist/hooks/use-interval.d.ts +3 -1
- package/dist/hooks/use-timeout.d.ts +3 -1
- package/dist/index.js +20 -25
- package/package.json +7 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,120 +1,143 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-timing
|
|
2
2
|
|
|
3
|
+
## 7.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ee8d95a: Rollback rollup version from v4 to v2 to prevent an issue with CJS builds in unit tests
|
|
8
|
+
|
|
9
|
+
## 7.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- ae9b619: Fix bug with `useTimeout` and `useInterval` `clear` function where it didn't use the provided ClearPolicy
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- f03298f: Tooling:
|
|
18
|
+
|
|
19
|
+
- Switching to `pnpm`.
|
|
20
|
+
- Upgrading `rollup` to v4 and `@babel/runtime` to match the current webapp version.
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- bb2a026: pnpm: Switch to workspace protocol to handle dependency versions with changesets on monorepo setup"
|
|
25
|
+
|
|
3
26
|
## 6.0.1
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
6
29
|
|
|
7
|
-
-
|
|
30
|
+
- 11a0f5c6: No functional changes. Adding prepublishOnly script.
|
|
8
31
|
|
|
9
32
|
## 6.0.0
|
|
10
33
|
|
|
11
34
|
### Major Changes
|
|
12
35
|
|
|
13
|
-
-
|
|
36
|
+
- e6abdd17: Upgrade to React 18
|
|
14
37
|
|
|
15
38
|
## 5.0.2
|
|
16
39
|
|
|
17
40
|
### Patch Changes
|
|
18
41
|
|
|
19
|
-
-
|
|
42
|
+
- 02a1b298: Make sure we don't package tsconfig and tsbuildinfo files
|
|
20
43
|
|
|
21
44
|
## 5.0.1
|
|
22
45
|
|
|
23
46
|
### Patch Changes
|
|
24
47
|
|
|
25
|
-
-
|
|
48
|
+
- 559e82d5: Update to build tooling, generating smaller output
|
|
26
49
|
|
|
27
50
|
## 5.0.0
|
|
28
51
|
|
|
29
52
|
### Major Changes
|
|
30
53
|
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
54
|
+
- f72f7dd4: - **[BREAKING CHANGE]** Policy types are now using enums across all APIs
|
|
55
|
+
- **[BREAKING CHANGE]** `useScheduledTimeout` has been renamed to `useTimeout` and the original `useTimeout` has been removed. To update existing uses of `useTimeout` to the new API: if `active` was `true` just delete that argument or replace it with `{schedulingPolicy: SchedulingPolicy.Immediately}`; if `active` was `false` replace it with `{schedulingPolicy: SchedulingPolicy.OnDemand}`.
|
|
56
|
+
- **[BREAKING CHANGE]** `useScheduledInterval` has been renamed to `useInterval` and the original `useInterval` has been removed. To update existing uses of `useInterval` to the new API: if `active` was `true` just delete that argument or replace it with `{schedulingPolicy: SchedulingPolicy.Immediately}`; if `active` was `false` replace it with `{schedulingPolicy: SchedulingPolicy.OnDemand}`.
|
|
57
|
+
- **[NEW]** `useTimeout` now supports an optional `ActionPolicy` in the options. The default is to not reset the timeout when the `action` callback changes. This can be changed to `ActionPolicy.Reset` to reset the timeout when the `action` callback changes (it is recommended that you use `useCallback` on your `action` callback to avoid resetting the timeout everytime a component renders when using the `Reset` policy).
|
|
58
|
+
- **[NEW]** `useInterval` now supports an optional `ActionPolicy` in the options. The default is to not reset the interval when the `action` callback changes. This can be changed to `ActionPolicy.Reset` to reset the interval when the `action` callback changes (it is recommended that you use `useCallback` on your `action` callback to avoid resetting the interval everytime a component renders when using the `Reset` policy).
|
|
59
|
+
- **[BUGFIX]** `useTimeout` will now correctly reset the timeout when the `set` method is called, as intended.
|
|
60
|
+
- **[BUGFIX]** `useInterval` will now correctly reset the interval when the `set` method is called, as intended.
|
|
38
61
|
|
|
39
62
|
## 4.0.2
|
|
40
63
|
|
|
41
64
|
### Patch Changes
|
|
42
65
|
|
|
43
|
-
-
|
|
66
|
+
- 695f2567: Provide a friendly name (for dev tools) for withActionScheduler
|
|
44
67
|
|
|
45
68
|
## 4.0.1
|
|
46
69
|
|
|
47
70
|
### Patch Changes
|
|
48
71
|
|
|
49
|
-
-
|
|
72
|
+
- df9a10aa: Update state and props to be readonly in components using getDerivedStateFromProps()
|
|
50
73
|
|
|
51
74
|
## 4.0.0
|
|
52
75
|
|
|
53
76
|
### Major Changes
|
|
54
77
|
|
|
55
|
-
-
|
|
78
|
+
- 0c2607e6: Remove ref-forwarding from withActionScheduler
|
|
56
79
|
|
|
57
80
|
## 3.0.3
|
|
58
81
|
|
|
59
82
|
### Patch Changes
|
|
60
83
|
|
|
61
|
-
-
|
|
84
|
+
- a6164ed0: Don't use React.FC<> for functional components
|
|
62
85
|
|
|
63
86
|
## 3.0.2
|
|
64
87
|
|
|
65
88
|
### Patch Changes
|
|
66
89
|
|
|
67
|
-
-
|
|
90
|
+
- c20f48f3: Don't transpile classes when building bundles
|
|
68
91
|
|
|
69
92
|
## 3.0.1
|
|
70
93
|
|
|
71
94
|
### Patch Changes
|
|
72
95
|
|
|
73
|
-
-
|
|
74
|
-
-
|
|
96
|
+
- ccb6fe00: Miscellaneous TS type fixes
|
|
97
|
+
- d4c2b18c: Fix a variety of issues with Flow types generated by flowgen
|
|
75
98
|
|
|
76
99
|
## 3.0.0
|
|
77
100
|
|
|
78
101
|
### Major Changes
|
|
79
102
|
|
|
80
|
-
-
|
|
103
|
+
- 1ca4d7e3: Fix minor issue with generate Flow types (this is a major bump b/c I forgot to do one after doing the TS conversion)
|
|
81
104
|
|
|
82
105
|
### Minor Changes
|
|
83
106
|
|
|
84
|
-
-
|
|
107
|
+
- ef661acf: Export ActionScheduler
|
|
85
108
|
|
|
86
109
|
## 2.1.3
|
|
87
110
|
|
|
88
111
|
### Patch Changes
|
|
89
112
|
|
|
90
|
-
-
|
|
113
|
+
- b5ba5568: Ensure that flow lib defs use React.ElementConfig<> isntead of JSX.LibraryManagedAttributes<>
|
|
91
114
|
|
|
92
115
|
## 2.1.2
|
|
93
116
|
|
|
94
117
|
### Patch Changes
|
|
95
118
|
|
|
96
|
-
-
|
|
97
|
-
-
|
|
98
|
-
-
|
|
99
|
-
-
|
|
100
|
-
-
|
|
101
|
-
-
|
|
102
|
-
-
|
|
103
|
-
-
|
|
119
|
+
- d816af08: Update build and test configs use TypeScript
|
|
120
|
+
- 3891f544: Update babel config to include plugins that Storybook needed
|
|
121
|
+
- 0d28bb1c: Configured TypeScript
|
|
122
|
+
- 3d05f764: Fix HOCs and other type errors
|
|
123
|
+
- c2ec4902: Update eslint configuration, fix lint
|
|
124
|
+
- 2983c05b: Include 'types' field in package.json
|
|
125
|
+
- 77ff6a66: Generate Flow types from TypeScript types
|
|
126
|
+
- ec8d4b7f: Fix miscellaneous TypeScript errors
|
|
104
127
|
|
|
105
128
|
## 2.1.1
|
|
106
129
|
|
|
107
130
|
### Patch Changes
|
|
108
131
|
|
|
109
|
-
-
|
|
132
|
+
- 91cb727c: Remove file extensions from imports
|
|
110
133
|
|
|
111
134
|
## 2.1.0
|
|
112
135
|
|
|
113
136
|
### Minor Changes
|
|
114
137
|
|
|
115
|
-
-
|
|
116
|
-
|
|
117
|
-
-
|
|
118
|
-
|
|
119
|
-
-
|
|
120
|
-
|
|
138
|
+
- 029b4810: Adds `useInterval()` hook that mimics the behavior of `ActionScheduler`'s
|
|
139
|
+
`interval()` method.
|
|
140
|
+
- c57cd770: Rename `useInterval` and `useTimeout` to `useScheduledInterval`
|
|
141
|
+
and `useScheduledTimeout` respectively.
|
|
142
|
+
- 29766c8e: Add `useInterval` and `useTimeout` hooks to provide an API for
|
|
143
|
+
using intervals and timeouts.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Khan Academy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/es/index.js
CHANGED
|
@@ -193,18 +193,13 @@ class ActionSchedulerProvider extends React.Component {
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
function _extends() {
|
|
196
|
-
_extends = Object.assign ? Object.assign.bind() : function (
|
|
197
|
-
for (var
|
|
198
|
-
var
|
|
199
|
-
for (var
|
|
200
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
201
|
-
target[key] = source[key];
|
|
202
|
-
}
|
|
203
|
-
}
|
|
196
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
197
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
198
|
+
var t = arguments[e];
|
|
199
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
204
200
|
}
|
|
205
|
-
return
|
|
206
|
-
};
|
|
207
|
-
return _extends.apply(this, arguments);
|
|
201
|
+
return n;
|
|
202
|
+
}, _extends.apply(null, arguments);
|
|
208
203
|
}
|
|
209
204
|
|
|
210
205
|
function withActionScheduler(WrappedComponent) {
|
|
@@ -231,33 +226,33 @@ function useInterval(action, intervalMs, options = {}) {
|
|
|
231
226
|
actionProxyRef.current = action;
|
|
232
227
|
if (actionPolicy === ActionPolicy.Reset) {
|
|
233
228
|
var _intervalRef$current;
|
|
234
|
-
(_intervalRef$current = intervalRef.current) == null
|
|
229
|
+
(_intervalRef$current = intervalRef.current) == null || _intervalRef$current.set();
|
|
235
230
|
}
|
|
236
231
|
}
|
|
237
232
|
useEffect(() => {
|
|
238
233
|
intervalRef.current = new Interval(() => {
|
|
239
|
-
actionProxyRef.current == null
|
|
234
|
+
actionProxyRef.current == null || actionProxyRef.current();
|
|
240
235
|
}, intervalMs, schedulePolicy);
|
|
241
236
|
return () => {
|
|
242
237
|
var _intervalRef$current2;
|
|
243
|
-
(_intervalRef$current2 = intervalRef.current) == null
|
|
238
|
+
(_intervalRef$current2 = intervalRef.current) == null || _intervalRef$current2.clear(clearPolicy);
|
|
244
239
|
intervalRef.current = null;
|
|
245
240
|
};
|
|
246
241
|
}, [intervalMs, clearPolicy, schedulePolicy]);
|
|
247
242
|
const externalApi = useMemo(() => ({
|
|
248
243
|
set: () => {
|
|
249
244
|
var _intervalRef$current3;
|
|
250
|
-
(_intervalRef$current3 = intervalRef.current) == null
|
|
245
|
+
(_intervalRef$current3 = intervalRef.current) == null || _intervalRef$current3.set();
|
|
251
246
|
},
|
|
252
|
-
clear: policy => {
|
|
247
|
+
clear: (policy = clearPolicy) => {
|
|
253
248
|
var _intervalRef$current4;
|
|
254
|
-
(_intervalRef$current4 = intervalRef.current) == null
|
|
249
|
+
(_intervalRef$current4 = intervalRef.current) == null || _intervalRef$current4.clear(policy);
|
|
255
250
|
},
|
|
256
251
|
get isSet() {
|
|
257
252
|
var _intervalRef$current$, _intervalRef$current5;
|
|
258
253
|
return (_intervalRef$current$ = (_intervalRef$current5 = intervalRef.current) == null ? void 0 : _intervalRef$current5.isSet) != null ? _intervalRef$current$ : false;
|
|
259
254
|
}
|
|
260
|
-
}), []);
|
|
255
|
+
}), [clearPolicy]);
|
|
261
256
|
return externalApi;
|
|
262
257
|
}
|
|
263
258
|
|
|
@@ -276,33 +271,33 @@ function useTimeout(action, timeoutMs, options = {}) {
|
|
|
276
271
|
actionProxyRef.current = action;
|
|
277
272
|
if (actionPolicy === ActionPolicy.Reset) {
|
|
278
273
|
var _timeoutRef$current;
|
|
279
|
-
(_timeoutRef$current = timeoutRef.current) == null
|
|
274
|
+
(_timeoutRef$current = timeoutRef.current) == null || _timeoutRef$current.set();
|
|
280
275
|
}
|
|
281
276
|
}
|
|
282
277
|
useEffect(() => {
|
|
283
278
|
timeoutRef.current = new Timeout(() => {
|
|
284
|
-
actionProxyRef.current == null
|
|
279
|
+
actionProxyRef.current == null || actionProxyRef.current();
|
|
285
280
|
}, timeoutMs, schedulePolicy);
|
|
286
281
|
return () => {
|
|
287
282
|
var _timeoutRef$current2;
|
|
288
|
-
(_timeoutRef$current2 = timeoutRef.current) == null
|
|
283
|
+
(_timeoutRef$current2 = timeoutRef.current) == null || _timeoutRef$current2.clear(clearPolicy);
|
|
289
284
|
timeoutRef.current = null;
|
|
290
285
|
};
|
|
291
286
|
}, [timeoutMs, clearPolicy, schedulePolicy]);
|
|
292
287
|
const externalApi = useMemo(() => ({
|
|
293
288
|
set: () => {
|
|
294
289
|
var _timeoutRef$current3;
|
|
295
|
-
(_timeoutRef$current3 = timeoutRef.current) == null
|
|
290
|
+
(_timeoutRef$current3 = timeoutRef.current) == null || _timeoutRef$current3.set();
|
|
296
291
|
},
|
|
297
|
-
clear: policy => {
|
|
292
|
+
clear: (policy = clearPolicy) => {
|
|
298
293
|
var _timeoutRef$current4;
|
|
299
|
-
(_timeoutRef$current4 = timeoutRef.current) == null
|
|
294
|
+
(_timeoutRef$current4 = timeoutRef.current) == null || _timeoutRef$current4.clear(policy);
|
|
300
295
|
},
|
|
301
296
|
get isSet() {
|
|
302
297
|
var _timeoutRef$current$i, _timeoutRef$current5;
|
|
303
298
|
return (_timeoutRef$current$i = (_timeoutRef$current5 = timeoutRef.current) == null ? void 0 : _timeoutRef$current5.isSet) != null ? _timeoutRef$current$i : false;
|
|
304
299
|
}
|
|
305
|
-
}), []);
|
|
300
|
+
}), [clearPolicy]);
|
|
306
301
|
return externalApi;
|
|
307
302
|
}
|
|
308
303
|
|
|
@@ -25,6 +25,8 @@ import type { IInterval, HookOptions } from "../util/types";
|
|
|
25
25
|
* scheduling the interval, use `SchedulePolicy.OnDemand`.
|
|
26
26
|
* @returns An `IInterval` API for interacting with the given interval. This
|
|
27
27
|
* API is a no-op if called when not mounted. This means that any calls prior
|
|
28
|
-
* to mounting or after unmounting will not have any effect.
|
|
28
|
+
* to mounting or after unmounting will not have any effect. This API is
|
|
29
|
+
* not reactive, so do not deconstruct the return value, but instead
|
|
30
|
+
* dereference it at the time of use.
|
|
29
31
|
*/
|
|
30
32
|
export declare function useInterval(action: () => unknown, intervalMs: number, options?: HookOptions): IInterval;
|
|
@@ -25,6 +25,8 @@ import type { ITimeout, HookOptions } from "../util/types";
|
|
|
25
25
|
* scheduling the timeout, use `SchedulePolicy.OnDemand`.
|
|
26
26
|
* @returns An `ITimeout` API for interacting with the given timeout. This
|
|
27
27
|
* API is a no-op if called when not mounted. This means that any calls prior
|
|
28
|
-
* to mounting or after unmounting will not have any effect.
|
|
28
|
+
* to mounting or after unmounting will not have any effect. This API is
|
|
29
|
+
* not reactive, so do not deconstruct the return value, but instead
|
|
30
|
+
* dereference it at the time of use.
|
|
29
31
|
*/
|
|
30
32
|
export declare function useTimeout(action: () => unknown, timeoutMs: number, options?: HookOptions): ITimeout;
|
package/dist/index.js
CHANGED
|
@@ -216,18 +216,13 @@ class ActionSchedulerProvider extends React__namespace.Component {
|
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
function _extends() {
|
|
219
|
-
_extends = Object.assign ? Object.assign.bind() : function (
|
|
220
|
-
for (var
|
|
221
|
-
var
|
|
222
|
-
for (var
|
|
223
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
224
|
-
target[key] = source[key];
|
|
225
|
-
}
|
|
226
|
-
}
|
|
219
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
220
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
221
|
+
var t = arguments[e];
|
|
222
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
227
223
|
}
|
|
228
|
-
return
|
|
229
|
-
};
|
|
230
|
-
return _extends.apply(this, arguments);
|
|
224
|
+
return n;
|
|
225
|
+
}, _extends.apply(null, arguments);
|
|
231
226
|
}
|
|
232
227
|
|
|
233
228
|
function withActionScheduler(WrappedComponent) {
|
|
@@ -254,33 +249,33 @@ function useInterval(action, intervalMs, options = {}) {
|
|
|
254
249
|
actionProxyRef.current = action;
|
|
255
250
|
if (actionPolicy === ActionPolicy.Reset) {
|
|
256
251
|
var _intervalRef$current;
|
|
257
|
-
(_intervalRef$current = intervalRef.current) == null
|
|
252
|
+
(_intervalRef$current = intervalRef.current) == null || _intervalRef$current.set();
|
|
258
253
|
}
|
|
259
254
|
}
|
|
260
255
|
React.useEffect(() => {
|
|
261
256
|
intervalRef.current = new Interval(() => {
|
|
262
|
-
actionProxyRef.current == null
|
|
257
|
+
actionProxyRef.current == null || actionProxyRef.current();
|
|
263
258
|
}, intervalMs, schedulePolicy);
|
|
264
259
|
return () => {
|
|
265
260
|
var _intervalRef$current2;
|
|
266
|
-
(_intervalRef$current2 = intervalRef.current) == null
|
|
261
|
+
(_intervalRef$current2 = intervalRef.current) == null || _intervalRef$current2.clear(clearPolicy);
|
|
267
262
|
intervalRef.current = null;
|
|
268
263
|
};
|
|
269
264
|
}, [intervalMs, clearPolicy, schedulePolicy]);
|
|
270
265
|
const externalApi = React.useMemo(() => ({
|
|
271
266
|
set: () => {
|
|
272
267
|
var _intervalRef$current3;
|
|
273
|
-
(_intervalRef$current3 = intervalRef.current) == null
|
|
268
|
+
(_intervalRef$current3 = intervalRef.current) == null || _intervalRef$current3.set();
|
|
274
269
|
},
|
|
275
|
-
clear: policy => {
|
|
270
|
+
clear: (policy = clearPolicy) => {
|
|
276
271
|
var _intervalRef$current4;
|
|
277
|
-
(_intervalRef$current4 = intervalRef.current) == null
|
|
272
|
+
(_intervalRef$current4 = intervalRef.current) == null || _intervalRef$current4.clear(policy);
|
|
278
273
|
},
|
|
279
274
|
get isSet() {
|
|
280
275
|
var _intervalRef$current$, _intervalRef$current5;
|
|
281
276
|
return (_intervalRef$current$ = (_intervalRef$current5 = intervalRef.current) == null ? void 0 : _intervalRef$current5.isSet) != null ? _intervalRef$current$ : false;
|
|
282
277
|
}
|
|
283
|
-
}), []);
|
|
278
|
+
}), [clearPolicy]);
|
|
284
279
|
return externalApi;
|
|
285
280
|
}
|
|
286
281
|
|
|
@@ -299,33 +294,33 @@ function useTimeout(action, timeoutMs, options = {}) {
|
|
|
299
294
|
actionProxyRef.current = action;
|
|
300
295
|
if (actionPolicy === ActionPolicy.Reset) {
|
|
301
296
|
var _timeoutRef$current;
|
|
302
|
-
(_timeoutRef$current = timeoutRef.current) == null
|
|
297
|
+
(_timeoutRef$current = timeoutRef.current) == null || _timeoutRef$current.set();
|
|
303
298
|
}
|
|
304
299
|
}
|
|
305
300
|
React.useEffect(() => {
|
|
306
301
|
timeoutRef.current = new Timeout(() => {
|
|
307
|
-
actionProxyRef.current == null
|
|
302
|
+
actionProxyRef.current == null || actionProxyRef.current();
|
|
308
303
|
}, timeoutMs, schedulePolicy);
|
|
309
304
|
return () => {
|
|
310
305
|
var _timeoutRef$current2;
|
|
311
|
-
(_timeoutRef$current2 = timeoutRef.current) == null
|
|
306
|
+
(_timeoutRef$current2 = timeoutRef.current) == null || _timeoutRef$current2.clear(clearPolicy);
|
|
312
307
|
timeoutRef.current = null;
|
|
313
308
|
};
|
|
314
309
|
}, [timeoutMs, clearPolicy, schedulePolicy]);
|
|
315
310
|
const externalApi = React.useMemo(() => ({
|
|
316
311
|
set: () => {
|
|
317
312
|
var _timeoutRef$current3;
|
|
318
|
-
(_timeoutRef$current3 = timeoutRef.current) == null
|
|
313
|
+
(_timeoutRef$current3 = timeoutRef.current) == null || _timeoutRef$current3.set();
|
|
319
314
|
},
|
|
320
|
-
clear: policy => {
|
|
315
|
+
clear: (policy = clearPolicy) => {
|
|
321
316
|
var _timeoutRef$current4;
|
|
322
|
-
(_timeoutRef$current4 = timeoutRef.current) == null
|
|
317
|
+
(_timeoutRef$current4 = timeoutRef.current) == null || _timeoutRef$current4.clear(policy);
|
|
323
318
|
},
|
|
324
319
|
get isSet() {
|
|
325
320
|
var _timeoutRef$current$i, _timeoutRef$current5;
|
|
326
321
|
return (_timeoutRef$current$i = (_timeoutRef$current5 = timeoutRef.current) == null ? void 0 : _timeoutRef$current5.isSet) != null ? _timeoutRef$current$i : false;
|
|
327
322
|
}
|
|
328
|
-
}), []);
|
|
323
|
+
}), [clearPolicy]);
|
|
329
324
|
return externalApi;
|
|
330
325
|
}
|
|
331
326
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-timing",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "7.0.1",
|
|
5
5
|
"design": "v1",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -10,17 +10,16 @@
|
|
|
10
10
|
"main": "dist/index.js",
|
|
11
11
|
"module": "dist/es/index.js",
|
|
12
12
|
"types": "dist/index.d.ts",
|
|
13
|
-
"scripts": {
|
|
14
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
15
|
-
"prepublishOnly": "../../utils/publish/package-pre-publish-check.sh"
|
|
16
|
-
},
|
|
17
13
|
"peerDependencies": {
|
|
18
14
|
"react": "18.2.0"
|
|
19
15
|
},
|
|
20
16
|
"devDependencies": {
|
|
21
|
-
"@khanacademy/wb-dev-build-settings": "
|
|
22
|
-
"@khanacademy/wonder-blocks-testing-core": "
|
|
17
|
+
"@khanacademy/wb-dev-build-settings": "2.1.1",
|
|
18
|
+
"@khanacademy/wonder-blocks-testing-core": "2.1.1"
|
|
23
19
|
},
|
|
24
20
|
"author": "",
|
|
25
|
-
"license": "MIT"
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
24
|
+
}
|
|
26
25
|
}
|