Download web/src/apps/code/frame-bootstrap.html from fsanyoto/loopable: direct link, hf CLI and curl.
- Browser
- Download file 2.43 kB
-
https://huggingface.co/spaces/fsanyoto/loopable/resolve/3dbbea877ddd4ebfd5e381604dffdf0ef3d80c83/web/src/apps/code/frame-bootstrap.html
- Command line
-
hf download hf://spaces/fsanyoto/loopable@3dbbea877ddd4ebfd5e381604dffdf0ef3d80c83/web/src/apps/code/frame-bootstrap.html
-
curl -L -o frame-bootstrap.html https://huggingface.co/spaces/fsanyoto/loopable/resolve/3dbbea877ddd4ebfd5e381604dffdf0ef3d80c83/web/src/apps/code/frame-bootstrap.html
2.43 kB
| <meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; connect-src 'none'; img-src 'none'; font-src data:; media-src 'none'; object-src 'none'; frame-src 'none'; worker-src 'none'; base-uri 'none'; form-action 'none'"><meta charset="utf-8"><style>html,body{margin:0;height:100%;overflow:hidden}iframe{display:block;width:100%;height:100%;border:0}</style><script> | |
| (() => { | |
| "use strict"; | |
| if (parent === window) return; | |
| let allowed = false; | |
| let mounted = false; | |
| let peer; | |
| let observer; | |
| const send = phase => parent.postMessage({ type: "code-app-bootstrap", phase }, "*"); | |
| const cleanup = () => { observer?.disconnect(); peer?.close(); clearTimeout(timer); }; | |
| const timer = setTimeout(() => { cleanup(); send("refused"); }, 1500); | |
| addEventListener("pagehide", cleanup, { once: true }); | |
| addEventListener("message", event => { | |
| if (event.source !== parent) return; | |
| const request = event.data; | |
| if (!allowed || mounted || request?.type !== "code-app-bootstrap" || request.phase !== "mount" | |
| || typeof request.document !== "string" || typeof request.name !== "string") return; | |
| mounted = true; | |
| const child = document.createElement("iframe"); | |
| child.title = request.name; | |
| child.sandbox = "allow-scripts"; | |
| child.referrerPolicy = "no-referrer"; | |
| child.srcdoc = request.document; | |
| document.body.append(child); | |
| send("mounted"); | |
| }); | |
| try { | |
| // Only a native enforcing report from this response permits receiving App text. | |
| observer = new ReportingObserver(reports => { | |
| if (!reports.some(report => report.type === "connection-allowlist" | |
| && report.body.disposition === "enforce" && report.body.connection === "webrtc" | |
| && report.body.url === location.href && Array.isArray(report.body.allowlist) | |
| && report.body.allowlist.length === 0)) return; | |
| allowed = true; | |
| cleanup(); | |
| send("ready"); | |
| }, { types: ["connection-allowlist"] }); | |
| observer.observe(); | |
| // No ICE servers or App data enter this capability probe. | |
| peer = new RTCPeerConnection({ iceServers: [] }); | |
| peer.createDataChannel("boundary"); | |
| peer.createOffer().then(offer => peer.setLocalDescription(offer)).then(() => peer.close()).catch(() => { | |
| cleanup(); send("refused"); | |
| }); | |
| } catch { | |
| cleanup(); send("refused"); | |
| } | |
| })(); | |
| </script> | |