@khanacademy/wonder-blocks-timing 7.0.0 → 7.0.2
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 +12 -0
- package/dist/es/index.js +16 -16
- package/dist/index.js +22 -19
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-timing
|
|
2
2
|
|
|
3
|
+
## 7.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1d7be37: Use pnpm catalog to pin dependency versions across packages
|
|
8
|
+
|
|
9
|
+
## 7.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- ee8d95a: Rollback rollup version from v4 to v2 to prevent an issue with CJS builds in unit tests
|
|
14
|
+
|
|
3
15
|
## 7.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
package/dist/es/index.js
CHANGED
|
@@ -19,9 +19,9 @@ let ActionPolicy = function (ActionPolicy) {
|
|
|
19
19
|
|
|
20
20
|
class Timeout {
|
|
21
21
|
constructor(action, timeoutMs, schedulePolicy = SchedulePolicy.Immediately) {
|
|
22
|
-
this._timeoutId =
|
|
23
|
-
this._action =
|
|
24
|
-
this._timeoutMs =
|
|
22
|
+
this._timeoutId = void 0;
|
|
23
|
+
this._action = void 0;
|
|
24
|
+
this._timeoutMs = void 0;
|
|
25
25
|
if (typeof action !== "function") {
|
|
26
26
|
throw new Error("Action must be a function");
|
|
27
27
|
}
|
|
@@ -58,9 +58,9 @@ class Timeout {
|
|
|
58
58
|
|
|
59
59
|
class Interval {
|
|
60
60
|
constructor(action, intervalMs, schedulePolicy = SchedulePolicy.Immediately) {
|
|
61
|
-
this._intervalId =
|
|
62
|
-
this._action =
|
|
63
|
-
this._intervalMs =
|
|
61
|
+
this._intervalId = void 0;
|
|
62
|
+
this._action = void 0;
|
|
63
|
+
this._intervalMs = void 0;
|
|
64
64
|
if (typeof action !== "function") {
|
|
65
65
|
throw new Error("Action must be a function");
|
|
66
66
|
}
|
|
@@ -97,8 +97,8 @@ class Interval {
|
|
|
97
97
|
|
|
98
98
|
class AnimationFrame {
|
|
99
99
|
constructor(action, schedulePolicy = SchedulePolicy.Immediately) {
|
|
100
|
-
this._animationFrameId =
|
|
101
|
-
this._action =
|
|
100
|
+
this._animationFrameId = void 0;
|
|
101
|
+
this._action = void 0;
|
|
102
102
|
if (typeof action !== "function") {
|
|
103
103
|
throw new Error("Action must be a function");
|
|
104
104
|
}
|
|
@@ -138,24 +138,24 @@ class ActionScheduler {
|
|
|
138
138
|
if (this._disabled) {
|
|
139
139
|
return ActionScheduler.NoopAction;
|
|
140
140
|
}
|
|
141
|
-
const timeout = new Timeout(action, period, options == null ?
|
|
142
|
-
this._registeredActions.push(() => timeout.clear(options == null ?
|
|
141
|
+
const timeout = new Timeout(action, period, options == null ? void 0 : options.schedulePolicy);
|
|
142
|
+
this._registeredActions.push(() => timeout.clear(options == null ? void 0 : options.clearPolicy));
|
|
143
143
|
return timeout;
|
|
144
144
|
}
|
|
145
145
|
interval(action, period, options) {
|
|
146
146
|
if (this._disabled) {
|
|
147
147
|
return ActionScheduler.NoopAction;
|
|
148
148
|
}
|
|
149
|
-
const interval = new Interval(action, period, options == null ?
|
|
150
|
-
this._registeredActions.push(() => interval.clear(options == null ?
|
|
149
|
+
const interval = new Interval(action, period, options == null ? void 0 : options.schedulePolicy);
|
|
150
|
+
this._registeredActions.push(() => interval.clear(options == null ? void 0 : options.clearPolicy));
|
|
151
151
|
return interval;
|
|
152
152
|
}
|
|
153
153
|
animationFrame(action, options) {
|
|
154
154
|
if (this._disabled) {
|
|
155
155
|
return ActionScheduler.NoopAction;
|
|
156
156
|
}
|
|
157
|
-
const animationFrame = new AnimationFrame(action, options == null ?
|
|
158
|
-
this._registeredActions.push(() => animationFrame.clear(options == null ?
|
|
157
|
+
const animationFrame = new AnimationFrame(action, options == null ? void 0 : options.schedulePolicy);
|
|
158
|
+
this._registeredActions.push(() => animationFrame.clear(options == null ? void 0 : options.clearPolicy));
|
|
159
159
|
return animationFrame;
|
|
160
160
|
}
|
|
161
161
|
clearAll() {
|
|
@@ -250,7 +250,7 @@ function useInterval(action, intervalMs, options = {}) {
|
|
|
250
250
|
},
|
|
251
251
|
get isSet() {
|
|
252
252
|
var _intervalRef$current$, _intervalRef$current5;
|
|
253
|
-
return (_intervalRef$current$ = (_intervalRef$current5 = intervalRef.current) == null ?
|
|
253
|
+
return (_intervalRef$current$ = (_intervalRef$current5 = intervalRef.current) == null ? void 0 : _intervalRef$current5.isSet) != null ? _intervalRef$current$ : false;
|
|
254
254
|
}
|
|
255
255
|
}), [clearPolicy]);
|
|
256
256
|
return externalApi;
|
|
@@ -295,7 +295,7 @@ function useTimeout(action, timeoutMs, options = {}) {
|
|
|
295
295
|
},
|
|
296
296
|
get isSet() {
|
|
297
297
|
var _timeoutRef$current$i, _timeoutRef$current5;
|
|
298
|
-
return (_timeoutRef$current$i = (_timeoutRef$current5 = timeoutRef.current) == null ?
|
|
298
|
+
return (_timeoutRef$current$i = (_timeoutRef$current5 = timeoutRef.current) == null ? void 0 : _timeoutRef$current5.isSet) != null ? _timeoutRef$current$i : false;
|
|
299
299
|
}
|
|
300
300
|
}), [clearPolicy]);
|
|
301
301
|
return externalApi;
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var React = require('react');
|
|
4
6
|
|
|
5
|
-
function
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
6
9
|
var n = Object.create(null);
|
|
7
10
|
if (e) {
|
|
8
11
|
Object.keys(e).forEach(function (k) {
|
|
@@ -15,11 +18,11 @@ function _interopNamespaceDefault(e) {
|
|
|
15
18
|
}
|
|
16
19
|
});
|
|
17
20
|
}
|
|
18
|
-
n
|
|
21
|
+
n["default"] = e;
|
|
19
22
|
return Object.freeze(n);
|
|
20
23
|
}
|
|
21
24
|
|
|
22
|
-
var React__namespace = /*#__PURE__*/
|
|
25
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
23
26
|
|
|
24
27
|
let SchedulePolicy = function (SchedulePolicy) {
|
|
25
28
|
SchedulePolicy["Immediately"] = "schedule-immediately";
|
|
@@ -39,9 +42,9 @@ let ActionPolicy = function (ActionPolicy) {
|
|
|
39
42
|
|
|
40
43
|
class Timeout {
|
|
41
44
|
constructor(action, timeoutMs, schedulePolicy = SchedulePolicy.Immediately) {
|
|
42
|
-
this._timeoutId =
|
|
43
|
-
this._action =
|
|
44
|
-
this._timeoutMs =
|
|
45
|
+
this._timeoutId = void 0;
|
|
46
|
+
this._action = void 0;
|
|
47
|
+
this._timeoutMs = void 0;
|
|
45
48
|
if (typeof action !== "function") {
|
|
46
49
|
throw new Error("Action must be a function");
|
|
47
50
|
}
|
|
@@ -78,9 +81,9 @@ class Timeout {
|
|
|
78
81
|
|
|
79
82
|
class Interval {
|
|
80
83
|
constructor(action, intervalMs, schedulePolicy = SchedulePolicy.Immediately) {
|
|
81
|
-
this._intervalId =
|
|
82
|
-
this._action =
|
|
83
|
-
this._intervalMs =
|
|
84
|
+
this._intervalId = void 0;
|
|
85
|
+
this._action = void 0;
|
|
86
|
+
this._intervalMs = void 0;
|
|
84
87
|
if (typeof action !== "function") {
|
|
85
88
|
throw new Error("Action must be a function");
|
|
86
89
|
}
|
|
@@ -117,8 +120,8 @@ class Interval {
|
|
|
117
120
|
|
|
118
121
|
class AnimationFrame {
|
|
119
122
|
constructor(action, schedulePolicy = SchedulePolicy.Immediately) {
|
|
120
|
-
this._animationFrameId =
|
|
121
|
-
this._action =
|
|
123
|
+
this._animationFrameId = void 0;
|
|
124
|
+
this._action = void 0;
|
|
122
125
|
if (typeof action !== "function") {
|
|
123
126
|
throw new Error("Action must be a function");
|
|
124
127
|
}
|
|
@@ -158,24 +161,24 @@ class ActionScheduler {
|
|
|
158
161
|
if (this._disabled) {
|
|
159
162
|
return ActionScheduler.NoopAction;
|
|
160
163
|
}
|
|
161
|
-
const timeout = new Timeout(action, period, options == null ?
|
|
162
|
-
this._registeredActions.push(() => timeout.clear(options == null ?
|
|
164
|
+
const timeout = new Timeout(action, period, options == null ? void 0 : options.schedulePolicy);
|
|
165
|
+
this._registeredActions.push(() => timeout.clear(options == null ? void 0 : options.clearPolicy));
|
|
163
166
|
return timeout;
|
|
164
167
|
}
|
|
165
168
|
interval(action, period, options) {
|
|
166
169
|
if (this._disabled) {
|
|
167
170
|
return ActionScheduler.NoopAction;
|
|
168
171
|
}
|
|
169
|
-
const interval = new Interval(action, period, options == null ?
|
|
170
|
-
this._registeredActions.push(() => interval.clear(options == null ?
|
|
172
|
+
const interval = new Interval(action, period, options == null ? void 0 : options.schedulePolicy);
|
|
173
|
+
this._registeredActions.push(() => interval.clear(options == null ? void 0 : options.clearPolicy));
|
|
171
174
|
return interval;
|
|
172
175
|
}
|
|
173
176
|
animationFrame(action, options) {
|
|
174
177
|
if (this._disabled) {
|
|
175
178
|
return ActionScheduler.NoopAction;
|
|
176
179
|
}
|
|
177
|
-
const animationFrame = new AnimationFrame(action, options == null ?
|
|
178
|
-
this._registeredActions.push(() => animationFrame.clear(options == null ?
|
|
180
|
+
const animationFrame = new AnimationFrame(action, options == null ? void 0 : options.schedulePolicy);
|
|
181
|
+
this._registeredActions.push(() => animationFrame.clear(options == null ? void 0 : options.clearPolicy));
|
|
179
182
|
return animationFrame;
|
|
180
183
|
}
|
|
181
184
|
clearAll() {
|
|
@@ -270,7 +273,7 @@ function useInterval(action, intervalMs, options = {}) {
|
|
|
270
273
|
},
|
|
271
274
|
get isSet() {
|
|
272
275
|
var _intervalRef$current$, _intervalRef$current5;
|
|
273
|
-
return (_intervalRef$current$ = (_intervalRef$current5 = intervalRef.current) == null ?
|
|
276
|
+
return (_intervalRef$current$ = (_intervalRef$current5 = intervalRef.current) == null ? void 0 : _intervalRef$current5.isSet) != null ? _intervalRef$current$ : false;
|
|
274
277
|
}
|
|
275
278
|
}), [clearPolicy]);
|
|
276
279
|
return externalApi;
|
|
@@ -315,7 +318,7 @@ function useTimeout(action, timeoutMs, options = {}) {
|
|
|
315
318
|
},
|
|
316
319
|
get isSet() {
|
|
317
320
|
var _timeoutRef$current$i, _timeoutRef$current5;
|
|
318
|
-
return (_timeoutRef$current$i = (_timeoutRef$current5 = timeoutRef.current) == null ?
|
|
321
|
+
return (_timeoutRef$current$i = (_timeoutRef$current5 = timeoutRef.current) == null ? void 0 : _timeoutRef$current5.isSet) != null ? _timeoutRef$current$i : false;
|
|
319
322
|
}
|
|
320
323
|
}), [clearPolicy]);
|
|
321
324
|
return externalApi;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-timing",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.2",
|
|
5
5
|
"design": "v1",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"react": "18.2.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@khanacademy/wb-dev-build-settings": "2.1.
|
|
18
|
-
"@khanacademy/wonder-blocks-testing-core": "2.1
|
|
17
|
+
"@khanacademy/wb-dev-build-settings": "2.1.1",
|
|
18
|
+
"@khanacademy/wonder-blocks-testing-core": "2.2.1"
|
|
19
19
|
},
|
|
20
20
|
"author": "",
|
|
21
21
|
"license": "MIT",
|