import Vue from 'vue';
import Vuex from 'vuex';
import undoRedo from '../plugins/undo-redo';
import shareMutations from '../plugins/share-mutations';
import shareDevTools from '../plugins/share-devtools';
import page from './modules/page';
import definition from './modules/definition';
import Config from 'classes/Config';

/* global process */

Vue.use(Vuex);

let store = new Vuex.Store({

	state: {
		over: {
			x: 0,
			y: 0
		},
		preview: {
			visible: false,
			url: ''
		},
		wrapperStyles: {},
		showIframeOverlay: false
	},

	getters: {},

	mutations: {

		updateOver(state, position) {
			state.over = position;
		},

		changePreview(state, value) {
			state.preview = value;
		},

		updateWrapperStyle(state, { prop, value }) {
			state.wrapperStyles = { ...state.wrapperStyles, [prop]: value };
		},

		showIframeOverlay(state, yes) {
			state.showIframeOverlay = yes;
		}
	},

	actions: {},

	modules: {
		page,
		definition
	},

	plugins: [
		shareMutations,
		undoRedo,
		...(Config.get('debug', false) ? [shareDevTools] : [])
	],

	strict: process.env.NODE_ENV !== 'production'

});

export default store;

import Vue from 'vue';
import Vuex from 'vuex';
import undoRedo from '../plugins/undo-redo';

import page from './modules/page';
import definition from './modules/definition';

/* global window */

Vue.use(Vuex);

const store = (
	window.self === window.top ? {

		state: {
			over: {
				x: 0,
				y: 0
			},
			preview: {
				visible: false,
				url: ''
			},
			wrapperStyles: {},
			showIframeOverlay: false
		},

		getters: {},

		mutations: {

			updateOver(state, position) {
				state.over = position;
			},

			changePreview(state, value) {
				state.preview = value;
			},

			updateWrapperStyle(state, { prop, value }) {
				state.wrapperStyles = { ...state.wrapperStyles, [prop]: value };
			},

			showIframeOverlay(state, yes) {
				state.showIframeOverlay = yes;
			}
		},

		actions: {},

		modules: {
			page,
			definition
		},

		plugins: [undoRedo]

	}

	:

	window.top.store
);

window.store = store;

export default new Vuex.Store(store);

--- 
+++ 
@@ -1,67 +1,67 @@
 import Vue from 'vue';
 import Vuex from 'vuex';
 import undoRedo from '../plugins/undo-redo';
-import shareMutations from '../plugins/share-mutations';
-import shareDevTools from '../plugins/share-devtools';
+
 import page from './modules/page';
 import definition from './modules/definition';
-import Config from 'classes/Config';
 
-/* global process */
+/* global window */
 
 Vue.use(Vuex);
 
-let store = new Vuex.Store({
+const store = (
+	window.self === window.top ? {
 
-	state: {
-		over: {
-			x: 0,
-			y: 0
-		},
-		preview: {
-			visible: false,
-			url: ''
-		},
-		wrapperStyles: {},
-		showIframeOverlay: false
-	},
-
-	getters: {},
-
-	mutations: {
-
-		updateOver(state, position) {
-			state.over = position;
+		state: {
+			over: {
+				x: 0,
+				y: 0
+			},
+			preview: {
+				visible: false,
+				url: ''
+			},
+			wrapperStyles: {},
+			showIframeOverlay: false
 		},
 
-		changePreview(state, value) {
-			state.preview = value;
+		getters: {},
+
+		mutations: {
+
+			updateOver(state, position) {
+				state.over = position;
+			},
+
+			changePreview(state, value) {
+				state.preview = value;
+			},
+
+			updateWrapperStyle(state, { prop, value }) {
+				state.wrapperStyles = { ...state.wrapperStyles, [prop]: value };
+			},
+
+			showIframeOverlay(state, yes) {
+				state.showIframeOverlay = yes;
+			}
 		},
 
-		updateWrapperStyle(state, { prop, value }) {
-			state.wrapperStyles = { ...state.wrapperStyles, [prop]: value };
+		actions: {},
+
+		modules: {
+			page,
+			definition
 		},
 
-		showIframeOverlay(state, yes) {
-			state.showIframeOverlay = yes;
-		}
-	},
+		plugins: [undoRedo]
 
-	actions: {},
+	}
 
-	modules: {
-		page,
-		definition
-	},
+	:
 
-	plugins: [
-		shareMutations,
-		undoRedo,
-		...(Config.get('debug', false) ? [shareDevTools] : [])
-	],
+	window.top.store
+);
 
-	strict: process.env.NODE_ENV !== 'production'
+window.store = store;
 
-});
-
-export default store;
+export default new Vuex.Store(store);
Update store to use new Vuex plugins.

Overall this feels like a much cleaner approach.
