fixed build window issue:

This commit is contained in:
Jade (Rose) Rowland 2024-06-14 15:28:24 -04:00
parent 2a2ddf205a
commit 1d95da7a3a
3 changed files with 8 additions and 4 deletions

View File

@ -39,6 +39,8 @@ function safeEval(str, options = {}) {
export const evaluate = async (code, transpiler, transpilerOptions) => {
let meta = {};
//post to iframe parent (like Udels) if it exists...
window.parent?.postMessage(code);
if (transpiler) {
// transform syntactically correct js code to semantically usable code
const transpiled = transpiler(code, transpilerOptions);

View File

@ -2,9 +2,7 @@ import { useRef } from 'react';
export function UdelFrame({ onEvaluate, hash, instance }) {
const ref = useRef();
console.info('frame')
window.addEventListener('message', (message) => {
console.info(message, 'message')
const childWindow = ref?.current?.contentWindow;
if (message == null || message.source !== childWindow) {
return; // Skip message in this event listener

View File

@ -29,9 +29,13 @@ export const defaultSettings = {
userPatterns: '{}',
audioDeviceName: defaultAudioDeviceName,
};
const search = new URLSearchParams(window.location.search);
let search = null;
if (typeof window !== 'undefined') {
search = new URLSearchParams(window.location.search);
}
// if running multiple instance in one window, it will use the settings for that instance. else default to normal
const instance = parseInt(search.get('instance') ?? '0');
const instance = parseInt(search?.get('instance') ?? '0');
const settings_key = `strudel-settings${instance > 0 ? instance : ''}`;
export const settingsMap = persistentMap(settings_key, defaultSettings);