@chromatic-com/cypress 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { rebuild } from 'rrweb-snapshot';
|
|
1
|
+
import { rebuild, NodeType } from 'rrweb-snapshot';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var r=new URL(window.location.href);r.pathname="";r.search="";var p=r.toString().replace(/\/$/,""),o=e=>{if(e.type===NodeType.Element&&e.tagName==="html")return e;if("childNodes"in e)return e.childNodes.find(t=>o(t))},m=async(e,t)=>{let{url:n,id:s}=e.storyContext.parameters.server,d=await(await fetch(`${n}/${s}`)).json(),i=o(d),a=await rebuild(i,{doc:document});return document.replaceChild(a,document.children[0]),document.head.innerHTML+='<script id="storybook-root"><\/script><script id="storybook-docs"><\/script>',e.showMain(),()=>{}},f={renderToCanvas:m,parameters:{server:{url:p},layout:"fullscreen"}};
|
|
4
4
|
|
|
5
|
-
export {
|
|
5
|
+
export { f as default };
|
|
6
6
|
//# sourceMappingURL=out.js.map
|
|
7
7
|
//# sourceMappingURL=preview.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../shared/storybook-config/preview.ts"],"names":["rebuild","pageUrl","strippedUrl","renderToCanvas","context","element","url","id","htmlNode","html","preview_default"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../shared/storybook-config/preview.ts"],"names":["NodeType","rebuild","pageUrl","strippedUrl","findHtmlNode","node","childNode","renderToCanvas","context","element","url","id","snapshot","htmlNode","html","preview_default"],"mappings":"AAEA,OAAS,YAAAA,EAAU,WAAAC,MAAe,iBAElC,IAAMC,EAAU,IAAI,IAAI,OAAO,SAAS,IAAI,EAC5CA,EAAQ,SAAW,GACnBA,EAAQ,OAAS,GACjB,IAAMC,EAAcD,EAAQ,SAAS,EAAE,QAAQ,MAAO,EAAE,EAOlDE,EAAgBC,GAAiE,CACrF,GAAIA,EAAK,OAASL,EAAS,SAAWK,EAAK,UAAY,OACrD,OAAOA,EAGT,GAAI,eAAgBA,EAClB,OAAOA,EAAK,WAAW,KAAMC,GACpBF,EAAaE,CAAS,CAC9B,CAIL,EAEMC,EAAiD,MAAOC,EAASC,IAAY,CACjF,GAAM,CAAE,IAAAC,EAAK,GAAAC,CAAG,EAAIH,EAAQ,aAAa,WAAW,OAE9CI,EAAY,MADD,MAAM,MAAM,GAAGF,KAAOC,GAAI,GACV,KAAK,EAGhCE,EAAWT,EAAaQ,CAAQ,EAQhCE,EAAQ,MAAMb,EAAQY,EAAU,CAAE,IAAK,QAAS,CAAC,EAGvD,gBAAS,aAAaC,EAAM,SAAS,SAAS,CAAC,CAAC,EAOhD,SAAS,KAAK,WACZ,+EAEFN,EAAQ,SAAS,EACV,IAAM,CAAC,CAChB,EAEOO,EAAQ,CACb,eAAAR,EACA,WAAY,CACV,OAAQ,CAAE,IAAKJ,CAAY,EAC3B,OAAQ,YACV,CACF","sourcesContent":["import type { RenderToCanvas, WebRenderer } from '@storybook/types';\nimport type { serializedNodeWithId } from 'rrweb-snapshot';\nimport { NodeType, rebuild } from 'rrweb-snapshot';\n\nconst pageUrl = new URL(window.location.href);\npageUrl.pathname = '';\npageUrl.search = '';\nconst strippedUrl = pageUrl.toString().replace(/\\/$/, '');\n\nexport interface RRWebFramework extends WebRenderer {\n component: undefined;\n storyResult: Record<string, never>;\n}\n\nconst findHtmlNode = (node: serializedNodeWithId): serializedNodeWithId | undefined => {\n if (node.type === NodeType.Element && node.tagName === 'html') {\n return node;\n }\n\n if ('childNodes' in node) {\n return node.childNodes.find((childNode) => {\n return findHtmlNode(childNode);\n });\n }\n\n return undefined;\n};\n\nconst renderToCanvas: RenderToCanvas<RRWebFramework> = async (context, element) => {\n const { url, id } = context.storyContext.parameters.server;\n const response = await fetch(`${url}/${id}`);\n const snapshot = (await response.json()) as serializedNodeWithId;\n\n // The snapshot is a representation of a complete HTML document\n const htmlNode = findHtmlNode(snapshot);\n\n // If you rebuild the full snapshot with rrweb (the document) it will replace the\n // current document and call `document.open()` in the process, which unbinds all event handlers\n // (and breaks Storybook).\n // However, if you just rebuild the html element part, it will recreate but not attempt to\n // insert it in the DOM.\n // @ts-expect-error rebuild is typed incorreclty, cache and mirror are optional\n const html = (await rebuild(htmlNode, { doc: document })) as HTMLElement;\n\n // Now we insert the rebuilt html element in the DOM\n document.replaceChild(html, document.children[0]);\n\n // Storybook's WebView will throw an error if it cannot find these two ids in the DOM.\n // We never render docs (so the #storybook-docs doesn't matter), and our`renderToCanvas`\n // function is already ignoring the #storybook-root (`element` above), so it doesn't matter where\n // they are or what they contain.\n // We make them a script in the head to ensure they don't impact layout.\n document.head.innerHTML +=\n '<script id=\"storybook-root\"></script><script id=\"storybook-docs\"></script>';\n\n context.showMain();\n return () => {}; // We can't really cleanup\n};\n\nexport default {\n renderToCanvas,\n parameters: {\n server: { url: strippedUrl },\n layout: 'fullscreen',\n },\n};\n"]}
|