Uses npm for website, hosts playground runner on https://isolated-playground.github.io for better isolation. (#5034)

This commit is contained in:
Henning Dieterichs 2025-10-09 19:05:34 +02:00 committed by GitHub
parent e2764eac56
commit a30f4f9920
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 6523 additions and 3629 deletions

View file

@ -9,6 +9,30 @@ import {
} from "../../../shared";
import { Button } from "react-bootstrap";
const jsSrc = `
try {
const baseUrl = ${JSON.stringify(document.baseURI.toString())};
const base = document.createElement('base');
base.href = baseUrl;
document.head.appendChild(base);
const scriptRuntime = document.createElement('script');
scriptRuntime.src = './runtime.js';
document.head.appendChild(scriptRuntime);
const script = document.createElement('script');
script.src = './playgroundRunner.js';
document.head.appendChild(script);
const link = document.createElement('link');
link.href = './playgroundRunner.css';
link.rel = 'stylesheet';
document.head.appendChild(link);
} catch (e) {
console.error(e);
}
`;
@observer
export class Preview extends React.Component<{
model: PlaygroundModel;
@ -54,7 +78,9 @@ export class Preview extends React.Component<{
sandbox="allow-scripts allow-modals"
frameBorder={0}
ref={this.handleIframe}
src="./playgroundRunner.html"
src={`https://isolated-playground.github.io/?jsSrcBase64=${btoa(
jsSrc
)}`}
/>
</div>
);