Dashboard sipadu mbip
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

scheduler-tracing.development.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. /** @license React v0.18.0
  2. * scheduler-tracing.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. 'use strict';
  10. if (process.env.NODE_ENV !== "production") {
  11. (function() {
  12. 'use strict';
  13. Object.defineProperty(exports, '__esModule', { value: true });
  14. // Helps identify side effects in render-phase lifecycle hooks and setState
  15. // reducers by double invoking them in Strict Mode.
  16. // To preserve the "Pause on caught exceptions" behavior of the debugger, we
  17. // replay the begin phase of a failed component inside invokeGuardedCallback.
  18. // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
  19. // Gather advanced timing metrics for Profiler subtrees.
  20. // Trace which interactions trigger each commit.
  21. var enableSchedulerTracing = true; // SSR experiments
  22. // Only used in www builds.
  23. // Only used in www builds.
  24. // Disable javascript: URL strings in href for XSS protection.
  25. // React Fire: prevent the value and checked attributes from syncing
  26. // with their related DOM properties
  27. // These APIs will no longer be "unstable" in the upcoming 16.7 release,
  28. // Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
  29. // Experimental React Flare event system and event components support.
  30. // Experimental Host Component support.
  31. // Experimental Scope support.
  32. // New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
  33. // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
  34. // Till then, we warn about the missing mock, but still fallback to a legacy mode compatible version
  35. // For tests, we flush suspense fallbacks in an act scope;
  36. // *except* in some of our own tests, where we test incremental loading states.
  37. // Add a callback property to suspense to notify which promises are currently
  38. // in the update queue. This allows reporting and tracing of what is causing
  39. // the user to see a loading state.
  40. // Also allows hydration callbacks to fire when a dehydrated boundary gets
  41. // hydrated or deleted.
  42. // Part of the simplification of React.createElement so we can eventually move
  43. // from React.createElement to React.jsx
  44. // https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
  45. // Flag to turn event.target and event.currentTarget in ReactNative from a reactTag to a component instance
  46. var DEFAULT_THREAD_ID = 0; // Counters used to generate unique IDs.
  47. var interactionIDCounter = 0;
  48. var threadIDCounter = 0; // Set of currently traced interactions.
  49. // Interactions "stack"–
  50. // Meaning that newly traced interactions are appended to the previously active set.
  51. // When an interaction goes out of scope, the previous set (if any) is restored.
  52. exports.__interactionsRef = null; // Listener(s) to notify when interactions begin and end.
  53. exports.__subscriberRef = null;
  54. if (enableSchedulerTracing) {
  55. exports.__interactionsRef = {
  56. current: new Set()
  57. };
  58. exports.__subscriberRef = {
  59. current: null
  60. };
  61. }
  62. function unstable_clear(callback) {
  63. if (!enableSchedulerTracing) {
  64. return callback();
  65. }
  66. var prevInteractions = exports.__interactionsRef.current;
  67. exports.__interactionsRef.current = new Set();
  68. try {
  69. return callback();
  70. } finally {
  71. exports.__interactionsRef.current = prevInteractions;
  72. }
  73. }
  74. function unstable_getCurrent() {
  75. if (!enableSchedulerTracing) {
  76. return null;
  77. } else {
  78. return exports.__interactionsRef.current;
  79. }
  80. }
  81. function unstable_getThreadID() {
  82. return ++threadIDCounter;
  83. }
  84. function unstable_trace(name, timestamp, callback) {
  85. var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID;
  86. if (!enableSchedulerTracing) {
  87. return callback();
  88. }
  89. var interaction = {
  90. __count: 1,
  91. id: interactionIDCounter++,
  92. name: name,
  93. timestamp: timestamp
  94. };
  95. var prevInteractions = exports.__interactionsRef.current; // Traced interactions should stack/accumulate.
  96. // To do that, clone the current interactions.
  97. // The previous set will be restored upon completion.
  98. var interactions = new Set(prevInteractions);
  99. interactions.add(interaction);
  100. exports.__interactionsRef.current = interactions;
  101. var subscriber = exports.__subscriberRef.current;
  102. var returnValue;
  103. try {
  104. if (subscriber !== null) {
  105. subscriber.onInteractionTraced(interaction);
  106. }
  107. } finally {
  108. try {
  109. if (subscriber !== null) {
  110. subscriber.onWorkStarted(interactions, threadID);
  111. }
  112. } finally {
  113. try {
  114. returnValue = callback();
  115. } finally {
  116. exports.__interactionsRef.current = prevInteractions;
  117. try {
  118. if (subscriber !== null) {
  119. subscriber.onWorkStopped(interactions, threadID);
  120. }
  121. } finally {
  122. interaction.__count--; // If no async work was scheduled for this interaction,
  123. // Notify subscribers that it's completed.
  124. if (subscriber !== null && interaction.__count === 0) {
  125. subscriber.onInteractionScheduledWorkCompleted(interaction);
  126. }
  127. }
  128. }
  129. }
  130. }
  131. return returnValue;
  132. }
  133. function unstable_wrap(callback) {
  134. var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID;
  135. if (!enableSchedulerTracing) {
  136. return callback;
  137. }
  138. var wrappedInteractions = exports.__interactionsRef.current;
  139. var subscriber = exports.__subscriberRef.current;
  140. if (subscriber !== null) {
  141. subscriber.onWorkScheduled(wrappedInteractions, threadID);
  142. } // Update the pending async work count for the current interactions.
  143. // Update after calling subscribers in case of error.
  144. wrappedInteractions.forEach(function (interaction) {
  145. interaction.__count++;
  146. });
  147. var hasRun = false;
  148. function wrapped() {
  149. var prevInteractions = exports.__interactionsRef.current;
  150. exports.__interactionsRef.current = wrappedInteractions;
  151. subscriber = exports.__subscriberRef.current;
  152. try {
  153. var returnValue;
  154. try {
  155. if (subscriber !== null) {
  156. subscriber.onWorkStarted(wrappedInteractions, threadID);
  157. }
  158. } finally {
  159. try {
  160. returnValue = callback.apply(undefined, arguments);
  161. } finally {
  162. exports.__interactionsRef.current = prevInteractions;
  163. if (subscriber !== null) {
  164. subscriber.onWorkStopped(wrappedInteractions, threadID);
  165. }
  166. }
  167. }
  168. return returnValue;
  169. } finally {
  170. if (!hasRun) {
  171. // We only expect a wrapped function to be executed once,
  172. // But in the event that it's executed more than once–
  173. // Only decrement the outstanding interaction counts once.
  174. hasRun = true; // Update pending async counts for all wrapped interactions.
  175. // If this was the last scheduled async work for any of them,
  176. // Mark them as completed.
  177. wrappedInteractions.forEach(function (interaction) {
  178. interaction.__count--;
  179. if (subscriber !== null && interaction.__count === 0) {
  180. subscriber.onInteractionScheduledWorkCompleted(interaction);
  181. }
  182. });
  183. }
  184. }
  185. }
  186. wrapped.cancel = function cancel() {
  187. subscriber = exports.__subscriberRef.current;
  188. try {
  189. if (subscriber !== null) {
  190. subscriber.onWorkCanceled(wrappedInteractions, threadID);
  191. }
  192. } finally {
  193. // Update pending async counts for all wrapped interactions.
  194. // If this was the last scheduled async work for any of them,
  195. // Mark them as completed.
  196. wrappedInteractions.forEach(function (interaction) {
  197. interaction.__count--;
  198. if (subscriber && interaction.__count === 0) {
  199. subscriber.onInteractionScheduledWorkCompleted(interaction);
  200. }
  201. });
  202. }
  203. };
  204. return wrapped;
  205. }
  206. var subscribers = null;
  207. if (enableSchedulerTracing) {
  208. subscribers = new Set();
  209. }
  210. function unstable_subscribe(subscriber) {
  211. if (enableSchedulerTracing) {
  212. subscribers.add(subscriber);
  213. if (subscribers.size === 1) {
  214. exports.__subscriberRef.current = {
  215. onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted,
  216. onInteractionTraced: onInteractionTraced,
  217. onWorkCanceled: onWorkCanceled,
  218. onWorkScheduled: onWorkScheduled,
  219. onWorkStarted: onWorkStarted,
  220. onWorkStopped: onWorkStopped
  221. };
  222. }
  223. }
  224. }
  225. function unstable_unsubscribe(subscriber) {
  226. if (enableSchedulerTracing) {
  227. subscribers.delete(subscriber);
  228. if (subscribers.size === 0) {
  229. exports.__subscriberRef.current = null;
  230. }
  231. }
  232. }
  233. function onInteractionTraced(interaction) {
  234. var didCatchError = false;
  235. var caughtError = null;
  236. subscribers.forEach(function (subscriber) {
  237. try {
  238. subscriber.onInteractionTraced(interaction);
  239. } catch (error) {
  240. if (!didCatchError) {
  241. didCatchError = true;
  242. caughtError = error;
  243. }
  244. }
  245. });
  246. if (didCatchError) {
  247. throw caughtError;
  248. }
  249. }
  250. function onInteractionScheduledWorkCompleted(interaction) {
  251. var didCatchError = false;
  252. var caughtError = null;
  253. subscribers.forEach(function (subscriber) {
  254. try {
  255. subscriber.onInteractionScheduledWorkCompleted(interaction);
  256. } catch (error) {
  257. if (!didCatchError) {
  258. didCatchError = true;
  259. caughtError = error;
  260. }
  261. }
  262. });
  263. if (didCatchError) {
  264. throw caughtError;
  265. }
  266. }
  267. function onWorkScheduled(interactions, threadID) {
  268. var didCatchError = false;
  269. var caughtError = null;
  270. subscribers.forEach(function (subscriber) {
  271. try {
  272. subscriber.onWorkScheduled(interactions, threadID);
  273. } catch (error) {
  274. if (!didCatchError) {
  275. didCatchError = true;
  276. caughtError = error;
  277. }
  278. }
  279. });
  280. if (didCatchError) {
  281. throw caughtError;
  282. }
  283. }
  284. function onWorkStarted(interactions, threadID) {
  285. var didCatchError = false;
  286. var caughtError = null;
  287. subscribers.forEach(function (subscriber) {
  288. try {
  289. subscriber.onWorkStarted(interactions, threadID);
  290. } catch (error) {
  291. if (!didCatchError) {
  292. didCatchError = true;
  293. caughtError = error;
  294. }
  295. }
  296. });
  297. if (didCatchError) {
  298. throw caughtError;
  299. }
  300. }
  301. function onWorkStopped(interactions, threadID) {
  302. var didCatchError = false;
  303. var caughtError = null;
  304. subscribers.forEach(function (subscriber) {
  305. try {
  306. subscriber.onWorkStopped(interactions, threadID);
  307. } catch (error) {
  308. if (!didCatchError) {
  309. didCatchError = true;
  310. caughtError = error;
  311. }
  312. }
  313. });
  314. if (didCatchError) {
  315. throw caughtError;
  316. }
  317. }
  318. function onWorkCanceled(interactions, threadID) {
  319. var didCatchError = false;
  320. var caughtError = null;
  321. subscribers.forEach(function (subscriber) {
  322. try {
  323. subscriber.onWorkCanceled(interactions, threadID);
  324. } catch (error) {
  325. if (!didCatchError) {
  326. didCatchError = true;
  327. caughtError = error;
  328. }
  329. }
  330. });
  331. if (didCatchError) {
  332. throw caughtError;
  333. }
  334. }
  335. exports.unstable_clear = unstable_clear;
  336. exports.unstable_getCurrent = unstable_getCurrent;
  337. exports.unstable_getThreadID = unstable_getThreadID;
  338. exports.unstable_trace = unstable_trace;
  339. exports.unstable_wrap = unstable_wrap;
  340. exports.unstable_subscribe = unstable_subscribe;
  341. exports.unstable_unsubscribe = unstable_unsubscribe;
  342. })();
  343. }