Skip to content

Commit

Permalink
inject strudel with std
Browse files Browse the repository at this point in the history
  • Loading branch information
TodePond committed Jan 25, 2025
1 parent a52ed26 commit 43ee812
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ fetch('/src/std.js').then(async (response) => {
stdSource = await response.text();
});

export function getStdSource() {
if (!stdSource) throw new Error('stdSource not loaded yet');
return stdSource;
}

// Return the lines of a panel view.
function getDocumentText(view) {
const doc = view.viewState.state.doc;
Expand Down
14 changes: 6 additions & 8 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { applySettingsToNudel, getSettings } from './settings.js';
import { PastaMirror } from './editor.js';
import { clearInlineErrors, displayInlineErrors } from './error.js';
import './style.css';
import { getStdSource } from './export.js';

export const pastamirror = new PastaMirror();
window.editorViews = pastamirror.editorViews;
Expand Down Expand Up @@ -66,17 +67,14 @@ export const Frame = {
};

// hydra
session.on('eval:hydra', (msg) =>
Frame.hydra?.contentWindow.postMessage({
type: 'eval',
msg,
}),
);

session.on('eval:hydra', (msg) => Frame.hydra?.contentWindow.postMessage({ type: 'eval', msg }));
// shader
session.on('eval:shader', (msg) => Frame.shader?.contentWindow.postMessage({ type: 'eval', msg }));
// strudel
session.on('eval:strudel', (msg) => Frame.strudel?.contentWindow.postMessage({ type: 'eval', msg }));
session.on('eval:strudel', (msg) => {
msg.body = msg.body + '\n\n\n' + getStdSource();
return Frame.strudel?.contentWindow.postMessage({ type: 'eval', msg });
});
// kabelsalat
session.on('eval:kabelsalat', (msg) => Frame.kabelsalat?.contentWindow.postMessage({ type: 'eval', msg }));

Expand Down

0 comments on commit 43ee812

Please sign in to comment.