@atlaskit/insm 1.2.12 → 2.0.0

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.
@@ -1,193 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.AnimationFPSIM = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
- var AnimationFPSIM = exports.AnimationFPSIM = /*#__PURE__*/function () {
12
- function AnimationFPSIM() {
13
- (0, _classCallCheck2.default)(this, AnimationFPSIM);
14
- /**
15
- * AFPS stands for Animation Frames Per Second
16
- */
17
- (0, _defineProperty2.default)(this, "name", 'afps');
18
- (0, _defineProperty2.default)(this, "monitor", new AnimationFPSMonitor());
19
- }
20
- return (0, _createClass2.default)(AnimationFPSIM, [{
21
- key: "start",
22
- value: function start(paused) {
23
- var result = this.monitor.startNewWindow(paused);
24
- return result;
25
- }
26
- }, {
27
- key: "end",
28
- value: function end() {
29
- var result = this.monitor.end();
30
- return result;
31
- }
32
- }, {
33
- key: "pause",
34
- value: function pause() {
35
- this.monitor.pause();
36
- }
37
- }, {
38
- key: "resume",
39
- value: function resume() {
40
- this.monitor.resume();
41
- }
42
- }]);
43
- }();
44
- var AnimationFPSMonitor = /*#__PURE__*/function () {
45
- function AnimationFPSMonitor() {
46
- (0, _classCallCheck2.default)(this, AnimationFPSMonitor);
47
- (0, _defineProperty2.default)(this, "paused", false);
48
- (0, _defineProperty2.default)(this, "currentState", {
49
- numerator: 0,
50
- denominator: 0,
51
- max: 0,
52
- average: 0,
53
- min: 0
54
- });
55
- // Current measurement window
56
- (0, _defineProperty2.default)(this, "windowFrameCount", 0);
57
- (0, _defineProperty2.default)(this, "windowTotalTime", 0);
58
- (0, _defineProperty2.default)(this, "currentFrameStart", 0);
59
- }
60
- return (0, _createClass2.default)(AnimationFPSMonitor, [{
61
- key: "measureWindowFPS",
62
- value: function measureWindowFPS() {
63
- // Calculate FPS for this window
64
- // Note: windowFrameCount and windowTotalTime is reset after each window measurement
65
- var windowSeconds = this.windowTotalTime / 1000;
66
- // frames / seconds
67
- var windowFPS = this.windowFrameCount / windowSeconds;
68
-
69
- // Update overall tracking
70
- this.currentState.numerator += this.windowFrameCount;
71
- // The denominator is seconds not ms
72
- this.currentState.denominator += windowSeconds;
73
-
74
- // Calculate overall average FPS: (total frames / total time measured in seconds
75
- this.currentState.average = this.currentState.numerator / this.currentState.denominator;
76
- if (this.currentState.max === 0 || windowFPS > this.currentState.max) {
77
- this.currentState.max = windowFPS;
78
- }
79
- if (this.currentState.min === 0 || windowFPS < this.currentState.min) {
80
- this.currentState.min = windowFPS;
81
- }
82
- }
83
-
84
- /**
85
- * If there is running tracking - it will be reset
86
- */
87
- }, {
88
- key: "startWindowTracking",
89
- value: function startWindowTracking() {
90
- var _this = this;
91
- // Clear any previous tracking state
92
- this.resetOverallTracking();
93
- var _measureFrame = function measureFrame() {
94
- _this.currentFrameStart = global.performance.now();
95
- _this.animationFrame = requestAnimationFrame(function () {
96
- // While measurement is paused -- we don't count the animation frame towards the monitored
97
- // period.
98
- if (!_this.paused) {
99
- var frameDuration = performance.now() - _this.currentFrameStart;
100
-
101
- // Add frame to current window
102
- _this.windowFrameCount++;
103
- _this.windowTotalTime += frameDuration;
104
-
105
- // Check if window is >= 1 second (1000ms)
106
- // When the page is running smoothly it's expected this will not be hit frequently
107
- if (_this.windowTotalTime >= 1000) {
108
- _this.measureWindowFPS();
109
- // Reset window for next measurement
110
- _this.resetWindow();
111
- }
112
- }
113
- _measureFrame();
114
- });
115
- };
116
- _measureFrame();
117
- }
118
- }, {
119
- key: "startNewWindow",
120
- value: function startNewWindow(paused) {
121
- var lastWindowResult = {
122
- numerator: this.currentState.numerator,
123
- denominator: this.currentState.denominator,
124
- max: this.currentState.max,
125
- min: this.currentState.min,
126
- average: this.currentState.average
127
- };
128
- this.paused = paused;
129
- this.startWindowTracking();
130
- return lastWindowResult;
131
- }
132
- }, {
133
- key: "resetWindow",
134
- value: function resetWindow() {
135
- this.windowFrameCount = 0;
136
- this.windowTotalTime = 0;
137
- // Note this.currentFrameStart is over ridden
138
- // as part of tracking - so does not need to be
139
- // reset.
140
- }
141
- }, {
142
- key: "endWindowTracking",
143
- value: function endWindowTracking() {
144
- if (this.animationFrame) {
145
- cancelAnimationFrame(this.animationFrame);
146
- }
147
- }
148
- }, {
149
- key: "resetOverallTracking",
150
- value: function resetOverallTracking() {
151
- this.resetWindow();
152
- this.endWindowTracking();
153
- this.currentState = {
154
- numerator: 0,
155
- denominator: 0,
156
- max: 0,
157
- min: 0,
158
- average: 0
159
- };
160
- }
161
- }, {
162
- key: "end",
163
- value: function end() {
164
- try {
165
- this.measureWindowFPS();
166
- return this.currentState;
167
- } finally {
168
- this.resetOverallTracking();
169
- }
170
- }
171
- }, {
172
- key: "pause",
173
- value: function pause() {
174
- // Note - we leave the tracking animationFrame monitoring running, and on resume
175
- // simply set the currentFrameStart and paused to true
176
- // This works because the tracking builds windows of tracked time rather than
177
- // basing itself off a window start time and time elapsed time since then.
178
- this.paused = true;
179
- }
180
- }, {
181
- key: "resume",
182
- value: function resume() {
183
- // Note - We don't need to handle the gap in measurement - as the raf logic builds/increments a window time
184
- // based on the currentFrameStart (and any previous measurements which can only happen while the tracking
185
- // is not paused).
186
- this.currentFrameStart = performance.now();
187
- this.paused = false;
188
- if (!this.animationFrame) {
189
- this.startWindowTracking();
190
- }
191
- }
192
- }]);
193
- }();
@@ -1,153 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- export class AnimationFPSIM {
3
- constructor() {
4
- /**
5
- * AFPS stands for Animation Frames Per Second
6
- */
7
- _defineProperty(this, "name", 'afps');
8
- _defineProperty(this, "monitor", new AnimationFPSMonitor());
9
- }
10
- start(paused) {
11
- const result = this.monitor.startNewWindow(paused);
12
- return result;
13
- }
14
- end() {
15
- const result = this.monitor.end();
16
- return result;
17
- }
18
- pause() {
19
- this.monitor.pause();
20
- }
21
- resume() {
22
- this.monitor.resume();
23
- }
24
- }
25
- class AnimationFPSMonitor {
26
- constructor() {
27
- _defineProperty(this, "paused", false);
28
- _defineProperty(this, "currentState", {
29
- numerator: 0,
30
- denominator: 0,
31
- max: 0,
32
- average: 0,
33
- min: 0
34
- });
35
- // Current measurement window
36
- _defineProperty(this, "windowFrameCount", 0);
37
- _defineProperty(this, "windowTotalTime", 0);
38
- _defineProperty(this, "currentFrameStart", 0);
39
- }
40
- measureWindowFPS() {
41
- // Calculate FPS for this window
42
- // Note: windowFrameCount and windowTotalTime is reset after each window measurement
43
- const windowSeconds = this.windowTotalTime / 1000;
44
- // frames / seconds
45
- const windowFPS = this.windowFrameCount / windowSeconds;
46
-
47
- // Update overall tracking
48
- this.currentState.numerator += this.windowFrameCount;
49
- // The denominator is seconds not ms
50
- this.currentState.denominator += windowSeconds;
51
-
52
- // Calculate overall average FPS: (total frames / total time measured in seconds
53
- this.currentState.average = this.currentState.numerator / this.currentState.denominator;
54
- if (this.currentState.max === 0 || windowFPS > this.currentState.max) {
55
- this.currentState.max = windowFPS;
56
- }
57
- if (this.currentState.min === 0 || windowFPS < this.currentState.min) {
58
- this.currentState.min = windowFPS;
59
- }
60
- }
61
-
62
- /**
63
- * If there is running tracking - it will be reset
64
- */
65
- startWindowTracking() {
66
- // Clear any previous tracking state
67
- this.resetOverallTracking();
68
- const measureFrame = () => {
69
- this.currentFrameStart = global.performance.now();
70
- this.animationFrame = requestAnimationFrame(() => {
71
- // While measurement is paused -- we don't count the animation frame towards the monitored
72
- // period.
73
- if (!this.paused) {
74
- const frameDuration = performance.now() - this.currentFrameStart;
75
-
76
- // Add frame to current window
77
- this.windowFrameCount++;
78
- this.windowTotalTime += frameDuration;
79
-
80
- // Check if window is >= 1 second (1000ms)
81
- // When the page is running smoothly it's expected this will not be hit frequently
82
- if (this.windowTotalTime >= 1000) {
83
- this.measureWindowFPS();
84
- // Reset window for next measurement
85
- this.resetWindow();
86
- }
87
- }
88
- measureFrame();
89
- });
90
- };
91
- measureFrame();
92
- }
93
- startNewWindow(paused) {
94
- const lastWindowResult = {
95
- numerator: this.currentState.numerator,
96
- denominator: this.currentState.denominator,
97
- max: this.currentState.max,
98
- min: this.currentState.min,
99
- average: this.currentState.average
100
- };
101
- this.paused = paused;
102
- this.startWindowTracking();
103
- return lastWindowResult;
104
- }
105
- resetWindow() {
106
- this.windowFrameCount = 0;
107
- this.windowTotalTime = 0;
108
- // Note this.currentFrameStart is over ridden
109
- // as part of tracking - so does not need to be
110
- // reset.
111
- }
112
- endWindowTracking() {
113
- if (this.animationFrame) {
114
- cancelAnimationFrame(this.animationFrame);
115
- }
116
- }
117
- resetOverallTracking() {
118
- this.resetWindow();
119
- this.endWindowTracking();
120
- this.currentState = {
121
- numerator: 0,
122
- denominator: 0,
123
- max: 0,
124
- min: 0,
125
- average: 0
126
- };
127
- }
128
- end() {
129
- try {
130
- this.measureWindowFPS();
131
- return this.currentState;
132
- } finally {
133
- this.resetOverallTracking();
134
- }
135
- }
136
- pause() {
137
- // Note - we leave the tracking animationFrame monitoring running, and on resume
138
- // simply set the currentFrameStart and paused to true
139
- // This works because the tracking builds windows of tracked time rather than
140
- // basing itself off a window start time and time elapsed time since then.
141
- this.paused = true;
142
- }
143
- resume() {
144
- // Note - We don't need to handle the gap in measurement - as the raf logic builds/increments a window time
145
- // based on the currentFrameStart (and any previous measurements which can only happen while the tracking
146
- // is not paused).
147
- this.currentFrameStart = performance.now();
148
- this.paused = false;
149
- if (!this.animationFrame) {
150
- this.startWindowTracking();
151
- }
152
- }
153
- }
@@ -1,186 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
- export var AnimationFPSIM = /*#__PURE__*/function () {
5
- function AnimationFPSIM() {
6
- _classCallCheck(this, AnimationFPSIM);
7
- /**
8
- * AFPS stands for Animation Frames Per Second
9
- */
10
- _defineProperty(this, "name", 'afps');
11
- _defineProperty(this, "monitor", new AnimationFPSMonitor());
12
- }
13
- return _createClass(AnimationFPSIM, [{
14
- key: "start",
15
- value: function start(paused) {
16
- var result = this.monitor.startNewWindow(paused);
17
- return result;
18
- }
19
- }, {
20
- key: "end",
21
- value: function end() {
22
- var result = this.monitor.end();
23
- return result;
24
- }
25
- }, {
26
- key: "pause",
27
- value: function pause() {
28
- this.monitor.pause();
29
- }
30
- }, {
31
- key: "resume",
32
- value: function resume() {
33
- this.monitor.resume();
34
- }
35
- }]);
36
- }();
37
- var AnimationFPSMonitor = /*#__PURE__*/function () {
38
- function AnimationFPSMonitor() {
39
- _classCallCheck(this, AnimationFPSMonitor);
40
- _defineProperty(this, "paused", false);
41
- _defineProperty(this, "currentState", {
42
- numerator: 0,
43
- denominator: 0,
44
- max: 0,
45
- average: 0,
46
- min: 0
47
- });
48
- // Current measurement window
49
- _defineProperty(this, "windowFrameCount", 0);
50
- _defineProperty(this, "windowTotalTime", 0);
51
- _defineProperty(this, "currentFrameStart", 0);
52
- }
53
- return _createClass(AnimationFPSMonitor, [{
54
- key: "measureWindowFPS",
55
- value: function measureWindowFPS() {
56
- // Calculate FPS for this window
57
- // Note: windowFrameCount and windowTotalTime is reset after each window measurement
58
- var windowSeconds = this.windowTotalTime / 1000;
59
- // frames / seconds
60
- var windowFPS = this.windowFrameCount / windowSeconds;
61
-
62
- // Update overall tracking
63
- this.currentState.numerator += this.windowFrameCount;
64
- // The denominator is seconds not ms
65
- this.currentState.denominator += windowSeconds;
66
-
67
- // Calculate overall average FPS: (total frames / total time measured in seconds
68
- this.currentState.average = this.currentState.numerator / this.currentState.denominator;
69
- if (this.currentState.max === 0 || windowFPS > this.currentState.max) {
70
- this.currentState.max = windowFPS;
71
- }
72
- if (this.currentState.min === 0 || windowFPS < this.currentState.min) {
73
- this.currentState.min = windowFPS;
74
- }
75
- }
76
-
77
- /**
78
- * If there is running tracking - it will be reset
79
- */
80
- }, {
81
- key: "startWindowTracking",
82
- value: function startWindowTracking() {
83
- var _this = this;
84
- // Clear any previous tracking state
85
- this.resetOverallTracking();
86
- var _measureFrame = function measureFrame() {
87
- _this.currentFrameStart = global.performance.now();
88
- _this.animationFrame = requestAnimationFrame(function () {
89
- // While measurement is paused -- we don't count the animation frame towards the monitored
90
- // period.
91
- if (!_this.paused) {
92
- var frameDuration = performance.now() - _this.currentFrameStart;
93
-
94
- // Add frame to current window
95
- _this.windowFrameCount++;
96
- _this.windowTotalTime += frameDuration;
97
-
98
- // Check if window is >= 1 second (1000ms)
99
- // When the page is running smoothly it's expected this will not be hit frequently
100
- if (_this.windowTotalTime >= 1000) {
101
- _this.measureWindowFPS();
102
- // Reset window for next measurement
103
- _this.resetWindow();
104
- }
105
- }
106
- _measureFrame();
107
- });
108
- };
109
- _measureFrame();
110
- }
111
- }, {
112
- key: "startNewWindow",
113
- value: function startNewWindow(paused) {
114
- var lastWindowResult = {
115
- numerator: this.currentState.numerator,
116
- denominator: this.currentState.denominator,
117
- max: this.currentState.max,
118
- min: this.currentState.min,
119
- average: this.currentState.average
120
- };
121
- this.paused = paused;
122
- this.startWindowTracking();
123
- return lastWindowResult;
124
- }
125
- }, {
126
- key: "resetWindow",
127
- value: function resetWindow() {
128
- this.windowFrameCount = 0;
129
- this.windowTotalTime = 0;
130
- // Note this.currentFrameStart is over ridden
131
- // as part of tracking - so does not need to be
132
- // reset.
133
- }
134
- }, {
135
- key: "endWindowTracking",
136
- value: function endWindowTracking() {
137
- if (this.animationFrame) {
138
- cancelAnimationFrame(this.animationFrame);
139
- }
140
- }
141
- }, {
142
- key: "resetOverallTracking",
143
- value: function resetOverallTracking() {
144
- this.resetWindow();
145
- this.endWindowTracking();
146
- this.currentState = {
147
- numerator: 0,
148
- denominator: 0,
149
- max: 0,
150
- min: 0,
151
- average: 0
152
- };
153
- }
154
- }, {
155
- key: "end",
156
- value: function end() {
157
- try {
158
- this.measureWindowFPS();
159
- return this.currentState;
160
- } finally {
161
- this.resetOverallTracking();
162
- }
163
- }
164
- }, {
165
- key: "pause",
166
- value: function pause() {
167
- // Note - we leave the tracking animationFrame monitoring running, and on resume
168
- // simply set the currentFrameStart and paused to true
169
- // This works because the tracking builds windows of tracked time rather than
170
- // basing itself off a window start time and time elapsed time since then.
171
- this.paused = true;
172
- }
173
- }, {
174
- key: "resume",
175
- value: function resume() {
176
- // Note - We don't need to handle the gap in measurement - as the raf logic builds/increments a window time
177
- // based on the currentFrameStart (and any previous measurements which can only happen while the tracking
178
- // is not paused).
179
- this.currentFrameStart = performance.now();
180
- this.paused = false;
181
- if (!this.animationFrame) {
182
- this.startWindowTracking();
183
- }
184
- }
185
- }]);
186
- }();
@@ -1,57 +0,0 @@
1
- import type { PeriodMeasurer } from '../types';
2
- export declare class AnimationFPSIM implements PeriodMeasurer {
3
- /**
4
- * AFPS stands for Animation Frames Per Second
5
- */
6
- name: string;
7
- monitor: AnimationFPSMonitor;
8
- start(paused: boolean): {
9
- numerator: number;
10
- denominator: number;
11
- max: number;
12
- min: number;
13
- average: number;
14
- };
15
- end(): {
16
- numerator: number;
17
- denominator: number;
18
- max: number;
19
- min: number;
20
- average: number;
21
- };
22
- pause(): void;
23
- resume(): void;
24
- }
25
- declare class AnimationFPSMonitor {
26
- paused: boolean;
27
- private currentState;
28
- private windowFrameCount;
29
- private windowTotalTime;
30
- private currentFrameStart;
31
- animationFrame?: ReturnType<typeof requestAnimationFrame>;
32
- private measureWindowFPS;
33
- /**
34
- * If there is running tracking - it will be reset
35
- */
36
- private startWindowTracking;
37
- startNewWindow(paused: boolean): {
38
- numerator: number;
39
- denominator: number;
40
- max: number;
41
- min: number;
42
- average: number;
43
- };
44
- private resetWindow;
45
- private endWindowTracking;
46
- private resetOverallTracking;
47
- end(): {
48
- numerator: number;
49
- denominator: number;
50
- max: number;
51
- min: number;
52
- average: number;
53
- };
54
- pause(): void;
55
- resume(): void;
56
- }
57
- export {};