{"version":3,"file":"index.cjs","names":["renderToString","useRef","useState","useMemo","useMergeRefs","useFocusableIframe"],"sources":["../../src/sandbox/index.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport {\n\trenderToString,\n\tuseRef,\n\tuseState,\n\tuseEffect,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useFocusableIframe, useMergeRefs } from '@wordpress/compose';\nimport type { SandBoxProps } from './types';\n\ntype SandBoxContentProps = Omit< SandBoxProps, 'allowSameOrigin' >;\n\n/**\n * Matches CSS viewport-relative length values such as `100vh`, `50.5vw`,\n * and `.5dvh`. Used to strip viewport units from user-supplied HTML inside\n * the sandbox iframe, because those units are relative to the iframe's\n * own size and would create a measurement feedback loop with the\n * resize observer.\n *\n * Exported for tests. NOTE: an identical regex literal is duplicated\n * inside `observeAndResizeJS` below because that function is serialized\n * via `.toString()` and embedded into the iframe's `srcdoc` — it has no\n * access to this module's scope at runtime. If you change one, change\n * the other; the \"is embedded in the sandbox iframe srcdoc\" test\n * guards against drift.\n */\nexport const VIEWPORT_UNIT_VALUE_REGEX =\n\t/^\\d*\\.?\\d+(?:vw|vh|svw|lvw|dvw|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax)$/;\n\nconst observeAndResizeJS = function () {\n\tconst { MutationObserver } = window;\n\n\tif ( ! MutationObserver || ! window.parent ) {\n\t\treturn;\n\t}\n\n\tfunction sendResize() {\n\t\t// This runs in the document <head>, and as a `load`/`resize` listener,\n\t\t// so the body may not exist yet. Bail rather than throw on a null body.\n\t\tif ( ! document.body ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst clientBoundingRect = document.body.getBoundingClientRect();\n\n\t\twindow.parent.postMessage(\n\t\t\t{\n\t\t\t\taction: 'resize',\n\t\t\t\twidth: clientBoundingRect.width,\n\t\t\t\theight: clientBoundingRect.height,\n\t\t\t},\n\t\t\t'*'\n\t\t);\n\t}\n\n\t// Runs the body-dependent setup once the document body is available. Reads\n\t// `document.body` into a local so the null check narrows it for the rest of\n\t// the function: this runs in <head> and via DOMContentLoaded, so the body\n\t// isn't guaranteed to exist yet.\n\tfunction connect() {\n\t\tconst { body } = document;\n\t\tif ( ! body ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst observer = new MutationObserver( sendResize );\n\t\tobserver.observe( body, {\n\t\t\tattributes: true,\n\t\t\tattributeOldValue: false,\n\t\t\tcharacterData: true,\n\t\t\tcharacterDataOldValue: false,\n\t\t\tchildList: true,\n\t\t\tsubtree: true,\n\t\t} );\n\n\t\t// Hack: Remove viewport unit styles, as these are relative\n\t\t// the iframe root and interfere with our mechanism for\n\t\t// determining the unconstrained page bounds.\n\t\tfunction removeViewportStyles( ruleOrNode: ElementCSSInlineStyle ) {\n\t\t\tif ( ruleOrNode.style ) {\n\t\t\t\t(\n\t\t\t\t\t[ 'width', 'height', 'minHeight', 'maxHeight' ] as const\n\t\t\t\t ).forEach( function ( style ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\t/^\\d*\\.?\\d+(?:vw|vh|svw|lvw|dvw|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax)$/.test(\n\t\t\t\t\t\t\truleOrNode.style[ style ]\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\truleOrNode.style[ style ] = '';\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\n\t\tArray.prototype.forEach.call(\n\t\t\tdocument.querySelectorAll( '[style]' ),\n\t\t\tremoveViewportStyles\n\t\t);\n\t\tArray.prototype.forEach.call(\n\t\t\tdocument.styleSheets,\n\t\t\tfunction ( stylesheet ) {\n\t\t\t\tlet rules;\n\t\t\t\ttry {\n\t\t\t\t\trules = stylesheet.cssRules || stylesheet.rules;\n\t\t\t\t} catch {\n\t\t\t\t\t// Reading `cssRules` throws a SecurityError for a\n\t\t\t\t\t// cross-origin stylesheet (e.g. a remote <link> in the\n\t\t\t\t\t// user's HTML). Skip those rather than aborting the setup.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tArray.prototype.forEach.call( rules, removeViewportStyles );\n\t\t\t}\n\t\t);\n\n\t\tbody.style.position = 'absolute';\n\t\tbody.style.width = '100%';\n\t\tbody.setAttribute( 'data-resizable-iframe-connected', '' );\n\n\t\tsendResize();\n\t}\n\n\twindow.addEventListener( 'load', sendResize, true );\n\n\t// Resize events can change the width of elements with 100% width, but we don't\n\t// get an DOM mutations for that, so do the resize when the window is resized, too.\n\twindow.addEventListener( 'resize', sendResize, true );\n\n\t// This script is injected into the document <head> so it parses before the\n\t// (possibly malformed) user content in <body>: an unclosed attribute quote\n\t// in that content can't then swallow this <script> tag and dump its source\n\t// into the preview as visible text. Because <head> runs before <body>\n\t// exists, defer the body-dependent setup until the DOM is ready.\n\tif ( document.body ) {\n\t\tconnect();\n\t} else {\n\t\tdocument.addEventListener( 'DOMContentLoaded', connect );\n\t}\n};\n\n// TODO: These styles shouldn't be coupled with WordPress.\nconst style = `\n\tbody {\n\t\tmargin: 0;\n\t}\n\thtml,\n\tbody,\n\tbody > div {\n\t\twidth: 100%;\n\t}\n\thtml.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio > div,\n\tbody.wp-has-aspect-ratio > div iframe {\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\toverflow: hidden; /* If it has an aspect ratio, it shouldn't scroll. */\n\t}\n\tbody > div > * {\n\t\tmargin-top: 0 !important; /* Has to have !important to override inline styles. */\n\t\tmargin-bottom: 0 !important;\n\t}\n`;\n\n/**\n * Builds the full HTML document string for the sandbox iframe content. Shared\n * by both the isolated (`srcdoc`) and same-origin (`contentDocument.write`)\n * sandboxes so the two paths always emit the same markup — notably keeping the\n * resize script in `<head>`, ahead of the user content, on both. A single\n * builder means the write path cannot drift back to putting the script in\n * `<body>` while the `srcdoc` path keeps it in `<head>`.\n *\n * `lang` is passed in rather than read here because the two callers source it\n * from different documents: the isolated sandbox uses the module's `document`,\n * while the same-origin sandbox uses the iframe's `ownerDocument`. They are\n * normally the same document, but keeping the argument preserves each path's\n * exact prior behavior.\n *\n * Exported for tests.\n *\n * @param props\n * @param props.html    User-supplied HTML for the iframe body.\n * @param props.title   Document title.\n * @param props.type    Optional class name for the `<html>`/`<body>` elements.\n * @param props.styles  CSS rule strings, injected as `<style>` tags in the head.\n * @param props.scripts External script URLs, injected as `<script src>` in the\n *                      body (embeds expect their scripts there).\n * @param props.lang    Language for the `<html lang>` attribute.\n * @return The full `<!DOCTYPE html>…` document string.\n */\nexport function buildSandBoxDocument( {\n\thtml,\n\ttitle,\n\ttype,\n\tstyles,\n\tscripts,\n\tlang,\n}: {\n\thtml: string;\n\ttitle: string;\n\ttype?: string;\n\tstyles: string[];\n\tscripts: string[];\n\tlang: string;\n} ): string {\n\tconst htmlDoc = (\n\t\t<html lang={ lang } className={ type }>\n\t\t\t<head>\n\t\t\t\t<title>{ title }</title>\n\t\t\t\t<style dangerouslySetInnerHTML={ { __html: style } } />\n\t\t\t\t{ styles.map( ( rules, i ) => (\n\t\t\t\t\t<style\n\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\tdangerouslySetInnerHTML={ { __html: rules } }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t\t<script\n\t\t\t\t\ttype=\"text/javascript\"\n\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t__html: `(${ observeAndResizeJS.toString() })();`,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</head>\n\t\t\t<body\n\t\t\t\tdata-resizable-iframe-connected=\"data-resizable-iframe-connected\"\n\t\t\t\tclassName={ type }\n\t\t\t>\n\t\t\t\t<div dangerouslySetInnerHTML={ { __html: html } } />\n\t\t\t\t{ scripts.map( ( src ) => (\n\t\t\t\t\t<script key={ src } src={ src } />\n\t\t\t\t) ) }\n\t\t\t</body>\n\t\t</html>\n\t);\n\n\treturn '<!DOCTYPE html>' + renderToString( htmlDoc );\n}\n\n/**\n * Isolated sandbox that uses the `srcdoc` attribute to render content\n * without `allow-same-origin`. This is the default for user-controlled\n * content (e.g., the HTML block) where same-origin access would be a\n * security risk.\n *\n * Because `srcdoc` is a declarative attribute, the browser automatically\n * re-renders the content when the iframe is moved in the DOM (e.g.,\n * block reordering), so no `load` event listener is needed.\n * The `message` listener is re-synced on every `load` so\n * it follows the iframe if it's reparented into a different document.\n */\nfunction IsolatedSandBox( {\n\thtml = '',\n\ttitle = '',\n\ttype,\n\tstyles = [],\n\tscripts = [],\n\tonFocus,\n\ttabIndex,\n\tallowPopups = false,\n\tallowForms = false,\n}: SandBoxContentProps ) {\n\tconst ref = useRef< HTMLIFrameElement >( null );\n\tconst [ width, setWidth ] = useState( 0 );\n\tconst [ height, setHeight ] = useState( 0 );\n\n\tconst sandbox = clsx( 'allow-scripts', 'allow-presentation', {\n\t\t'allow-popups': allowPopups,\n\t\t'allow-forms': allowForms,\n\t} );\n\n\tconst srcDoc = useMemo(\n\t\t() =>\n\t\t\tbuildSandBoxDocument( {\n\t\t\t\thtml,\n\t\t\t\ttitle,\n\t\t\t\ttype,\n\t\t\t\tstyles,\n\t\t\t\tscripts,\n\t\t\t\t// Read inside the memo: the `no-dom-globals-in-react-fc` lint\n\t\t\t\t// rule forbids DOM globals in the render body. `lang` rarely\n\t\t\t\t// changes after load, so leaving it out of the deps is fine.\n\t\t\t\tlang: document.documentElement.lang,\n\t\t\t} ),\n\t\t[ html, title, type, styles, scripts ]\n\t);\n\n\tuseEffect( () => {\n\t\tconst iframe = ref.current;\n\t\tif ( ! iframe ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction checkMessageForResize( event: MessageEvent ) {\n\t\t\t// Verify that the mounted element is the source of the message.\n\t\t\t// iframe.contentWindow is accessible cross-origin as a\n\t\t\t// WindowProxy reference, so this check still works without\n\t\t\t// allow-same-origin.\n\t\t\tif ( ! iframe || iframe.contentWindow !== event.source ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Attempt to parse the message data as JSON if passed as string.\n\t\t\tlet data = event.data || {};\n\n\t\t\tif ( 'string' === typeof data ) {\n\t\t\t\ttry {\n\t\t\t\t\tdata = JSON.parse( data );\n\t\t\t\t} catch {}\n\t\t\t}\n\n\t\t\t// Update the state only if the message is formatted as we expect,\n\t\t\t// i.e. as an object with a 'resize' action.\n\t\t\tif ( 'resize' !== data.action ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetWidth( data.width );\n\t\t\tsetHeight( data.height );\n\t\t}\n\n\t\tlet currentView: Window | null = null;\n\t\tfunction syncListener() {\n\t\t\tconst view = iframe?.ownerDocument?.defaultView ?? null;\n\t\t\tif ( view === currentView ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcurrentView?.removeEventListener(\n\t\t\t\t'message',\n\t\t\t\tcheckMessageForResize\n\t\t\t);\n\n\t\t\tcurrentView = view;\n\t\t\tcurrentView?.addEventListener( 'message', checkMessageForResize );\n\t\t}\n\n\t\tsyncListener();\n\t\tiframe.addEventListener( 'load', syncListener );\n\n\t\treturn () => {\n\t\t\tiframe.removeEventListener( 'load', syncListener );\n\t\t\tcurrentView?.removeEventListener(\n\t\t\t\t'message',\n\t\t\t\tcheckMessageForResize\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<iframe\n\t\t\tref={ useMergeRefs( [ ref, useFocusableIframe() ] ) }\n\t\t\ttitle={ title }\n\t\t\ttabIndex={ tabIndex }\n\t\t\tclassName=\"components-sandbox\"\n\t\t\tsandbox={ sandbox }\n\t\t\tsrcDoc={ srcDoc }\n\t\t\tonFocus={ onFocus }\n\t\t\twidth={ Math.ceil( width ) }\n\t\t\theight={ Math.ceil( height ) }\n\t\t/>\n\t);\n}\n\n/**\n * Same-origin sandbox that writes to `contentDocument` directly. This\n * preserves the parent page's URL as the iframe's document URL, which\n * provides a valid Referer header for nested iframes (required by\n * providers like YouTube).\n *\n * Only used when `allowSameOrigin` is true — i.e., for server-fetched\n * oEmbed previews that are not directly user-controlled.\n *\n * This implementation is intentionally kept close to the original\n * pre-refactor code to preserve past bugfixes:\n * - load listener for iframe re-initialization after DOM moves (#21916)\n * - forceRerender guard to avoid unnecessary full rewrites (#20176)\n */\nfunction SameOriginSandBox( {\n\thtml = '',\n\ttitle = '',\n\ttype,\n\tstyles = [],\n\tscripts = [],\n\tonFocus,\n\ttabIndex,\n\tallowPopups = false,\n\tallowForms = false,\n}: SandBoxContentProps ) {\n\tconst ref = useRef< HTMLIFrameElement >( null );\n\tconst [ width, setWidth ] = useState( 0 );\n\tconst [ height, setHeight ] = useState( 0 );\n\n\tconst sandbox = clsx(\n\t\t'allow-scripts',\n\t\t'allow-same-origin',\n\t\t'allow-presentation',\n\t\t{\n\t\t\t'allow-popups': allowPopups,\n\t\t\t'allow-forms': allowForms,\n\t\t}\n\t);\n\n\tfunction isFrameAccessible() {\n\t\ttry {\n\t\t\treturn !! ref.current?.contentDocument?.body;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tfunction trySandBox( forceRerender = false ) {\n\t\tif ( ! isFrameAccessible() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { contentDocument, ownerDocument } =\n\t\t\tref.current as HTMLIFrameElement & {\n\t\t\t\tcontentDocument: Document;\n\t\t\t};\n\n\t\tif (\n\t\t\t! forceRerender &&\n\t\t\tnull !==\n\t\t\t\tcontentDocument?.body.getAttribute(\n\t\t\t\t\t'data-resizable-iframe-connected'\n\t\t\t\t)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Put the html snippet into a html document, and then write it to the\n\t\t// iframe's document. The external `scripts` still go into the body to\n\t\t// support embedded content such as Instagram that expects them there;\n\t\t// only the resize helper lives in the head.\n\t\t//\n\t\t// Writing the document like this makes it act in the same way as if it\n\t\t// was loaded over the network, so DOM creation and mutation, script\n\t\t// execution, etc. all work as expected.\n\t\tcontentDocument.open();\n\t\t// Nested iframes should send this page's URL as their `Referer`, which\n\t\t// YouTube requires. Safari sends none after `open()` until the URL is\n\t\t// set again with `replaceState()`. Firefox throws here but already\n\t\t// sends the referrer. See https://bugs.webkit.org/show_bug.cgi?id=169846.\n\t\ttry {\n\t\t\tcontentDocument.defaultView?.history.replaceState(\n\t\t\t\tnull,\n\t\t\t\t'',\n\t\t\t\twindow.location.href\n\t\t\t);\n\t\t} catch {}\n\t\tcontentDocument.write(\n\t\t\tbuildSandBoxDocument( {\n\t\t\t\thtml,\n\t\t\t\ttitle,\n\t\t\t\ttype,\n\t\t\t\tstyles,\n\t\t\t\tscripts,\n\t\t\t\tlang: ownerDocument.documentElement.lang,\n\t\t\t} )\n\t\t);\n\t\tcontentDocument.close();\n\t}\n\n\tuseEffect( () => {\n\t\ttrySandBox();\n\n\t\tfunction tryNoForceSandBox() {\n\t\t\ttrySandBox( false );\n\t\t}\n\n\t\tfunction checkMessageForResize( event: MessageEvent ) {\n\t\t\tconst iframe = ref.current;\n\n\t\t\t// Verify that the mounted element is the source of the message.\n\t\t\tif ( ! iframe || iframe.contentWindow !== event.source ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Attempt to parse the message data as JSON if passed as string.\n\t\t\tlet data = event.data || {};\n\n\t\t\tif ( 'string' === typeof data ) {\n\t\t\t\ttry {\n\t\t\t\t\tdata = JSON.parse( data );\n\t\t\t\t} catch {}\n\t\t\t}\n\n\t\t\t// Update the state only if the message is formatted as we expect,\n\t\t\t// i.e. as an object with a 'resize' action.\n\t\t\tif ( 'resize' !== data.action ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetWidth( data.width );\n\t\t\tsetHeight( data.height );\n\t\t}\n\n\t\tconst iframe = ref.current;\n\t\tconst defaultView = iframe?.ownerDocument?.defaultView;\n\n\t\t// This used to be registered using <iframe onLoad={} />, but it made the iframe blank\n\t\t// after reordering the containing block. See these two issues for more details:\n\t\t// https://github.com/WordPress/gutenberg/issues/6146\n\t\t// https://github.com/facebook/react/issues/18752\n\t\tiframe?.addEventListener( 'load', tryNoForceSandBox, false );\n\t\tdefaultView?.addEventListener( 'message', checkMessageForResize );\n\n\t\treturn () => {\n\t\t\tiframe?.removeEventListener( 'load', tryNoForceSandBox, false );\n\t\t\tdefaultView?.removeEventListener(\n\t\t\t\t'message',\n\t\t\t\tcheckMessageForResize\n\t\t\t);\n\t\t};\n\t\t// Passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t}, [] );\n\n\tuseEffect( () => {\n\t\ttrySandBox();\n\t\t// Passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t}, [ title, styles, scripts ] );\n\n\tuseEffect( () => {\n\t\ttrySandBox( true );\n\t\t// Passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t}, [ html, type ] );\n\n\treturn (\n\t\t<iframe\n\t\t\tref={ useMergeRefs( [ ref, useFocusableIframe() ] ) }\n\t\t\ttitle={ title }\n\t\t\ttabIndex={ tabIndex }\n\t\t\tclassName=\"components-sandbox\"\n\t\t\tsandbox={ sandbox }\n\t\t\tonFocus={ onFocus }\n\t\t\twidth={ Math.ceil( width ) }\n\t\t\theight={ Math.ceil( height ) }\n\t\t/>\n\t);\n}\n\n/**\n * This component provides an isolated environment for arbitrary HTML via iframes.\n *\n * ```jsx\n * import { SandBox } from '@wordpress/components';\n *\n * const MySandBox = () => (\n * \t<SandBox html=\"<p>Content</p>\" title=\"SandBox\" type=\"embed\" />\n * );\n * ```\n */\nfunction SandBox( { allowSameOrigin = false, ...contentProps }: SandBoxProps ) {\n\tif ( allowSameOrigin ) {\n\t\treturn <SameOriginSandBox { ...contentProps } />;\n\t}\n\treturn <IsolatedSandBox { ...contentProps } />;\n}\n\nexport default SandBox;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;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