-
Notifications
You must be signed in to change notification settings - Fork 0
/
3-b7ee8d62a93ceb63a471.js.map
1 lines (1 loc) · 3.78 KB
/
3-b7ee8d62a93ceb63a471.js.map
1
{"version":3,"sources":["webpack:///../src/components/lazy-hydrate.tsx"],"names":["lazyHydrate","root","hydrated","forceHydrate","image","loading","isLoading","isLoaded","toggleIsLoaded","ref","imgClassName","imgStyle","objectPosition","backgroundColor","objectFit","props","width","height","layout","images","placeholder","wrapperBackgroundColor","cacheKey","JSON","stringify","component","React","LayoutWrapper","Placeholder","getPlaceholderProps","MainImage","className","getMainProps","current","render","hydrate"],"mappings":"2WAgBgBA,IAedC,EACAC,EACAC,OAfEC,UACAC,YACAC,cACAC,aACAC,mBACAC,QACAC,qBACAC,sBAAW,KACXC,mBACAC,wBACAC,iCACGC,mBAOHC,EAMEZ,EANFY,MACAC,EAKEb,EALFa,OACAC,EAIEd,EAJFc,OACAC,EAGEf,EAHFe,OACAC,EAEEhB,EAFFgB,YACiBC,EACfjB,EADFS,gBAGIS,EAAWC,KAAKC,UAAUL,GAEhCR,eACEG,YACAF,iBACAC,mBACGF,GAGL,IAAMc,EACJC,kBAACC,KAAcT,OAAQA,EAAQF,MAAOA,EAAOC,OAAQA,GACnDS,kBAACE,qBACKC,YACFT,EACAb,EACAW,EACAF,EACAC,EACAI,EACAP,EACAF,KAIJc,kBAACI,qBACMf,GACLC,MAAOA,EACPC,OAAQA,EACRc,UAAWrB,GACPsB,YACF1B,EACAC,EACAY,EACAd,EACAG,EACAc,EACAb,EACAE,MAaR,OAPIV,EAAKgC,WAEU/B,EAAS+B,SAAW9B,EAAa8B,QAAUC,SAASC,WAC5DV,EAAWxB,EAAKgC,SACzB/B,EAAS+B,YAAU,WAIfhC,EAAKgC,SACPC,iBAAQ,KAAkCjC,EAAKgC","file":"3-b7ee8d62a93ceb63a471.js","sourcesContent":["import React, { MutableRefObject } from \"react\"\nimport { hydrate, render } from \"react-dom\"\nimport { GatsbyImageProps } from \"./gatsby-image.browser\"\nimport { LayoutWrapper } from \"./layout-wrapper\"\nimport { Placeholder } from \"./placeholder\"\nimport { MainImageProps, MainImage } from \"./main-image\"\nimport { getMainProps, getPlaceholderProps } from \"./hooks\"\nimport { ReactElement } from \"react\"\n\ntype LazyHydrateProps = Omit<GatsbyImageProps, \"as\" | \"style\" | \"className\"> & {\n isLoading: boolean\n isLoaded: boolean // alwaystype SetStateAction<S> = S | ((prevState: S) => S);\n toggleIsLoaded: (toggle: boolean) => void\n ref: MutableRefObject<HTMLImageElement | undefined>\n}\n\nexport function lazyHydrate(\n {\n image,\n loading,\n isLoading,\n isLoaded,\n toggleIsLoaded,\n ref,\n imgClassName,\n imgStyle = {},\n objectPosition,\n backgroundColor,\n objectFit = `cover`,\n ...props\n }: LazyHydrateProps,\n root: MutableRefObject<HTMLElement | undefined>,\n hydrated: MutableRefObject<boolean>,\n forceHydrate: MutableRefObject<boolean>\n): (() => void) | null {\n const {\n width,\n height,\n layout,\n images,\n placeholder,\n backgroundColor: wrapperBackgroundColor,\n } = image\n\n const cacheKey = JSON.stringify(images)\n\n imgStyle = {\n objectFit,\n objectPosition,\n backgroundColor,\n ...imgStyle,\n }\n\n const component = (\n <LayoutWrapper layout={layout} width={width} height={height}>\n <Placeholder\n {...getPlaceholderProps(\n placeholder,\n isLoaded,\n layout,\n width,\n height,\n wrapperBackgroundColor,\n objectFit,\n objectPosition\n )}\n />\n\n <MainImage\n {...(props as Omit<MainImageProps, \"images\" | \"fallback\">)}\n width={width}\n height={height}\n className={imgClassName}\n {...getMainProps(\n isLoading,\n isLoaded,\n images,\n loading,\n toggleIsLoaded,\n cacheKey,\n ref,\n imgStyle\n )}\n />\n </LayoutWrapper>\n )\n\n if (root.current) {\n // Force render to mitigate \"Expected server HTML to contain a matching\" in develop\n const doRender = hydrated.current || forceHydrate.current ? render : hydrate\n doRender(component, root.current)\n hydrated.current = true\n }\n\n return (): void => {\n if (root.current) {\n render((null as unknown) as ReactElement, root.current)\n }\n }\n}\n"],"sourceRoot":""}