| [a762898] | 1 | /**
|
|---|
| 2 | * @license React
|
|---|
| 3 | * use-sync-external-store-shim.development.js
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright (c) Meta Platforms, Inc. and affiliates.
|
|---|
| 6 | *
|
|---|
| 7 | * This source code is licensed under the MIT license found in the
|
|---|
| 8 | * LICENSE file in the root directory of this source tree.
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 | "use strict";
|
|---|
| 12 | "production" !== process.env.NODE_ENV &&
|
|---|
| 13 | (function () {
|
|---|
| 14 | function is(x, y) {
|
|---|
| 15 | return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
|
|---|
| 16 | }
|
|---|
| 17 | function useSyncExternalStore$2(subscribe, getSnapshot) {
|
|---|
| 18 | didWarnOld18Alpha ||
|
|---|
| 19 | void 0 === React.startTransition ||
|
|---|
| 20 | ((didWarnOld18Alpha = !0),
|
|---|
| 21 | console.error(
|
|---|
| 22 | "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
|
|---|
| 23 | ));
|
|---|
| 24 | var value = getSnapshot();
|
|---|
| 25 | if (!didWarnUncachedGetSnapshot) {
|
|---|
| 26 | var cachedValue = getSnapshot();
|
|---|
| 27 | objectIs(value, cachedValue) ||
|
|---|
| 28 | (console.error(
|
|---|
| 29 | "The result of getSnapshot should be cached to avoid an infinite loop"
|
|---|
| 30 | ),
|
|---|
| 31 | (didWarnUncachedGetSnapshot = !0));
|
|---|
| 32 | }
|
|---|
| 33 | cachedValue = useState({
|
|---|
| 34 | inst: { value: value, getSnapshot: getSnapshot }
|
|---|
| 35 | });
|
|---|
| 36 | var inst = cachedValue[0].inst,
|
|---|
| 37 | forceUpdate = cachedValue[1];
|
|---|
| 38 | useLayoutEffect(
|
|---|
| 39 | function () {
|
|---|
| 40 | inst.value = value;
|
|---|
| 41 | inst.getSnapshot = getSnapshot;
|
|---|
| 42 | checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
|
|---|
| 43 | },
|
|---|
| 44 | [subscribe, value, getSnapshot]
|
|---|
| 45 | );
|
|---|
| 46 | useEffect(
|
|---|
| 47 | function () {
|
|---|
| 48 | checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
|
|---|
| 49 | return subscribe(function () {
|
|---|
| 50 | checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
|
|---|
| 51 | });
|
|---|
| 52 | },
|
|---|
| 53 | [subscribe]
|
|---|
| 54 | );
|
|---|
| 55 | useDebugValue(value);
|
|---|
| 56 | return value;
|
|---|
| 57 | }
|
|---|
| 58 | function checkIfSnapshotChanged(inst) {
|
|---|
| 59 | var latestGetSnapshot = inst.getSnapshot;
|
|---|
| 60 | inst = inst.value;
|
|---|
| 61 | try {
|
|---|
| 62 | var nextValue = latestGetSnapshot();
|
|---|
| 63 | return !objectIs(inst, nextValue);
|
|---|
| 64 | } catch (error) {
|
|---|
| 65 | return !0;
|
|---|
| 66 | }
|
|---|
| 67 | }
|
|---|
| 68 | function useSyncExternalStore$1(subscribe, getSnapshot) {
|
|---|
| 69 | return getSnapshot();
|
|---|
| 70 | }
|
|---|
| 71 | "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
|
|---|
| 72 | "function" ===
|
|---|
| 73 | typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart &&
|
|---|
| 74 | __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|---|
| 75 | var React = require("react"),
|
|---|
| 76 | objectIs = "function" === typeof Object.is ? Object.is : is,
|
|---|
| 77 | useState = React.useState,
|
|---|
| 78 | useEffect = React.useEffect,
|
|---|
| 79 | useLayoutEffect = React.useLayoutEffect,
|
|---|
| 80 | useDebugValue = React.useDebugValue,
|
|---|
| 81 | didWarnOld18Alpha = !1,
|
|---|
| 82 | didWarnUncachedGetSnapshot = !1,
|
|---|
| 83 | shim =
|
|---|
| 84 | "undefined" === typeof window ||
|
|---|
| 85 | "undefined" === typeof window.document ||
|
|---|
| 86 | "undefined" === typeof window.document.createElement
|
|---|
| 87 | ? useSyncExternalStore$1
|
|---|
| 88 | : useSyncExternalStore$2;
|
|---|
| 89 | exports.useSyncExternalStore =
|
|---|
| 90 | void 0 !== React.useSyncExternalStore ? React.useSyncExternalStore : shim;
|
|---|
| 91 | "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
|
|---|
| 92 | "function" ===
|
|---|
| 93 | typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
|
|---|
| 94 | __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|---|
| 95 | })();
|
|---|