You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Scripted/website/node_modules/.cache/babel-loader/2a0031edf994289a2df284d553e...

1 line
9.4 KiB

{"ast":null,"code":"import $89yE2$react, { useContext as $89yE2$useContext, useMemo as $89yE2$useMemo, useState as $89yE2$useState, useLayoutEffect as $89yE2$useLayoutEffect } from \"react\";\n\n// Default context value to use in case there is no SSRProvider. This is fine for\n// client-only apps. In order to support multiple copies of React Aria potentially\n// being on the page at once, the prefix is set to a random number. SSRProvider\n// will reset this to zero for consistency between server and client, so in the\n// SSR case multiple copies of React Aria is not supported.\nconst $704cf1d3b684cc5c$var$defaultContext = {\n prefix: String(Math.round(Math.random() * 10000000000)),\n current: 0\n};\nconst $704cf1d3b684cc5c$var$SSRContext = /*#__PURE__*/$89yE2$react.createContext($704cf1d3b684cc5c$var$defaultContext);\nfunction $704cf1d3b684cc5c$export$9f8ac96af4b1b2ae(props) {\n let cur = $89yE2$useContext($704cf1d3b684cc5c$var$SSRContext);\n let value = $89yE2$useMemo(() => ({\n // If this is the first SSRProvider, start with an empty string prefix, otherwise\n // append and increment the counter.\n prefix: cur === $704cf1d3b684cc5c$var$defaultContext ? '' : `${cur.prefix}-${++cur.current}`,\n current: 0\n }), [cur]);\n return /*#__PURE__*/$89yE2$react.createElement($704cf1d3b684cc5c$var$SSRContext.Provider, {\n value: value\n }, props.children);\n}\nlet $704cf1d3b684cc5c$var$canUseDOM = Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);\nfunction $704cf1d3b684cc5c$export$619500959fc48b26(defaultId) {\n let ctx = $89yE2$useContext($704cf1d3b684cc5c$var$SSRContext);\n // If we are rendering in a non-DOM environment, and there's no SSRProvider,\n // provide a warning to hint to the developer to add one.\n if (ctx === $704cf1d3b684cc5c$var$defaultContext && !$704cf1d3b684cc5c$var$canUseDOM) console.warn('When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.');\n return $89yE2$useMemo(() => defaultId || `react-aria${ctx.prefix}-${++ctx.current}`, [defaultId]);\n}\nfunction $704cf1d3b684cc5c$export$535bd6ca7f90a273() {\n let cur = $89yE2$useContext($704cf1d3b684cc5c$var$SSRContext);\n let isInSSRContext = cur !== $704cf1d3b684cc5c$var$defaultContext;\n let [isSSR, setIsSSR] = $89yE2$useState(isInSSRContext);\n // If on the client, and the component was initially server rendered,\n // then schedule a layout effect to update the component after hydration.\n if (typeof window !== 'undefined' && isInSSRContext)\n // This if statement technically breaks the rules of hooks, but is safe\n // because the condition never changes after mounting.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n $89yE2$useLayoutEffect(() => {\n setIsSSR(false);\n }, []);\n return isSSR;\n}\nexport { $704cf1d3b684cc5c$export$9f8ac96af4b1b2ae as SSRProvider, $704cf1d3b684cc5c$export$619500959fc48b26 as useSSRSafeId, $704cf1d3b684cc5c$export$535bd6ca7f90a273 as useIsSSR };","map":{"version":3,"mappings":";;AA4BA;AACA;AACA;AACA;AACA;AACA,MAAMA,oCAAc,GAAoB;EACtCC,MAAM,EAAEC,MAAM,CAACC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,MAAM,KAAK,WAAW;EACrDC,OAAO,EAAE;AACX,CAAC;AAED,MAAMC,gCAAU,gBAAGC,YAAK,CAACC,aAAa,CAAkBT,oCAAc;SAWtDU,yCAAW,CAACC,KAAuB,EAAe;EAChE,IAAIC,GAAG,GAAGC,iBAAU,CAACN,gCAAU;EAC/B,IAAIO,KAAK,GAAoBC,cAAO,QAAQ;IAC1C;IACA;IACAd,MAAM,EAAEW,GAAG,KAAKZ,oCAAc,GAAG,EAAE,MAAMY,GAAG,CAACX,MAAO,IAAC,EAAIW,GAAG,CAACN,OAAO;IACpEA,OAAO,EAAE;EACX,CAAC,GAAG,CAACM,GAAG,CAAC;EAET,OAAM,wCACHL,gCAAU,CAACS,QAAQ;IAACF,KAAK,EAAEA;KACzBH,KAAK,CAACM,QAAQ;AAGrB;AAEA,IAAIC,+BAAS,GAAGC,OAAO,CACrB,OAAOC,MAAM,KAAK,WAAW,IAC7BA,MAAM,CAACC,QAAQ,IACfD,MAAM,CAACC,QAAQ,CAACC,aAAa;SAIfC,yCAAY,CAACC,SAAkB,EAAU;EACvD,IAAIC,GAAG,GAAGZ,iBAAU,CAACN,gCAAU;EAE/B;EACA;EACA,IAAIkB,GAAG,KAAKzB,oCAAc,KAAKkB,+BAAS,EACtCQ,OAAO,CAACC,IAAI,CAAC,iJAAiJ;EAGhK,OAAOZ,cAAO,OAAOS,SAAS,IAAK,aAAYC,GAAG,CAACxB,MAAO,IAAC,EAAIwB,GAAG,CAACnB,OAAO,IAAI,CAACkB,SAAS,CAAC;AAC3F;SAOgBI,yCAAQ,GAAY;EAClC,IAAIhB,GAAG,GAAGC,iBAAU,CAACN,gCAAU;EAC/B,IAAIsB,cAAc,GAAGjB,GAAG,KAAKZ,oCAAc;EAC3C,IAAG,CAAE8B,KAAK,EAAEC,QAAQ,IAAIC,eAAQ,CAACH,cAAc;EAE/C;EACA;EACA,IAAI,OAAOT,MAAM,KAAK,WAAW,IAAIS,cAAc;IACjD;IACA;IACA;IACAI,sBAAe,OAAO;MACpBF,QAAQ,CAAC,KAAK;IAChB,CAAC,EAAE,EAAE;EAGP,OAAOD,KAAK;AACd","names":["$704cf1d3b684cc5c$var$defaultContext","prefix","String","Math","round","random","current","$704cf1d3b684cc5c$var$SSRContext","$89yE2$react","createContext","$704cf1d3b684cc5c$export$9f8ac96af4b1b2ae","props","cur","$89yE2$useContext","value","$89yE2$useMemo","Provider","children","$704cf1d3b684cc5c$var$canUseDOM","Boolean","window","document","createElement","$704cf1d3b684cc5c$export$619500959fc48b26","defaultId","ctx","console","warn","$704cf1d3b684cc5c$export$535bd6ca7f90a273","isInSSRContext","isSSR","setIsSSR","$89yE2$useState","$89yE2$useLayoutEffect"],"sources":["C:\\Cours\\SAE\\SAE-3.01\\Scripted\\Scripted\\website\\node_modules\\@react-aria\\ssr\\dist\\packages\\@react-aria\\ssr\\src\\SSRProvider.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// We must avoid a circular dependency with @react-aria/utils, and this useLayoutEffect is\n// guarded by a check that it only runs on the client side.\n// eslint-disable-next-line rulesdir/useLayoutEffectRule\nimport React, {ReactNode, useContext, useLayoutEffect, useMemo, useState} from 'react';\n\n// To support SSR, the auto incrementing id counter is stored in a context. This allows\n// it to be reset on every request to ensure the client and server are consistent.\n// There is also a prefix string that is used to support async loading components\n// Each async boundary must be wrapped in an SSR provider, which appends to the prefix\n// and resets the current id counter. This ensures that async loaded components have\n// consistent ids regardless of the loading order.\ninterface SSRContextValue {\n prefix: string,\n current: number\n}\n\n// Default context value to use in case there is no SSRProvider. This is fine for\n// client-only apps. In order to support multiple copies of React Aria potentially\n// being on the page at once, the prefix is set to a random number. SSRProvider\n// will reset this to zero for consistency between server and client, so in the\n// SSR case multiple copies of React Aria is not supported.\nconst defaultContext: SSRContextValue = {\n prefix: String(Math.round(Math.random() * 10000000000)),\n current: 0\n};\n\nconst SSRContext = React.createContext<SSRContextValue>(defaultContext);\n\nexport interface SSRProviderProps {\n /** Your application here. */\n children: ReactNode\n}\n\n/**\n * When using SSR with React Aria, applications must be wrapped in an SSRProvider.\n * This ensures that auto generated ids are consistent between the client and server.\n */\nexport function SSRProvider(props: SSRProviderProps): JSX.Element {\n let cur = useContext(SSRContext);\n let value: SSRContextValue = useMemo(() => ({\n // If this is the first SSRProvider, start with an empty string prefix, otherwise\n // append and increment the counter.\n prefix: cur === defaultContext ? '' : `${cur.prefix}-${++cur.current}`,\n current: 0\n }), [cur]);\n\n return (\n <SSRContext.Provider value={value}>\n {props.children}\n </SSRContext.Provider>\n );\n}\n\nlet canUseDOM = Boolean(\n typeof window !== 'undefined' &&\n window.document &&\n window.document.createElement\n);\n\n/** @private */\nexport function useSSRSafeId(defaultId?: string): string {\n let ctx = useContext(SSRContext);\n\n // If we are rendering in a non-DOM environment, and there's no SSRProvider,\n // provide a warning to hint to the developer to add one.\n if (ctx === defaultContext && !canUseDOM) {\n console.warn('When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.');\n }\n\n return useMemo(() => defaultId || `react-aria${ctx.prefix}-${++ctx.current}`, [defaultId]);\n}\n\n/**\n * Returns whether the component is currently being server side rendered or\n * hydrated on the client. Can be used to delay browser-specific rendering\n * until after hydration.\n */\nexport function useIsSSR(): boolean {\n let cur = useContext(SSRContext);\n let isInSSRContext = cur !== defaultContext;\n let [isSSR, setIsSSR] = useState(isInSSRContext);\n\n // If on the client, and the component was initially server rendered,\n // then schedule a layout effect to update the component after hydration.\n if (typeof window !== 'undefined' && isInSSRContext) {\n // This if statement technically breaks the rules of hooks, but is safe\n // because the condition never changes after mounting.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useLayoutEffect(() => {\n setIsSSR(false);\n }, []);\n }\n\n return isSSR;\n}\n"]},"metadata":{},"sourceType":"module"}