@openedx/frontend-build 15.0.0-alpha.2 → 15.0.0-alpha.20

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.
Files changed (220) hide show
  1. package/README.md +1 -1
  2. package/config/.eslintrc.js +1 -0
  3. package/config/data/paragonUtils.js +171 -0
  4. package/config/jest/setupTest.js +35 -0
  5. package/config/jest.config.js +4 -1
  6. package/config/webpack.common.config.js +44 -0
  7. package/config/webpack.dev-stage.config.js +1 -0
  8. package/config/webpack.dev.config.js +57 -35
  9. package/config/webpack.prod.config.js +2 -1
  10. package/lib/plugins/paragon-webpack-plugin/ParagonWebpackPlugin.js +126 -0
  11. package/lib/plugins/paragon-webpack-plugin/index.js +3 -0
  12. package/lib/plugins/paragon-webpack-plugin/utils/assetUtils.js +75 -0
  13. package/lib/plugins/paragon-webpack-plugin/utils/htmlUtils.js +69 -0
  14. package/lib/plugins/paragon-webpack-plugin/utils/index.js +9 -0
  15. package/lib/plugins/paragon-webpack-plugin/utils/paragonStylesheetUtils.js +120 -0
  16. package/lib/plugins/paragon-webpack-plugin/utils/scriptUtils.js +144 -0
  17. package/lib/plugins/paragon-webpack-plugin/utils/stylesheetUtils.js +107 -0
  18. package/lib/plugins/paragon-webpack-plugin/utils/tagUtils.js +58 -0
  19. package/package.json +22 -14
  20. package/.eslintignore +0 -5
  21. package/.eslintrc.js +0 -10
  22. package/.github/workflows/add-depr-ticket-to-depr-board.yml +0 -19
  23. package/.github/workflows/add-remove-label-on-comment.yml +0 -20
  24. package/.github/workflows/ci.yml +0 -30
  25. package/.github/workflows/commitlint.yml +0 -17
  26. package/.github/workflows/lockfileversion-check.yml +0 -13
  27. package/.github/workflows/release.yml +0 -34
  28. package/.github/workflows/self-assign-issue.yml +0 -12
  29. package/.github/workflows/sync-master-alpha.yml +0 -35
  30. package/.nvmrc +0 -1
  31. package/coverage/clover.xml +0 -6
  32. package/coverage/coverage-final.json +0 -1
  33. package/coverage/lcov-report/base.css +0 -224
  34. package/coverage/lcov-report/block-navigation.js +0 -87
  35. package/coverage/lcov-report/favicon.png +0 -0
  36. package/coverage/lcov-report/index.html +0 -101
  37. package/coverage/lcov-report/prettify.css +0 -1
  38. package/coverage/lcov-report/prettify.js +0 -2
  39. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  40. package/coverage/lcov-report/sorter.js +0 -196
  41. package/coverage/lcov.info +0 -0
  42. package/docs/0001-non-usage-of-gatsby.rst +0 -37
  43. package/docs/0002-js-environment-config.md +0 -47
  44. package/docs/0003-fedx-scripts-serve.md +0 -37
  45. package/example/.env +0 -0
  46. package/example/.env.development +0 -3
  47. package/example/.env.test +0 -2
  48. package/example/.eslintignore +0 -5
  49. package/example/.eslintrc.js +0 -3
  50. package/example/dist/1382e1cbf8d733d7301cdd212192bfea.jpg +0 -0
  51. package/example/dist/652.70be34739115e11aaeb3.js +0 -3
  52. package/example/dist/652.70be34739115e11aaeb3.js.LICENSE.txt +0 -41
  53. package/example/dist/652.70be34739115e11aaeb3.js.map +0 -1
  54. package/example/dist/app.9b26aa9c728d62e6064d.css +0 -3
  55. package/example/dist/app.9b26aa9c728d62e6064d.css.map +0 -1
  56. package/example/dist/app.9b26aa9c728d62e6064d.js +0 -2
  57. package/example/dist/app.9b26aa9c728d62e6064d.js.map +0 -1
  58. package/example/dist/babel/App.js +0 -94
  59. package/example/dist/babel/App.js.map +0 -1
  60. package/example/dist/babel/App.test.jsx +0 -11
  61. package/example/dist/babel/Image.tsx +0 -16
  62. package/example/dist/babel/__snapshots__/App.test.jsx.snap +0 -120
  63. package/example/dist/babel/apple.jpg +0 -0
  64. package/example/dist/babel/apple.svg +0 -1
  65. package/example/dist/babel/index.js +0 -13
  66. package/example/dist/babel/index.js.map +0 -1
  67. package/example/dist/babel/style.scss +0 -9
  68. package/example/dist/cb28cdb1468c915e27e5cec9af64f22f.svg +0 -1
  69. package/example/dist/index.html +0 -4
  70. package/example/dist/report.html +0 -39
  71. package/example/dist/runtime.40856db71d718a3e9d37.js +0 -2
  72. package/example/dist/runtime.40856db71d718a3e9d37.js.map +0 -1
  73. package/example/env.config.js +0 -6
  74. package/example/node_modules/.package-lock.json +0 -98
  75. package/example/node_modules/js-tokens/CHANGELOG.md +0 -151
  76. package/example/node_modules/js-tokens/LICENSE +0 -21
  77. package/example/node_modules/js-tokens/README.md +0 -240
  78. package/example/node_modules/js-tokens/index.js +0 -23
  79. package/example/node_modules/js-tokens/package.json +0 -30
  80. package/example/node_modules/loose-envify/LICENSE +0 -21
  81. package/example/node_modules/loose-envify/README.md +0 -45
  82. package/example/node_modules/loose-envify/cli.js +0 -16
  83. package/example/node_modules/loose-envify/custom.js +0 -4
  84. package/example/node_modules/loose-envify/index.js +0 -3
  85. package/example/node_modules/loose-envify/loose-envify.js +0 -36
  86. package/example/node_modules/loose-envify/package.json +0 -36
  87. package/example/node_modules/loose-envify/replace.js +0 -65
  88. package/example/node_modules/object-assign/index.js +0 -90
  89. package/example/node_modules/object-assign/license +0 -21
  90. package/example/node_modules/object-assign/package.json +0 -42
  91. package/example/node_modules/object-assign/readme.md +0 -61
  92. package/example/node_modules/prop-types/LICENSE +0 -21
  93. package/example/node_modules/prop-types/README.md +0 -302
  94. package/example/node_modules/prop-types/checkPropTypes.js +0 -103
  95. package/example/node_modules/prop-types/factory.js +0 -19
  96. package/example/node_modules/prop-types/factoryWithThrowingShims.js +0 -65
  97. package/example/node_modules/prop-types/factoryWithTypeCheckers.js +0 -610
  98. package/example/node_modules/prop-types/index.js +0 -19
  99. package/example/node_modules/prop-types/lib/ReactPropTypesSecret.js +0 -12
  100. package/example/node_modules/prop-types/lib/has.js +0 -1
  101. package/example/node_modules/prop-types/package.json +0 -60
  102. package/example/node_modules/prop-types/prop-types.js +0 -1315
  103. package/example/node_modules/prop-types/prop-types.min.js +0 -1
  104. package/example/node_modules/react/LICENSE +0 -21
  105. package/example/node_modules/react/README.md +0 -13
  106. package/example/node_modules/react/build-info.json +0 -8
  107. package/example/node_modules/react/cjs/react-jsx-dev-runtime.development.js +0 -889
  108. package/example/node_modules/react/cjs/react-jsx-dev-runtime.production.min.js +0 -9
  109. package/example/node_modules/react/cjs/react-jsx-runtime.development.js +0 -911
  110. package/example/node_modules/react/cjs/react-jsx-runtime.production.min.js +0 -10
  111. package/example/node_modules/react/cjs/react.development.js +0 -1912
  112. package/example/node_modules/react/cjs/react.production.min.js +0 -25
  113. package/example/node_modules/react/index.js +0 -7
  114. package/example/node_modules/react/jsx-dev-runtime.js +0 -7
  115. package/example/node_modules/react/jsx-runtime.js +0 -7
  116. package/example/node_modules/react/package.json +0 -44
  117. package/example/node_modules/react/umd/react.development.js +0 -3318
  118. package/example/node_modules/react/umd/react.production.min.js +0 -32
  119. package/example/node_modules/react/umd/react.profiling.min.js +0 -39
  120. package/example/node_modules/react-dom/LICENSE +0 -21
  121. package/example/node_modules/react-dom/README.md +0 -54
  122. package/example/node_modules/react-dom/build-info.json +0 -8
  123. package/example/node_modules/react-dom/cjs/react-dom-server.browser.development.js +0 -4043
  124. package/example/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js +0 -54
  125. package/example/node_modules/react-dom/cjs/react-dom-server.node.development.js +0 -4085
  126. package/example/node_modules/react-dom/cjs/react-dom-server.node.production.min.js +0 -55
  127. package/example/node_modules/react-dom/cjs/react-dom-test-utils.development.js +0 -1480
  128. package/example/node_modules/react-dom/cjs/react-dom-test-utils.production.min.js +0 -35
  129. package/example/node_modules/react-dom/cjs/react-dom-unstable-fizz.browser.development.js +0 -141
  130. package/example/node_modules/react-dom/cjs/react-dom-unstable-fizz.browser.production.min.js +0 -11
  131. package/example/node_modules/react-dom/cjs/react-dom-unstable-fizz.node.development.js +0 -162
  132. package/example/node_modules/react-dom/cjs/react-dom-unstable-fizz.node.production.min.js +0 -12
  133. package/example/node_modules/react-dom/cjs/react-dom-unstable-native-dependencies.development.js +0 -1629
  134. package/example/node_modules/react-dom/cjs/react-dom-unstable-native-dependencies.production.min.js +0 -31
  135. package/example/node_modules/react-dom/cjs/react-dom.development.js +0 -25012
  136. package/example/node_modules/react-dom/cjs/react-dom.production.min.js +0 -292
  137. package/example/node_modules/react-dom/cjs/react-dom.profiling.min.js +0 -299
  138. package/example/node_modules/react-dom/index.js +0 -38
  139. package/example/node_modules/react-dom/package.json +0 -60
  140. package/example/node_modules/react-dom/profiling.js +0 -38
  141. package/example/node_modules/react-dom/server.browser.js +0 -7
  142. package/example/node_modules/react-dom/server.js +0 -3
  143. package/example/node_modules/react-dom/server.node.js +0 -7
  144. package/example/node_modules/react-dom/test-utils.js +0 -7
  145. package/example/node_modules/react-dom/umd/react-dom-server.browser.development.js +0 -4147
  146. package/example/node_modules/react-dom/umd/react-dom-server.browser.production.min.js +0 -45
  147. package/example/node_modules/react-dom/umd/react-dom-test-utils.development.js +0 -1499
  148. package/example/node_modules/react-dom/umd/react-dom-test-utils.production.min.js +0 -30
  149. package/example/node_modules/react-dom/umd/react-dom-unstable-fizz.browser.development.js +0 -141
  150. package/example/node_modules/react-dom/umd/react-dom-unstable-fizz.browser.production.min.js +0 -10
  151. package/example/node_modules/react-dom/umd/react-dom-unstable-native-dependencies.development.js +0 -1628
  152. package/example/node_modules/react-dom/umd/react-dom-unstable-native-dependencies.production.min.js +0 -28
  153. package/example/node_modules/react-dom/umd/react-dom.development.js +0 -25147
  154. package/example/node_modules/react-dom/umd/react-dom.production.min.js +0 -239
  155. package/example/node_modules/react-dom/umd/react-dom.profiling.min.js +0 -247
  156. package/example/node_modules/react-dom/unstable-fizz.browser.js +0 -7
  157. package/example/node_modules/react-dom/unstable-fizz.js +0 -3
  158. package/example/node_modules/react-dom/unstable-fizz.node.js +0 -7
  159. package/example/node_modules/react-dom/unstable-native-dependencies.js +0 -7
  160. package/example/node_modules/react-is/LICENSE +0 -21
  161. package/example/node_modules/react-is/README.md +0 -104
  162. package/example/node_modules/react-is/build-info.json +0 -8
  163. package/example/node_modules/react-is/cjs/react-is.development.js +0 -181
  164. package/example/node_modules/react-is/cjs/react-is.production.min.js +0 -15
  165. package/example/node_modules/react-is/index.js +0 -7
  166. package/example/node_modules/react-is/package.json +0 -27
  167. package/example/node_modules/react-is/umd/react-is.development.js +0 -181
  168. package/example/node_modules/react-is/umd/react-is.production.min.js +0 -13
  169. package/example/node_modules/react-test-renderer/LICENSE +0 -21
  170. package/example/node_modules/react-test-renderer/README.md +0 -26
  171. package/example/node_modules/react-test-renderer/build-info.json +0 -8
  172. package/example/node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js +0 -1019
  173. package/example/node_modules/react-test-renderer/cjs/react-test-renderer-shallow.production.min.js +0 -35
  174. package/example/node_modules/react-test-renderer/cjs/react-test-renderer.development.js +0 -15596
  175. package/example/node_modules/react-test-renderer/cjs/react-test-renderer.production.min.js +0 -181
  176. package/example/node_modules/react-test-renderer/index.js +0 -7
  177. package/example/node_modules/react-test-renderer/package.json +0 -41
  178. package/example/node_modules/react-test-renderer/shallow.js +0 -7
  179. package/example/node_modules/react-test-renderer/umd/react-test-renderer-shallow.development.js +0 -1176
  180. package/example/node_modules/react-test-renderer/umd/react-test-renderer-shallow.production.min.js +0 -31
  181. package/example/node_modules/react-test-renderer/umd/react-test-renderer.development.js +0 -15709
  182. package/example/node_modules/react-test-renderer/umd/react-test-renderer.production.min.js +0 -151
  183. package/example/node_modules/scheduler/LICENSE +0 -21
  184. package/example/node_modules/scheduler/README.md +0 -9
  185. package/example/node_modules/scheduler/build-info.json +0 -8
  186. package/example/node_modules/scheduler/cjs/scheduler-tracing.development.js +0 -349
  187. package/example/node_modules/scheduler/cjs/scheduler-tracing.production.min.js +0 -10
  188. package/example/node_modules/scheduler/cjs/scheduler-tracing.profiling.min.js +0 -17
  189. package/example/node_modules/scheduler/cjs/scheduler-unstable_mock.development.js +0 -857
  190. package/example/node_modules/scheduler/cjs/scheduler-unstable_mock.production.min.js +0 -20
  191. package/example/node_modules/scheduler/cjs/scheduler.development.js +0 -858
  192. package/example/node_modules/scheduler/cjs/scheduler.production.min.js +0 -21
  193. package/example/node_modules/scheduler/index.js +0 -7
  194. package/example/node_modules/scheduler/package.json +0 -39
  195. package/example/node_modules/scheduler/tracing-profiling.js +0 -7
  196. package/example/node_modules/scheduler/tracing.js +0 -7
  197. package/example/node_modules/scheduler/umd/scheduler-tracing.development.js +0 -80
  198. package/example/node_modules/scheduler/umd/scheduler-tracing.production.min.js +0 -80
  199. package/example/node_modules/scheduler/umd/scheduler-tracing.profiling.min.js +0 -80
  200. package/example/node_modules/scheduler/umd/scheduler-unstable_mock.development.js +0 -857
  201. package/example/node_modules/scheduler/umd/scheduler-unstable_mock.production.min.js +0 -17
  202. package/example/node_modules/scheduler/umd/scheduler.development.js +0 -152
  203. package/example/node_modules/scheduler/umd/scheduler.production.min.js +0 -146
  204. package/example/node_modules/scheduler/umd/scheduler.profiling.min.js +0 -146
  205. package/example/node_modules/scheduler/unstable_mock.js +0 -7
  206. package/example/package-lock.json +0 -110
  207. package/example/package.json +0 -24
  208. package/example/public/index.html +0 -13
  209. package/example/src/App.jsx +0 -43
  210. package/example/src/App.test.jsx +0 -11
  211. package/example/src/Image.tsx +0 -16
  212. package/example/src/__snapshots__/App.test.jsx.snap +0 -120
  213. package/example/src/apple.jpg +0 -0
  214. package/example/src/apple.svg +0 -1
  215. package/example/src/index.jsx +0 -13
  216. package/example/src/style.scss +0 -9
  217. package/example/tsconfig.json +0 -16
  218. package/openedx.yaml +0 -10
  219. package/renovate.json +0 -22
  220. package/smoke-test.sh +0 -11
@@ -1,857 +0,0 @@
1
- /** @license React v0.19.1
2
- * scheduler-unstable_mock.development.js
3
- *
4
- * Copyright (c) Facebook, Inc. and its affiliates.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- */
9
-
10
- 'use strict';
11
-
12
- (function (global, factory) {
13
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
14
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
15
- (global = global || self, factory(global.SchedulerMock = {}));
16
- }(this, (function (exports) { 'use strict';
17
-
18
- var enableSchedulerDebugging = false;
19
- var enableProfiling = true;
20
-
21
- var currentTime = 0;
22
- var scheduledCallback = null;
23
- var scheduledTimeout = null;
24
- var timeoutTime = -1;
25
- var yieldedValues = null;
26
- var expectedNumberOfYields = -1;
27
- var didStop = false;
28
- var isFlushing = false;
29
- var needsPaint = false;
30
- var shouldYieldForPaint = false;
31
- function requestHostCallback(callback) {
32
- scheduledCallback = callback;
33
- }
34
- function requestHostTimeout(callback, ms) {
35
- scheduledTimeout = callback;
36
- timeoutTime = currentTime + ms;
37
- }
38
- function cancelHostTimeout() {
39
- scheduledTimeout = null;
40
- timeoutTime = -1;
41
- }
42
- function shouldYieldToHost() {
43
- if (expectedNumberOfYields !== -1 && yieldedValues !== null && yieldedValues.length >= expectedNumberOfYields || shouldYieldForPaint && needsPaint) {
44
- // We yielded at least as many values as expected. Stop flushing.
45
- didStop = true;
46
- return true;
47
- }
48
-
49
- return false;
50
- }
51
- function getCurrentTime() {
52
- return currentTime;
53
- }
54
- function forceFrameRate() {// No-op
55
- }
56
-
57
- function unstable_flushNumberOfYields(count) {
58
- if (isFlushing) {
59
- throw new Error('Already flushing work.');
60
- }
61
-
62
- if (scheduledCallback !== null) {
63
- var cb = scheduledCallback;
64
- expectedNumberOfYields = count;
65
- isFlushing = true;
66
-
67
- try {
68
- var hasMoreWork = true;
69
-
70
- do {
71
- hasMoreWork = cb(true, currentTime);
72
- } while (hasMoreWork && !didStop);
73
-
74
- if (!hasMoreWork) {
75
- scheduledCallback = null;
76
- }
77
- } finally {
78
- expectedNumberOfYields = -1;
79
- didStop = false;
80
- isFlushing = false;
81
- }
82
- }
83
- }
84
- function unstable_flushUntilNextPaint() {
85
- if (isFlushing) {
86
- throw new Error('Already flushing work.');
87
- }
88
-
89
- if (scheduledCallback !== null) {
90
- var cb = scheduledCallback;
91
- shouldYieldForPaint = true;
92
- needsPaint = false;
93
- isFlushing = true;
94
-
95
- try {
96
- var hasMoreWork = true;
97
-
98
- do {
99
- hasMoreWork = cb(true, currentTime);
100
- } while (hasMoreWork && !didStop);
101
-
102
- if (!hasMoreWork) {
103
- scheduledCallback = null;
104
- }
105
- } finally {
106
- shouldYieldForPaint = false;
107
- didStop = false;
108
- isFlushing = false;
109
- }
110
- }
111
- }
112
- function unstable_flushExpired() {
113
- if (isFlushing) {
114
- throw new Error('Already flushing work.');
115
- }
116
-
117
- if (scheduledCallback !== null) {
118
- isFlushing = true;
119
-
120
- try {
121
- var hasMoreWork = scheduledCallback(false, currentTime);
122
-
123
- if (!hasMoreWork) {
124
- scheduledCallback = null;
125
- }
126
- } finally {
127
- isFlushing = false;
128
- }
129
- }
130
- }
131
- function unstable_flushAllWithoutAsserting() {
132
- // Returns false if no work was flushed.
133
- if (isFlushing) {
134
- throw new Error('Already flushing work.');
135
- }
136
-
137
- if (scheduledCallback !== null) {
138
- var cb = scheduledCallback;
139
- isFlushing = true;
140
-
141
- try {
142
- var hasMoreWork = true;
143
-
144
- do {
145
- hasMoreWork = cb(true, currentTime);
146
- } while (hasMoreWork);
147
-
148
- if (!hasMoreWork) {
149
- scheduledCallback = null;
150
- }
151
-
152
- return true;
153
- } finally {
154
- isFlushing = false;
155
- }
156
- } else {
157
- return false;
158
- }
159
- }
160
- function unstable_clearYields() {
161
- if (yieldedValues === null) {
162
- return [];
163
- }
164
-
165
- var values = yieldedValues;
166
- yieldedValues = null;
167
- return values;
168
- }
169
- function unstable_flushAll() {
170
- if (yieldedValues !== null) {
171
- throw new Error('Log is not empty. Assert on the log of yielded values before ' + 'flushing additional work.');
172
- }
173
-
174
- unstable_flushAllWithoutAsserting();
175
-
176
- if (yieldedValues !== null) {
177
- throw new Error('While flushing work, something yielded a value. Use an ' + 'assertion helper to assert on the log of yielded values, e.g. ' + 'expect(Scheduler).toFlushAndYield([...])');
178
- }
179
- }
180
- function unstable_yieldValue(value) {
181
- if (yieldedValues === null) {
182
- yieldedValues = [value];
183
- } else {
184
- yieldedValues.push(value);
185
- }
186
- }
187
- function unstable_advanceTime(ms) {
188
- currentTime += ms;
189
-
190
- if (scheduledTimeout !== null && timeoutTime <= currentTime) {
191
- scheduledTimeout(currentTime);
192
- timeoutTime = -1;
193
- scheduledTimeout = null;
194
- }
195
- }
196
- function requestPaint() {
197
- needsPaint = true;
198
- }
199
-
200
- function push(heap, node) {
201
- var index = heap.length;
202
- heap.push(node);
203
- siftUp(heap, node, index);
204
- }
205
- function peek(heap) {
206
- var first = heap[0];
207
- return first === undefined ? null : first;
208
- }
209
- function pop(heap) {
210
- var first = heap[0];
211
-
212
- if (first !== undefined) {
213
- var last = heap.pop();
214
-
215
- if (last !== first) {
216
- heap[0] = last;
217
- siftDown(heap, last, 0);
218
- }
219
-
220
- return first;
221
- } else {
222
- return null;
223
- }
224
- }
225
-
226
- function siftUp(heap, node, i) {
227
- var index = i;
228
-
229
- while (true) {
230
- var parentIndex = index - 1 >>> 1;
231
- var parent = heap[parentIndex];
232
-
233
- if (parent !== undefined && compare(parent, node) > 0) {
234
- // The parent is larger. Swap positions.
235
- heap[parentIndex] = node;
236
- heap[index] = parent;
237
- index = parentIndex;
238
- } else {
239
- // The parent is smaller. Exit.
240
- return;
241
- }
242
- }
243
- }
244
-
245
- function siftDown(heap, node, i) {
246
- var index = i;
247
- var length = heap.length;
248
-
249
- while (index < length) {
250
- var leftIndex = (index + 1) * 2 - 1;
251
- var left = heap[leftIndex];
252
- var rightIndex = leftIndex + 1;
253
- var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those.
254
-
255
- if (left !== undefined && compare(left, node) < 0) {
256
- if (right !== undefined && compare(right, left) < 0) {
257
- heap[index] = right;
258
- heap[rightIndex] = node;
259
- index = rightIndex;
260
- } else {
261
- heap[index] = left;
262
- heap[leftIndex] = node;
263
- index = leftIndex;
264
- }
265
- } else if (right !== undefined && compare(right, node) < 0) {
266
- heap[index] = right;
267
- heap[rightIndex] = node;
268
- index = rightIndex;
269
- } else {
270
- // Neither child is smaller. Exit.
271
- return;
272
- }
273
- }
274
- }
275
-
276
- function compare(a, b) {
277
- // Compare sort index first, then task id.
278
- var diff = a.sortIndex - b.sortIndex;
279
- return diff !== 0 ? diff : a.id - b.id;
280
- }
281
-
282
- // TODO: Use symbols?
283
- var NoPriority = 0;
284
- var ImmediatePriority = 1;
285
- var UserBlockingPriority = 2;
286
- var NormalPriority = 3;
287
- var LowPriority = 4;
288
- var IdlePriority = 5;
289
-
290
- var runIdCounter = 0;
291
- var mainThreadIdCounter = 0;
292
- var profilingStateSize = 4;
293
- var sharedProfilingBuffer = // $FlowFixMe Flow doesn't know about SharedArrayBuffer
294
- typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer
295
- typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9
296
- ;
297
- var profilingState = sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks
298
-
299
- var PRIORITY = 0;
300
- var CURRENT_TASK_ID = 1;
301
- var CURRENT_RUN_ID = 2;
302
- var QUEUE_SIZE = 3;
303
-
304
- {
305
- profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue
306
- // array might include canceled tasks.
307
-
308
- profilingState[QUEUE_SIZE] = 0;
309
- profilingState[CURRENT_TASK_ID] = 0;
310
- } // Bytes per element is 4
311
-
312
-
313
- var INITIAL_EVENT_LOG_SIZE = 131072;
314
- var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes
315
-
316
- var eventLogSize = 0;
317
- var eventLogBuffer = null;
318
- var eventLog = null;
319
- var eventLogIndex = 0;
320
- var TaskStartEvent = 1;
321
- var TaskCompleteEvent = 2;
322
- var TaskErrorEvent = 3;
323
- var TaskCancelEvent = 4;
324
- var TaskRunEvent = 5;
325
- var TaskYieldEvent = 6;
326
- var SchedulerSuspendEvent = 7;
327
- var SchedulerResumeEvent = 8;
328
-
329
- function logEvent(entries) {
330
- if (eventLog !== null) {
331
- var offset = eventLogIndex;
332
- eventLogIndex += entries.length;
333
-
334
- if (eventLogIndex + 1 > eventLogSize) {
335
- eventLogSize *= 2;
336
-
337
- if (eventLogSize > MAX_EVENT_LOG_SIZE) {
338
- // Using console['error'] to evade Babel and ESLint
339
- console['error']("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.');
340
- stopLoggingProfilingEvents();
341
- return;
342
- }
343
-
344
- var newEventLog = new Int32Array(eventLogSize * 4);
345
- newEventLog.set(eventLog);
346
- eventLogBuffer = newEventLog.buffer;
347
- eventLog = newEventLog;
348
- }
349
-
350
- eventLog.set(entries, offset);
351
- }
352
- }
353
-
354
- function startLoggingProfilingEvents() {
355
- eventLogSize = INITIAL_EVENT_LOG_SIZE;
356
- eventLogBuffer = new ArrayBuffer(eventLogSize * 4);
357
- eventLog = new Int32Array(eventLogBuffer);
358
- eventLogIndex = 0;
359
- }
360
- function stopLoggingProfilingEvents() {
361
- var buffer = eventLogBuffer;
362
- eventLogSize = 0;
363
- eventLogBuffer = null;
364
- eventLog = null;
365
- eventLogIndex = 0;
366
- return buffer;
367
- }
368
- function markTaskStart(task, ms) {
369
- {
370
- profilingState[QUEUE_SIZE]++;
371
-
372
- if (eventLog !== null) {
373
- // performance.now returns a float, representing milliseconds. When the
374
- // event is logged, it's coerced to an int. Convert to microseconds to
375
- // maintain extra degrees of precision.
376
- logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]);
377
- }
378
- }
379
- }
380
- function markTaskCompleted(task, ms) {
381
- {
382
- profilingState[PRIORITY] = NoPriority;
383
- profilingState[CURRENT_TASK_ID] = 0;
384
- profilingState[QUEUE_SIZE]--;
385
-
386
- if (eventLog !== null) {
387
- logEvent([TaskCompleteEvent, ms * 1000, task.id]);
388
- }
389
- }
390
- }
391
- function markTaskCanceled(task, ms) {
392
- {
393
- profilingState[QUEUE_SIZE]--;
394
-
395
- if (eventLog !== null) {
396
- logEvent([TaskCancelEvent, ms * 1000, task.id]);
397
- }
398
- }
399
- }
400
- function markTaskErrored(task, ms) {
401
- {
402
- profilingState[PRIORITY] = NoPriority;
403
- profilingState[CURRENT_TASK_ID] = 0;
404
- profilingState[QUEUE_SIZE]--;
405
-
406
- if (eventLog !== null) {
407
- logEvent([TaskErrorEvent, ms * 1000, task.id]);
408
- }
409
- }
410
- }
411
- function markTaskRun(task, ms) {
412
- {
413
- runIdCounter++;
414
- profilingState[PRIORITY] = task.priorityLevel;
415
- profilingState[CURRENT_TASK_ID] = task.id;
416
- profilingState[CURRENT_RUN_ID] = runIdCounter;
417
-
418
- if (eventLog !== null) {
419
- logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]);
420
- }
421
- }
422
- }
423
- function markTaskYield(task, ms) {
424
- {
425
- profilingState[PRIORITY] = NoPriority;
426
- profilingState[CURRENT_TASK_ID] = 0;
427
- profilingState[CURRENT_RUN_ID] = 0;
428
-
429
- if (eventLog !== null) {
430
- logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]);
431
- }
432
- }
433
- }
434
- function markSchedulerSuspended(ms) {
435
- {
436
- mainThreadIdCounter++;
437
-
438
- if (eventLog !== null) {
439
- logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]);
440
- }
441
- }
442
- }
443
- function markSchedulerUnsuspended(ms) {
444
- {
445
- if (eventLog !== null) {
446
- logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]);
447
- }
448
- }
449
- }
450
-
451
- /* eslint-disable no-var */
452
- // Math.pow(2, 30) - 1
453
- // 0b111111111111111111111111111111
454
-
455
- var maxSigned31BitInt = 1073741823; // Times out immediately
456
-
457
- var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out
458
-
459
- var USER_BLOCKING_PRIORITY = 250;
460
- var NORMAL_PRIORITY_TIMEOUT = 5000;
461
- var LOW_PRIORITY_TIMEOUT = 10000; // Never times out
462
-
463
- var IDLE_PRIORITY = maxSigned31BitInt; // Tasks are stored on a min heap
464
-
465
- var taskQueue = [];
466
- var timerQueue = []; // Incrementing id counter. Used to maintain insertion order.
467
-
468
- var taskIdCounter = 1; // Pausing the scheduler is useful for debugging.
469
- var currentTask = null;
470
- var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy.
471
-
472
- var isPerformingWork = false;
473
- var isHostCallbackScheduled = false;
474
- var isHostTimeoutScheduled = false;
475
-
476
- function advanceTimers(currentTime) {
477
- // Check for tasks that are no longer delayed and add them to the queue.
478
- var timer = peek(timerQueue);
479
-
480
- while (timer !== null) {
481
- if (timer.callback === null) {
482
- // Timer was cancelled.
483
- pop(timerQueue);
484
- } else if (timer.startTime <= currentTime) {
485
- // Timer fired. Transfer to the task queue.
486
- pop(timerQueue);
487
- timer.sortIndex = timer.expirationTime;
488
- push(taskQueue, timer);
489
-
490
- {
491
- markTaskStart(timer, currentTime);
492
- timer.isQueued = true;
493
- }
494
- } else {
495
- // Remaining timers are pending.
496
- return;
497
- }
498
-
499
- timer = peek(timerQueue);
500
- }
501
- }
502
-
503
- function handleTimeout(currentTime) {
504
- isHostTimeoutScheduled = false;
505
- advanceTimers(currentTime);
506
-
507
- if (!isHostCallbackScheduled) {
508
- if (peek(taskQueue) !== null) {
509
- isHostCallbackScheduled = true;
510
- requestHostCallback(flushWork);
511
- } else {
512
- var firstTimer = peek(timerQueue);
513
-
514
- if (firstTimer !== null) {
515
- requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
516
- }
517
- }
518
- }
519
- }
520
-
521
- function flushWork(hasTimeRemaining, initialTime) {
522
- {
523
- markSchedulerUnsuspended(initialTime);
524
- } // We'll need a host callback the next time work is scheduled.
525
-
526
-
527
- isHostCallbackScheduled = false;
528
-
529
- if (isHostTimeoutScheduled) {
530
- // We scheduled a timeout but it's no longer needed. Cancel it.
531
- isHostTimeoutScheduled = false;
532
- cancelHostTimeout();
533
- }
534
-
535
- isPerformingWork = true;
536
- var previousPriorityLevel = currentPriorityLevel;
537
-
538
- try {
539
- if (enableProfiling) {
540
- try {
541
- return workLoop(hasTimeRemaining, initialTime);
542
- } catch (error) {
543
- if (currentTask !== null) {
544
- var currentTime = getCurrentTime();
545
- markTaskErrored(currentTask, currentTime);
546
- currentTask.isQueued = false;
547
- }
548
-
549
- throw error;
550
- }
551
- } else {
552
- // No catch in prod codepath.
553
- return workLoop(hasTimeRemaining, initialTime);
554
- }
555
- } finally {
556
- currentTask = null;
557
- currentPriorityLevel = previousPriorityLevel;
558
- isPerformingWork = false;
559
-
560
- {
561
- var _currentTime = getCurrentTime();
562
-
563
- markSchedulerSuspended(_currentTime);
564
- }
565
- }
566
- }
567
-
568
- function workLoop(hasTimeRemaining, initialTime) {
569
- var currentTime = initialTime;
570
- advanceTimers(currentTime);
571
- currentTask = peek(taskQueue);
572
-
573
- while (currentTask !== null && !(enableSchedulerDebugging )) {
574
- if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) {
575
- // This currentTask hasn't expired, and we've reached the deadline.
576
- break;
577
- }
578
-
579
- var callback = currentTask.callback;
580
-
581
- if (callback !== null) {
582
- currentTask.callback = null;
583
- currentPriorityLevel = currentTask.priorityLevel;
584
- var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
585
- markTaskRun(currentTask, currentTime);
586
- var continuationCallback = callback(didUserCallbackTimeout);
587
- currentTime = getCurrentTime();
588
-
589
- if (typeof continuationCallback === 'function') {
590
- currentTask.callback = continuationCallback;
591
- markTaskYield(currentTask, currentTime);
592
- } else {
593
- {
594
- markTaskCompleted(currentTask, currentTime);
595
- currentTask.isQueued = false;
596
- }
597
-
598
- if (currentTask === peek(taskQueue)) {
599
- pop(taskQueue);
600
- }
601
- }
602
-
603
- advanceTimers(currentTime);
604
- } else {
605
- pop(taskQueue);
606
- }
607
-
608
- currentTask = peek(taskQueue);
609
- } // Return whether there's additional work
610
-
611
-
612
- if (currentTask !== null) {
613
- return true;
614
- } else {
615
- var firstTimer = peek(timerQueue);
616
-
617
- if (firstTimer !== null) {
618
- requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
619
- }
620
-
621
- return false;
622
- }
623
- }
624
-
625
- function unstable_runWithPriority(priorityLevel, eventHandler) {
626
- switch (priorityLevel) {
627
- case ImmediatePriority:
628
- case UserBlockingPriority:
629
- case NormalPriority:
630
- case LowPriority:
631
- case IdlePriority:
632
- break;
633
-
634
- default:
635
- priorityLevel = NormalPriority;
636
- }
637
-
638
- var previousPriorityLevel = currentPriorityLevel;
639
- currentPriorityLevel = priorityLevel;
640
-
641
- try {
642
- return eventHandler();
643
- } finally {
644
- currentPriorityLevel = previousPriorityLevel;
645
- }
646
- }
647
-
648
- function unstable_next(eventHandler) {
649
- var priorityLevel;
650
-
651
- switch (currentPriorityLevel) {
652
- case ImmediatePriority:
653
- case UserBlockingPriority:
654
- case NormalPriority:
655
- // Shift down to normal priority
656
- priorityLevel = NormalPriority;
657
- break;
658
-
659
- default:
660
- // Anything lower than normal priority should remain at the current level.
661
- priorityLevel = currentPriorityLevel;
662
- break;
663
- }
664
-
665
- var previousPriorityLevel = currentPriorityLevel;
666
- currentPriorityLevel = priorityLevel;
667
-
668
- try {
669
- return eventHandler();
670
- } finally {
671
- currentPriorityLevel = previousPriorityLevel;
672
- }
673
- }
674
-
675
- function unstable_wrapCallback(callback) {
676
- var parentPriorityLevel = currentPriorityLevel;
677
- return function () {
678
- // This is a fork of runWithPriority, inlined for performance.
679
- var previousPriorityLevel = currentPriorityLevel;
680
- currentPriorityLevel = parentPriorityLevel;
681
-
682
- try {
683
- return callback.apply(this, arguments);
684
- } finally {
685
- currentPriorityLevel = previousPriorityLevel;
686
- }
687
- };
688
- }
689
-
690
- function timeoutForPriorityLevel(priorityLevel) {
691
- switch (priorityLevel) {
692
- case ImmediatePriority:
693
- return IMMEDIATE_PRIORITY_TIMEOUT;
694
-
695
- case UserBlockingPriority:
696
- return USER_BLOCKING_PRIORITY;
697
-
698
- case IdlePriority:
699
- return IDLE_PRIORITY;
700
-
701
- case LowPriority:
702
- return LOW_PRIORITY_TIMEOUT;
703
-
704
- case NormalPriority:
705
- default:
706
- return NORMAL_PRIORITY_TIMEOUT;
707
- }
708
- }
709
-
710
- function unstable_scheduleCallback(priorityLevel, callback, options) {
711
- var currentTime = getCurrentTime();
712
- var startTime;
713
- var timeout;
714
-
715
- if (typeof options === 'object' && options !== null) {
716
- var delay = options.delay;
717
-
718
- if (typeof delay === 'number' && delay > 0) {
719
- startTime = currentTime + delay;
720
- } else {
721
- startTime = currentTime;
722
- }
723
-
724
- timeout = typeof options.timeout === 'number' ? options.timeout : timeoutForPriorityLevel(priorityLevel);
725
- } else {
726
- timeout = timeoutForPriorityLevel(priorityLevel);
727
- startTime = currentTime;
728
- }
729
-
730
- var expirationTime = startTime + timeout;
731
- var newTask = {
732
- id: taskIdCounter++,
733
- callback: callback,
734
- priorityLevel: priorityLevel,
735
- startTime: startTime,
736
- expirationTime: expirationTime,
737
- sortIndex: -1
738
- };
739
-
740
- {
741
- newTask.isQueued = false;
742
- }
743
-
744
- if (startTime > currentTime) {
745
- // This is a delayed task.
746
- newTask.sortIndex = startTime;
747
- push(timerQueue, newTask);
748
-
749
- if (peek(taskQueue) === null && newTask === peek(timerQueue)) {
750
- // All tasks are delayed, and this is the task with the earliest delay.
751
- if (isHostTimeoutScheduled) {
752
- // Cancel an existing timeout.
753
- cancelHostTimeout();
754
- } else {
755
- isHostTimeoutScheduled = true;
756
- } // Schedule a timeout.
757
-
758
-
759
- requestHostTimeout(handleTimeout, startTime - currentTime);
760
- }
761
- } else {
762
- newTask.sortIndex = expirationTime;
763
- push(taskQueue, newTask);
764
-
765
- {
766
- markTaskStart(newTask, currentTime);
767
- newTask.isQueued = true;
768
- } // Schedule a host callback, if needed. If we're already performing work,
769
- // wait until the next time we yield.
770
-
771
-
772
- if (!isHostCallbackScheduled && !isPerformingWork) {
773
- isHostCallbackScheduled = true;
774
- requestHostCallback(flushWork);
775
- }
776
- }
777
-
778
- return newTask;
779
- }
780
-
781
- function unstable_pauseExecution() {
782
- }
783
-
784
- function unstable_continueExecution() {
785
-
786
- if (!isHostCallbackScheduled && !isPerformingWork) {
787
- isHostCallbackScheduled = true;
788
- requestHostCallback(flushWork);
789
- }
790
- }
791
-
792
- function unstable_getFirstCallbackNode() {
793
- return peek(taskQueue);
794
- }
795
-
796
- function unstable_cancelCallback(task) {
797
- {
798
- if (task.isQueued) {
799
- var currentTime = getCurrentTime();
800
- markTaskCanceled(task, currentTime);
801
- task.isQueued = false;
802
- }
803
- } // Null out the callback to indicate the task has been canceled. (Can't
804
- // remove from the queue because you can't remove arbitrary nodes from an
805
- // array based heap, only the first one.)
806
-
807
-
808
- task.callback = null;
809
- }
810
-
811
- function unstable_getCurrentPriorityLevel() {
812
- return currentPriorityLevel;
813
- }
814
-
815
- function unstable_shouldYield() {
816
- var currentTime = getCurrentTime();
817
- advanceTimers(currentTime);
818
- var firstTask = peek(taskQueue);
819
- return firstTask !== currentTask && currentTask !== null && firstTask !== null && firstTask.callback !== null && firstTask.startTime <= currentTime && firstTask.expirationTime < currentTask.expirationTime || shouldYieldToHost();
820
- }
821
-
822
- var unstable_requestPaint = requestPaint;
823
- var unstable_Profiling = {
824
- startLoggingProfilingEvents: startLoggingProfilingEvents,
825
- stopLoggingProfilingEvents: stopLoggingProfilingEvents,
826
- sharedProfilingBuffer: sharedProfilingBuffer
827
- } ;
828
-
829
- exports.unstable_IdlePriority = IdlePriority;
830
- exports.unstable_ImmediatePriority = ImmediatePriority;
831
- exports.unstable_LowPriority = LowPriority;
832
- exports.unstable_NormalPriority = NormalPriority;
833
- exports.unstable_Profiling = unstable_Profiling;
834
- exports.unstable_UserBlockingPriority = UserBlockingPriority;
835
- exports.unstable_advanceTime = unstable_advanceTime;
836
- exports.unstable_cancelCallback = unstable_cancelCallback;
837
- exports.unstable_clearYields = unstable_clearYields;
838
- exports.unstable_continueExecution = unstable_continueExecution;
839
- exports.unstable_flushAll = unstable_flushAll;
840
- exports.unstable_flushAllWithoutAsserting = unstable_flushAllWithoutAsserting;
841
- exports.unstable_flushExpired = unstable_flushExpired;
842
- exports.unstable_flushNumberOfYields = unstable_flushNumberOfYields;
843
- exports.unstable_flushUntilNextPaint = unstable_flushUntilNextPaint;
844
- exports.unstable_forceFrameRate = forceFrameRate;
845
- exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel;
846
- exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode;
847
- exports.unstable_next = unstable_next;
848
- exports.unstable_now = getCurrentTime;
849
- exports.unstable_pauseExecution = unstable_pauseExecution;
850
- exports.unstable_requestPaint = unstable_requestPaint;
851
- exports.unstable_runWithPriority = unstable_runWithPriority;
852
- exports.unstable_scheduleCallback = unstable_scheduleCallback;
853
- exports.unstable_shouldYield = unstable_shouldYield;
854
- exports.unstable_wrapCallback = unstable_wrapCallback;
855
- exports.unstable_yieldValue = unstable_yieldValue;
856
-
857
- })));