UNPKG

1.98 kBSource Map (JSON)View Raw
1{"version":3,"file":"gatsby-ssr.js","names":["onRenderBody","pathname","setHeadComponents","collectedScripts","collectedScriptsByPage","get","length","forwards","getForwards","__html","partytownSnippet","forward","delete"],"sources":["../../../src/internal-plugins/partytown/gatsby-ssr.tsx"],"sourcesContent":["import React from \"react\"\nimport { collectedScriptsByPage } from \"gatsby-script\"\nimport { getForwards } from \"./utils/get-forwards\"\nimport { partytownSnippet } from \"@builder.io/partytown/integration\"\nimport type { GatsbySSR } from \"gatsby\"\n\nexport const onRenderBody: GatsbySSR[`onRenderBody`] = ({\n pathname,\n setHeadComponents,\n}) => {\n const collectedScripts = collectedScriptsByPage.get(pathname)\n\n if (!collectedScripts?.length) {\n return\n }\n\n const forwards = getForwards(collectedScripts)\n\n // Adapted from https://github.com/BuilderIO/partytown/blob/main/src/react/snippet.tsx to only include SSR logic\n setHeadComponents([\n <script\n key=\"partytown\"\n data-partytown=\"\"\n suppressHydrationWarning={true}\n dangerouslySetInnerHTML={{\n __html: `\n ${partytownSnippet({ forward: forwards })}\n document.currentScript.dataset.partytown=\"\"\n `,\n }}\n />,\n ])\n\n // Clear scripts after we've used them to avoid leaky behavior\n collectedScriptsByPage.delete(pathname)\n}\n"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AAGO,MAAMA,YAAuC,GAAG,CAAC;EACtDC,QAAQ;EACRC;AACF,CAAC,KAAK;EACJ,MAAMC,gBAAgB,GAAGC,oCAAsB,CAACC,GAAG,CAACJ,QAAQ,CAAC;EAE7D,IAAI,EAACE,gBAAgB,aAAhBA,gBAAgB,eAAhBA,gBAAgB,CAAEG,MAAM,GAAE;IAC7B;EACF;EAEA,MAAMC,QAAQ,GAAG,IAAAC,wBAAW,EAACL,gBAAgB,CAAC;;EAE9C;EACAD,iBAAiB,CAAC,cAChB;IACE,GAAG,EAAC,WAAW;IACf,kBAAe,EAAE;IACjB,wBAAwB,EAAE,IAAK;IAC/B,uBAAuB,EAAE;MACvBO,MAAM,EAAG;AACjB,YAAY,IAAAC,6BAAgB,EAAC;QAAEC,OAAO,EAAEJ;MAAS,CAAC,CAAE;AACpD;AACA;IACM;EAAE,EACF,CACH,CAAC;;EAEF;EACAH,oCAAsB,CAACQ,MAAM,CAACX,QAAQ,CAAC;AACzC,CAAC;AAAA"}
\No newline at end of file