soiz1's picture
Upload 2891 files
6bcb42f verified
raw
history blame contribute delete
809 Bytes
import VM from 'scratch-vm';
import storage from '../lib/storage';
import {MAXIMUM_CLOUD_VARIABLES} from '../lib/tw-cloud-limits';
const SET_VM = 'scratch-gui/vm/SET_VM';
const defaultVM = new VM();
defaultVM.setCompatibilityMode(true);
defaultVM.extensionManager.workerMode = 'iframe';
defaultVM.runtime.cloudOptions.limit = MAXIMUM_CLOUD_VARIABLES;
defaultVM.attachStorage(storage);
const initialState = defaultVM;
const reducer = function (state, action) {
if (typeof state === 'undefined') state = initialState;
switch (action.type) {
case SET_VM:
return action.vm;
default:
return state;
}
};
const setVM = function (vm) {
return {
type: SET_VM,
vm: vm
};
};
export {
reducer as default,
initialState as vmInitialState,
setVM
};