1 line
13 KiB
JSON
1 line
13 KiB
JSON
{"ast":null,"code":"/** @license React v0.18.0\n * scheduler-tracing.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function () {\n 'use strict';\n\n Object.defineProperty(exports, '__esModule', {\n value: true\n }); // Helps identify side effects in render-phase lifecycle hooks and setState\n // reducers by double invoking them in Strict Mode.\n // To preserve the \"Pause on caught exceptions\" behavior of the debugger, we\n // replay the begin phase of a failed component inside invokeGuardedCallback.\n // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:\n // Gather advanced timing metrics for Profiler subtrees.\n // Trace which interactions trigger each commit.\n\n var enableSchedulerTracing = true; // SSR experiments\n // Only used in www builds.\n // Only used in www builds.\n // Disable javascript: URL strings in href for XSS protection.\n // React Fire: prevent the value and checked attributes from syncing\n // with their related DOM properties\n // These APIs will no longer be \"unstable\" in the upcoming 16.7 release,\n // Control this behavior with a flag to support 16.6 minor releases in the meanwhile.\n // Experimental React Flare event system and event components support.\n // Experimental Host Component support.\n // Experimental Scope support.\n // New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107\n // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)\n // Till then, we warn about the missing mock, but still fallback to a legacy mode compatible version\n // For tests, we flush suspense fallbacks in an act scope;\n // *except* in some of our own tests, where we test incremental loading states.\n // Add a callback property to suspense to notify which promises are currently\n // in the update queue. This allows reporting and tracing of what is causing\n // the user to see a loading state.\n // Also allows hydration callbacks to fire when a dehydrated boundary gets\n // hydrated or deleted.\n // Part of the simplification of React.createElement so we can eventually move\n // from React.createElement to React.jsx\n // https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md\n // Flag to turn event.target and event.currentTarget in ReactNative from a reactTag to a component instance\n\n var DEFAULT_THREAD_ID = 0; // Counters used to generate unique IDs.\n\n var interactionIDCounter = 0;\n var threadIDCounter = 0; // Set of currently traced interactions.\n // Interactions \"stack\"–\n // Meaning that newly traced interactions are appended to the previously active set.\n // When an interaction goes out of scope, the previous set (if any) is restored.\n\n exports.__interactionsRef = null; // Listener(s) to notify when interactions begin and end.\n\n exports.__subscriberRef = null;\n\n if (enableSchedulerTracing) {\n exports.__interactionsRef = {\n current: new Set()\n };\n exports.__subscriberRef = {\n current: null\n };\n }\n\n function unstable_clear(callback) {\n if (!enableSchedulerTracing) {\n return callback();\n }\n\n var prevInteractions = exports.__interactionsRef.current;\n exports.__interactionsRef.current = new Set();\n\n try {\n return callback();\n } finally {\n exports.__interactionsRef.current = prevInteractions;\n }\n }\n\n function unstable_getCurrent() {\n if (!enableSchedulerTracing) {\n return null;\n } else {\n return exports.__interactionsRef.current;\n }\n }\n\n function unstable_getThreadID() {\n return ++threadIDCounter;\n }\n\n function unstable_trace(name, timestamp, callback) {\n var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID;\n\n if (!enableSchedulerTracing) {\n return callback();\n }\n\n var interaction = {\n __count: 1,\n id: interactionIDCounter++,\n name: name,\n timestamp: timestamp\n };\n var prevInteractions = exports.__interactionsRef.current; // Traced interactions should stack/accumulate.\n // To do that, clone the current interactions.\n // The previous set will be restored upon completion.\n\n var interactions = new Set(prevInteractions);\n interactions.add(interaction);\n exports.__interactionsRef.current = interactions;\n var subscriber = exports.__subscriberRef.current;\n var returnValue;\n\n try {\n if (subscriber !== null) {\n subscriber.onInteractionTraced(interaction);\n }\n } finally {\n try {\n if (subscriber !== null) {\n subscriber.onWorkStarted(interactions, threadID);\n }\n } finally {\n try {\n returnValue = callback();\n } finally {\n exports.__interactionsRef.current = prevInteractions;\n\n try {\n if (subscriber !== null) {\n subscriber.onWorkStopped(interactions, threadID);\n }\n } finally {\n interaction.__count--; // If no async work was scheduled for this interaction,\n // Notify subscribers that it's completed.\n\n if (subscriber !== null && interaction.__count === 0) {\n subscriber.onInteractionScheduledWorkCompleted(interaction);\n }\n }\n }\n }\n }\n\n return returnValue;\n }\n\n function unstable_wrap(callback) {\n var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID;\n\n if (!enableSchedulerTracing) {\n return callback;\n }\n\n var wrappedInteractions = exports.__interactionsRef.current;\n var subscriber = exports.__subscriberRef.current;\n\n if (subscriber !== null) {\n subscriber.onWorkScheduled(wrappedInteractions, threadID);\n } // Update the pending async work count for the current interactions.\n // Update after calling subscribers in case of error.\n\n\n wrappedInteractions.forEach(function (interaction) {\n interaction.__count++;\n });\n var hasRun = false;\n\n function wrapped() {\n var prevInteractions = exports.__interactionsRef.current;\n exports.__interactionsRef.current = wrappedInteractions;\n subscriber = exports.__subscriberRef.current;\n\n try {\n var returnValue;\n\n try {\n if (subscriber !== null) {\n subscriber.onWorkStarted(wrappedInteractions, threadID);\n }\n } finally {\n try {\n returnValue = callback.apply(undefined, arguments);\n } finally {\n exports.__interactionsRef.current = prevInteractions;\n\n if (subscriber !== null) {\n subscriber.onWorkStopped(wrappedInteractions, threadID);\n }\n }\n }\n\n return returnValue;\n } finally {\n if (!hasRun) {\n // We only expect a wrapped function to be executed once,\n // But in the event that it's executed more than once–\n // Only decrement the outstanding interaction counts once.\n hasRun = true; // Update pending async counts for all wrapped interactions.\n // If this was the last scheduled async work for any of them,\n // Mark them as completed.\n\n wrappedInteractions.forEach(function (interaction) {\n interaction.__count--;\n\n if (subscriber !== null && interaction.__count === 0) {\n subscriber.onInteractionScheduledWorkCompleted(interaction);\n }\n });\n }\n }\n }\n\n wrapped.cancel = function cancel() {\n subscriber = exports.__subscriberRef.current;\n\n try {\n if (subscriber !== null) {\n subscriber.onWorkCanceled(wrappedInteractions, threadID);\n }\n } finally {\n // Update pending async counts for all wrapped interactions.\n // If this was the last scheduled async work for any of them,\n // Mark them as completed.\n wrappedInteractions.forEach(function (interaction) {\n interaction.__count--;\n\n if (subscriber && interaction.__count === 0) {\n subscriber.onInteractionScheduledWorkCompleted(interaction);\n }\n });\n }\n };\n\n return wrapped;\n }\n\n var subscribers = null;\n\n if (enableSchedulerTracing) {\n subscribers = new Set();\n }\n\n function unstable_subscribe(subscriber) {\n if (enableSchedulerTracing) {\n subscribers.add(subscriber);\n\n if (subscribers.size === 1) {\n exports.__subscriberRef.current = {\n onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted,\n onInteractionTraced: onInteractionTraced,\n onWorkCanceled: onWorkCanceled,\n onWorkScheduled: onWorkScheduled,\n onWorkStarted: onWorkStarted,\n onWorkStopped: onWorkStopped\n };\n }\n }\n }\n\n function unstable_unsubscribe(subscriber) {\n if (enableSchedulerTracing) {\n subscribers.delete(subscriber);\n\n if (subscribers.size === 0) {\n exports.__subscriberRef.current = null;\n }\n }\n }\n\n function onInteractionTraced(interaction) {\n var didCatchError = false;\n var caughtError = null;\n subscribers.forEach(function (subscriber) {\n try {\n subscriber.onInteractionTraced(interaction);\n } catch (error) {\n if (!didCatchError) {\n didCatchError = true;\n caughtError = error;\n }\n }\n });\n\n if (didCatchError) {\n throw caughtError;\n }\n }\n\n function onInteractionScheduledWorkCompleted(interaction) {\n var didCatchError = false;\n var caughtError = null;\n subscribers.forEach(function (subscriber) {\n try {\n subscriber.onInteractionScheduledWorkCompleted(interaction);\n } catch (error) {\n if (!didCatchError) {\n didCatchError = true;\n caughtError = error;\n }\n }\n });\n\n if (didCatchError) {\n throw caughtError;\n }\n }\n\n function onWorkScheduled(interactions, threadID) {\n var didCatchError = false;\n var caughtError = null;\n subscribers.forEach(function (subscriber) {\n try {\n subscriber.onWorkScheduled(interactions, threadID);\n } catch (error) {\n if (!didCatchError) {\n didCatchError = true;\n caughtError = error;\n }\n }\n });\n\n if (didCatchError) {\n throw caughtError;\n }\n }\n\n function onWorkStarted(interactions, threadID) {\n var didCatchError = false;\n var caughtError = null;\n subscribers.forEach(function (subscriber) {\n try {\n subscriber.onWorkStarted(interactions, threadID);\n } catch (error) {\n if (!didCatchError) {\n didCatchError = true;\n caughtError = error;\n }\n }\n });\n\n if (didCatchError) {\n throw caughtError;\n }\n }\n\n function onWorkStopped(interactions, threadID) {\n var didCatchError = false;\n var caughtError = null;\n subscribers.forEach(function (subscriber) {\n try {\n subscriber.onWorkStopped(interactions, threadID);\n } catch (error) {\n if (!didCatchError) {\n didCatchError = true;\n caughtError = error;\n }\n }\n });\n\n if (didCatchError) {\n throw caughtError;\n }\n }\n\n function onWorkCanceled(interactions, threadID) {\n var didCatchError = false;\n var caughtError = null;\n subscribers.forEach(function (subscriber) {\n try {\n subscriber.onWorkCanceled(interactions, threadID);\n } catch (error) {\n if (!didCatchError) {\n didCatchError = true;\n caughtError = error;\n }\n }\n });\n\n if (didCatchError) {\n throw caughtError;\n }\n }\n\n exports.unstable_clear = unstable_clear;\n exports.unstable_getCurrent = unstable_getCurrent;\n exports.unstable_getThreadID = unstable_getThreadID;\n exports.unstable_trace = unstable_trace;\n exports.unstable_wrap = unstable_wrap;\n exports.unstable_subscribe = unstable_subscribe;\n exports.unstable_unsubscribe = unstable_unsubscribe;\n })();\n}","map":null,"metadata":{},"sourceType":"script"} |