@@ -4,6 +4,7 @@ import classNames from 'classnames';
44import { SourceDocumentation , getNames , runInContext , type Context } from 'js-slang' ;
55// Importing this straight from js-slang doesn't work for whatever reason
66import createContext from 'js-slang/dist/createContext' ;
7+ import { setModulesStaticURL } from 'js-slang/dist/modules/loader' ;
78import { Chapter , Variant } from 'js-slang/dist/types' ;
89import { stringify } from 'js-slang/dist/utils/stringify' ;
910import React from 'react' ;
@@ -50,7 +51,16 @@ const createContextHelper = (onConsoleLog: (arg: string) => void) => {
5051const Playground : React . FC = ( ) => {
5152 const consoleLogs = React . useRef < string [ ] > ( [ ] ) ;
5253 const [ moduleBackend , setModuleBackend ] = React . useState < string | null > ( null ) ;
53- const [ useCompiledTabs , setUseCompiledTabs ] = React . useState ( false ) ;
54+
55+ React . useEffect ( ( ) => {
56+ const savedBackend = localStorage . getItem ( 'backend' ) ;
57+ if ( savedBackend != undefined ) {
58+ setModuleBackend ( savedBackend ) ;
59+ setModulesStaticURL ( savedBackend ) ;
60+ }
61+ } , [ ] ) ;
62+
63+ const [ useCompiledTabs , setUseCompiledTabs ] = React . useState ( ! ! localStorage . getItem ( 'compiledTabs' ) ) ;
5464
5565 const [ dynamicTabs , setDynamicTabs ] = React . useState < SideContentTab [ ] > ( [ ] ) ;
5666 const [ selectedTabId , setSelectedTab ] = React . useState ( testTabContent . id ) ;
@@ -184,9 +194,16 @@ const Playground: React.FC = () => {
184194 placement = "right"
185195 content = { < SettingsPopup
186196 backend = { moduleBackend ?? '' }
187- onBackendChange = { setModuleBackend }
197+ onBackendChange = { value => {
198+ setModuleBackend ( value ) ;
199+ setModulesStaticURL ( value ) ;
200+ localStorage . setItem ( 'backend' , value ) ;
201+ } }
188202 useCompiledForTabs = { useCompiledTabs }
189- onUseCompiledChange = { setUseCompiledTabs }
203+ onUseCompiledChange = { value => {
204+ setUseCompiledTabs ( value ) ;
205+ localStorage . setItem ( 'compiledTabs' , value ? 'true' : '' ) ;
206+ } }
190207 /> }
191208 renderTarget = { ( { isOpen : _isOpen , ...targetProps } ) => {
192209 return (
0 commit comments