A library for embedding Pyret into webpages
npm install pyret-embed- Copy node_modules/pyret-embed/dist/ to where you serve static files
- Note that all the Pyret stuff is set up to correctly work with relative paths
internally. You just need to make sure the paths to pyret.js and
editor.embed.html work from your source.
- From your website:
- ```
See examples/ for more examples!
``
type State = {
definitionsAtLastRun: string;
interactionsSinceLastRun: string[];
editorContents: string;
replContents: string;
messageNumber?: number;
};
type API = {
sendReset: (state: State) => void;
postMessage: (message: any) => void;
getFrame: () => HTMLIFrameElement;
setInteractions: (text: string) => void;
runDefinitions: () => void;
runInteractionResult: () => Promise
onChange: (callback: ((msg: any) => void)) => void;
clearInteractions: () => void;
currentState: () => State;
};
declare function makeEmbed(id: string, container: HTMLElement, src?: string): Promise
To see the examples in this repository:
```
$ git clone ...
$ npm install
$ python3 -m http.server # or your favorite static server
Then open localhost:8000/examples/basic.html in browser.