aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-10-08 15:19:25 +0900
committerGitHub <noreply@github.com>2017-10-08 15:19:25 +0900
commit0183161145d36cbafb7dbd86ca3a1aac6faca43f (patch)
treeaed757bfb5f8789156439d1e1fdff4e221376aaa /src
parent0f54a203dba38acdd080a928cee95f875fe84706 (diff)
parent57f798044d32ba7f9dc10a34ac31ad5dbdbf56ae (diff)
Merge pull request #22 from ueokande/separate-domains
Refactor: Separate domains
Diffstat (limited to 'src')
-rw-r--r--src/background/actions/index.js0
-rw-r--r--src/background/actions/operation.js (renamed from src/actions/operation.js)45
-rw-r--r--src/background/actions/tab.js (renamed from src/actions/tab.js)0
-rw-r--r--src/background/components/background.js (renamed from src/components/background.js)14
-rw-r--r--src/background/index.js10
-rw-r--r--src/console/actions/console.js (renamed from src/actions/console.js)2
-rw-r--r--src/console/actions/index.js9
-rw-r--r--src/console/components/completion.js (renamed from src/components/completion.js)2
-rw-r--r--src/console/components/console.js (renamed from src/components/console.js)6
-rw-r--r--src/console/index.html (renamed from src/pages/console.html)0
-rw-r--r--src/console/index.js (renamed from src/pages/console.js)14
-rw-r--r--src/console/reducers/index.js (renamed from src/reducers/console.js)2
-rw-r--r--src/console/site.scss (renamed from src/pages/console.scss)0
-rw-r--r--src/content/actions/follow.js (renamed from src/actions/follow.js)2
-rw-r--r--src/content/actions/index.js (renamed from src/actions/index.js)8
-rw-r--r--src/content/actions/input.js (renamed from src/actions/input.js)2
-rw-r--r--src/content/actions/operation.js43
-rw-r--r--src/content/components/content-input.js (renamed from src/components/content-input.js)0
-rw-r--r--src/content/components/follow.js (renamed from src/components/follow.js)4
-rw-r--r--src/content/components/keymapper.js (renamed from src/components/keymapper.js)4
-rw-r--r--src/content/index.js14
-rw-r--r--src/content/reducers/follow.js (renamed from src/reducers/follow.js)2
-rw-r--r--src/content/reducers/index.js (renamed from src/reducers/index.js)10
-rw-r--r--src/content/reducers/input.js (renamed from src/reducers/input.js)2
-rw-r--r--src/settings/actions/index.js4
-rw-r--r--src/settings/actions/setting.js (renamed from src/actions/setting.js)4
-rw-r--r--src/settings/components/setting.js (renamed from src/components/setting.js)2
-rw-r--r--src/settings/index.html (renamed from src/pages/settings.html)0
-rw-r--r--src/settings/index.js (renamed from src/pages/settings.js)8
-rw-r--r--src/settings/reducers/setting.js (renamed from src/reducers/setting.js)2
-rw-r--r--src/settings/site.scss (renamed from src/pages/settings.scss)0
-rw-r--r--src/shared/messages.js (renamed from src/content/messages.js)0
-rw-r--r--src/shared/store/index.js (renamed from src/store/index.js)0
33 files changed, 111 insertions, 104 deletions
diff --git a/src/background/actions/index.js b/src/background/actions/index.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/background/actions/index.js
diff --git a/src/actions/operation.js b/src/background/actions/operation.js
index 0bb8310..d736c09 100644
--- a/src/actions/operation.js
+++ b/src/background/actions/operation.js
@@ -1,10 +1,7 @@
import operations from 'shared/operations';
-import messages from 'content/messages';
+import messages from 'shared/messages';
import * as tabs from 'background/tabs';
import * as zooms from 'background/zooms';
-import * as scrolls from 'content/scrolls';
-import * as navigates from 'content/navigates';
-import * as followActions from 'actions/follow';
const sendConsoleShowCommand = (tab, command) => {
return browser.tabs.sendMessage(tab.id, {
@@ -13,43 +10,7 @@ const sendConsoleShowCommand = (tab, command) => {
});
};
-const exec = (operation) => {
- switch (operation.type) {
- case operations.SCROLL_LINES:
- return scrolls.scrollLines(window, operation.count);
- case operations.SCROLL_PAGES:
- return scrolls.scrollPages(window, operation.count);
- case operations.SCROLL_TOP:
- return scrolls.scrollTop(window);
- case operations.SCROLL_BOTTOM:
- return scrolls.scrollBottom(window);
- case operations.SCROLL_HOME:
- return scrolls.scrollLeft(window);
- case operations.SCROLL_END:
- return scrolls.scrollRight(window);
- case operations.FOLLOW_START:
- return followActions.enable(false);
- case operations.NAVIGATE_HISTORY_PREV:
- return navigates.historyPrev(window);
- case operations.NAVIGATE_HISTORY_NEXT:
- return navigates.historyNext(window);
- case operations.NAVIGATE_LINK_PREV:
- return navigates.linkPrev(window);
- case operations.NAVIGATE_LINK_NEXT:
- return navigates.linkNext(window);
- case operations.NAVIGATE_PARENT:
- return navigates.parent(window);
- case operations.NAVIGATE_ROOT:
- return navigates.root(window);
- default:
- browser.runtime.sendMessage({
- type: messages.BACKGROUND_OPERATION,
- operation,
- });
- }
-};
-
-const execBackground = (operation, tab) => {
+const exec = (operation, tab) => {
switch (operation.type) {
case operations.TAB_CLOSE:
return tabs.closeTab(tab.id);
@@ -88,4 +49,4 @@ const execBackground = (operation, tab) => {
}
};
-export { exec, execBackground };
+export { exec };
diff --git a/src/actions/tab.js b/src/background/actions/tab.js
index e512b6f..e512b6f 100644
--- a/src/actions/tab.js
+++ b/src/background/actions/tab.js
diff --git a/src/components/background.js b/src/background/components/background.js
index 4961d85..bfe1b3f 100644
--- a/src/components/background.js
+++ b/src/background/components/background.js
@@ -1,7 +1,7 @@
-import messages from 'content/messages';
-import * as operationActions from 'actions/operation';
-import * as settingsActions from 'actions/setting';
-import * as tabActions from 'actions/tab';
+import messages from 'shared/messages';
+import * as operationActions from 'background/actions/operation';
+import * as settingsActions from 'settings/actions/setting';
+import * as tabActions from 'background/actions/tab';
import * as commands from 'shared/commands';
export default class BackgroundComponent {
@@ -23,7 +23,7 @@ export default class BackgroundComponent {
update() {
let state = this.store.getState();
- this.updateSettings(state.setting);
+ this.updateSettings(state);
}
updateSettings(setting) {
@@ -37,7 +37,7 @@ export default class BackgroundComponent {
switch (message.type) {
case messages.BACKGROUND_OPERATION:
return this.store.dispatch(
- operationActions.execBackground(message.operation, sender.tab),
+ operationActions.exec(message.operation, sender.tab),
sender);
case messages.OPEN_URL:
if (message.newTab) {
@@ -58,7 +58,7 @@ export default class BackgroundComponent {
});
});
case messages.SETTINGS_QUERY:
- return Promise.resolve(this.store.getState().setting.settings);
+ return Promise.resolve(this.store.getState().settings);
case messages.CONSOLE_QUERY_COMPLETIONS:
return commands.complete(message.text, this.settings);
case messages.SETTINGS_RELOAD:
diff --git a/src/background/index.js b/src/background/index.js
index dbc10fb..6ba37eb 100644
--- a/src/background/index.js
+++ b/src/background/index.js
@@ -1,8 +1,8 @@
-import * as settingsActions from 'actions/setting';
-import messages from 'content/messages';
-import BackgroundComponent from 'components/background';
-import reducers from 'reducers';
-import { createStore } from 'store';
+import * as settingsActions from 'settings/actions/setting';
+import messages from 'shared/messages';
+import BackgroundComponent from 'background/components/background';
+import reducers from 'settings/reducers/setting';
+import { createStore } from 'shared/store';
const store = createStore(reducers, (e, sender) => {
console.error('Vim-Vixen:', e);
diff --git a/src/actions/console.js b/src/console/actions/console.js
index 4183489..01d9a9b 100644
--- a/src/actions/console.js
+++ b/src/console/actions/console.js
@@ -1,4 +1,4 @@
-import actions from 'actions';
+import actions from 'console/actions';
const showCommand = (text) => {
return {
diff --git a/src/console/actions/index.js b/src/console/actions/index.js
new file mode 100644
index 0000000..a5d03bc
--- /dev/null
+++ b/src/console/actions/index.js
@@ -0,0 +1,9 @@
+export default {
+ // console commands
+ CONSOLE_SHOW_COMMAND: 'console.show.command',
+ CONSOLE_SET_COMPLETIONS: 'console.set.completions',
+ CONSOLE_SHOW_ERROR: 'console.show.error',
+ CONSOLE_HIDE: 'console.hide',
+ CONSOLE_COMPLETION_NEXT: 'console.completion.next',
+ CONSOLE_COMPLETION_PREV: 'console.completion.prev',
+};
diff --git a/src/components/completion.js b/src/console/components/completion.js
index f527a84..5033b5c 100644
--- a/src/components/completion.js
+++ b/src/console/components/completion.js
@@ -6,7 +6,7 @@ export default class Completion {
}
update() {
- let state = this.store.getState().console;
+ let state = this.store.getState();
if (JSON.stringify(this.prevState) === JSON.stringify(state)) {
return;
}
diff --git a/src/components/console.js b/src/console/components/console.js
index 12341c1..9023d91 100644
--- a/src/components/console.js
+++ b/src/console/components/console.js
@@ -1,5 +1,5 @@
-import messages from 'content/messages';
-import * as consoleActions from 'actions/console';
+import messages from 'shared/messages';
+import * as consoleActions from 'console/actions/console';
export default class ConsoleComponent {
constructor(wrapper, store) {
@@ -71,7 +71,7 @@ export default class ConsoleComponent {
}
update() {
- let state = this.store.getState().console;
+ let state = this.store.getState();
if (!this.prevState.commandShown && state.commandShown) {
this.showCommand(state.commandText);
} else if (!state.commandShown) {
diff --git a/src/pages/console.html b/src/console/index.html
index 4222f12..4222f12 100644
--- a/src/pages/console.html
+++ b/src/console/index.html
diff --git a/src/pages/console.js b/src/console/index.js
index b7be73d..7396a96 100644
--- a/src/pages/console.js
+++ b/src/console/index.js
@@ -1,10 +1,10 @@
-import './console.scss';
-import messages from 'content/messages';
-import CompletionComponent from 'components/completion';
-import ConsoleComponent from 'components/console';
-import reducers from 'reducers';
-import { createStore } from 'store';
-import * as consoleActions from 'actions/console';
+import './site.scss';
+import messages from 'shared/messages';
+import CompletionComponent from 'console/components/completion';
+import ConsoleComponent from 'console/components/console';
+import reducers from 'console/reducers';
+import { createStore } from 'shared/store';
+import * as consoleActions from 'console/actions/console';
const store = createStore(reducers);
let completionComponent = null;
diff --git a/src/reducers/console.js b/src/console/reducers/index.js
index b9ed5b8..ee9c691 100644
--- a/src/reducers/console.js
+++ b/src/console/reducers/index.js
@@ -1,4 +1,4 @@
-import actions from 'actions';
+import actions from 'console/actions';
const defaultState = {
errorShown: false,
diff --git a/src/pages/console.scss b/src/console/site.scss
index 5823dce..5823dce 100644
--- a/src/pages/console.scss
+++ b/src/console/site.scss
diff --git a/src/actions/follow.js b/src/content/actions/follow.js
index 708cd95..5a18dd5 100644
--- a/src/actions/follow.js
+++ b/src/content/actions/follow.js
@@ -1,4 +1,4 @@
-import actions from 'actions';
+import actions from 'content/actions';
const enable = (newTab) => {
return {
diff --git a/src/actions/index.js b/src/content/actions/index.js
index 6a64795..0b3749d 100644
--- a/src/actions/index.js
+++ b/src/content/actions/index.js
@@ -1,12 +1,4 @@
export default {
- // console commands
- CONSOLE_SHOW_COMMAND: 'console.show.command',
- CONSOLE_SET_COMPLETIONS: 'console.set.completions',
- CONSOLE_SHOW_ERROR: 'console.show.error',
- CONSOLE_HIDE: 'console.hide',
- CONSOLE_COMPLETION_NEXT: 'console.completion.next',
- CONSOLE_COMPLETION_PREV: 'console.completion.prev',
-
// User input
INPUT_KEY_PRESS: 'input.key,press',
INPUT_CLEAR_KEYS: 'input.clear.keys',
diff --git a/src/actions/input.js b/src/content/actions/input.js
index 61acb76..cc4efac 100644
--- a/src/actions/input.js
+++ b/src/content/actions/input.js
@@ -1,4 +1,4 @@
-import actions from 'actions';
+import actions from 'content/actions';
const asKeymapChars = (key, ctrl) => {
if (ctrl) {
diff --git a/src/content/actions/operation.js b/src/content/actions/operation.js
new file mode 100644
index 0000000..d188a60
--- /dev/null
+++ b/src/content/actions/operation.js
@@ -0,0 +1,43 @@
+import operations from 'shared/operations';
+import messages from 'shared/messages';
+import * as scrolls from 'content/scrolls';
+import * as navigates from 'content/navigates';
+import * as followActions from 'content/actions/follow';
+
+const exec = (operation) => {
+ switch (operation.type) {
+ case operations.SCROLL_LINES:
+ return scrolls.scrollLines(window, operation.count);
+ case operations.SCROLL_PAGES:
+ return scrolls.scrollPages(window, operation.count);
+ case operations.SCROLL_TOP:
+ return scrolls.scrollTop(window);
+ case operations.SCROLL_BOTTOM:
+ return scrolls.scrollBottom(window);
+ case operations.SCROLL_HOME:
+ return scrolls.scrollLeft(window);
+ case operations.SCROLL_END:
+ return scrolls.scrollRight(window);
+ case operations.FOLLOW_START:
+ return followActions.enable(false);
+ case operations.NAVIGATE_HISTORY_PREV:
+ return navigates.historyPrev(window);
+ case operations.NAVIGATE_HISTORY_NEXT:
+ return navigates.historyNext(window);
+ case operations.NAVIGATE_LINK_PREV:
+ return navigates.linkPrev(window);
+ case operations.NAVIGATE_LINK_NEXT:
+ return navigates.linkNext(window);
+ case operations.NAVIGATE_PARENT:
+ return navigates.parent(window);
+ case operations.NAVIGATE_ROOT:
+ return navigates.root(window);
+ default:
+ browser.runtime.sendMessage({
+ type: messages.BACKGROUND_OPERATION,
+ operation,
+ });
+ }
+};
+
+export { exec };
diff --git a/src/components/content-input.js b/src/content/components/content-input.js
index 9568caf..9568caf 100644
--- a/src/components/content-input.js
+++ b/src/content/components/content-input.js
diff --git a/src/components/follow.js b/src/content/components/follow.js
index eedbd4d..c87424d 100644
--- a/src/components/follow.js
+++ b/src/content/components/follow.js
@@ -1,5 +1,5 @@
-import * as followActions from 'actions/follow';
-import messages from 'content/messages';
+import * as followActions from 'content/actions/follow';
+import messages from 'shared/messages';
import Hint from 'content/hint';
import HintKeyProducer from 'content/hint-key-producer';
diff --git a/src/components/keymapper.js b/src/content/components/keymapper.js
index 3685a4f..8f2cead 100644
--- a/src/components/keymapper.js
+++ b/src/content/components/keymapper.js
@@ -1,5 +1,5 @@
-import * as inputActions from 'actions/input';
-import * as operationActions from 'actions/operation';
+import * as inputActions from 'content/actions/input';
+import * as operationActions from 'content/actions/operation';
export default class KeymapperComponent {
constructor(store) {
diff --git a/src/content/index.js b/src/content/index.js
index d380291..adea871 100644
--- a/src/content/index.js
+++ b/src/content/index.js
@@ -1,12 +1,12 @@
import './console-frame.scss';
import * as consoleFrames from './console-frames';
-import * as settingActions from 'actions/setting';
-import { createStore } from 'store';
-import ContentInputComponent from 'components/content-input';
-import KeymapperComponent from 'components/keymapper';
-import FollowComponent from 'components/follow';
-import reducers from 'reducers';
-import messages from './messages';
+import * as settingActions from 'settings/actions/setting';
+import { createStore } from 'shared/store';
+import ContentInputComponent from 'content/components/content-input';
+import KeymapperComponent from 'content/components/keymapper';
+import FollowComponent from 'content/components/follow';
+import reducers from 'content/reducers';
+import messages from 'shared/messages';
const store = createStore(reducers);
const followComponent = new FollowComponent(window.document.body, store);
diff --git a/src/reducers/follow.js b/src/content/reducers/follow.js
index ed875e8..b7c0cf3 100644
--- a/src/reducers/follow.js
+++ b/src/content/reducers/follow.js
@@ -1,4 +1,4 @@
-import actions from 'actions';
+import actions from 'content/actions';
const defaultState = {
enabled: false,
diff --git a/src/reducers/index.js b/src/content/reducers/index.js
index 8ed6452..a62217f 100644
--- a/src/reducers/index.js
+++ b/src/content/reducers/index.js
@@ -1,11 +1,10 @@
-import inputReducer from 'reducers/input';
-import consoleReducer from 'reducers/console';
-import settingReducer from 'reducers/setting';
-import followReducer from 'reducers/follow';
+import settingReducer from 'settings/reducers/setting';
+import inputReducer from './input';
+import followReducer from './follow';
+// Make setting reducer instead of re-use
const defaultState = {
input: inputReducer(undefined, {}),
- console: consoleReducer(undefined, {}),
setting: settingReducer(undefined, {}),
follow: followReducer(undefined, {}),
};
@@ -13,7 +12,6 @@ const defaultState = {
export default function reducer(state = defaultState, action = {}) {
return Object.assign({}, state, {
input: inputReducer(state.input, action),
- console: consoleReducer(state.console, action),
setting: settingReducer(state.setting, action),
follow: followReducer(state.follow, action),
});
diff --git a/src/reducers/input.js b/src/content/reducers/input.js
index 2e4bcd8..802020f 100644
--- a/src/reducers/input.js
+++ b/src/content/reducers/input.js
@@ -1,4 +1,4 @@
-import actions from 'actions';
+import actions from 'content/actions';
const defaultState = {
keys: '',
diff --git a/src/settings/actions/index.js b/src/settings/actions/index.js
new file mode 100644
index 0000000..8c212c2
--- /dev/null
+++ b/src/settings/actions/index.js
@@ -0,0 +1,4 @@
+export default {
+ // Settings
+ SETTING_SET_SETTINGS: 'setting.set.settings',
+};
diff --git a/src/actions/setting.js b/src/settings/actions/setting.js
index 2a47608..697bcf0 100644
--- a/src/actions/setting.js
+++ b/src/settings/actions/setting.js
@@ -1,5 +1,5 @@
-import actions from 'actions';
-import messages from 'content/messages';
+import actions from 'settings/actions';
+import messages from 'shared/messages';
import DefaultSettings from 'shared/default-settings';
const load = () => {
diff --git a/src/components/setting.js b/src/settings/components/setting.js
index c2f99b6..14482a3 100644
--- a/src/components/setting.js
+++ b/src/settings/components/setting.js
@@ -1,4 +1,4 @@
-import * as settingActions from 'actions/setting';
+import * as settingActions from 'settings/actions/setting';
import { validate } from 'shared/validators/setting';
export default class SettingComponent {
diff --git a/src/pages/settings.html b/src/settings/index.html
index 99d6c6b..99d6c6b 100644
--- a/src/pages/settings.html
+++ b/src/settings/index.html
diff --git a/src/pages/settings.js b/src/settings/index.js
index 6e25e6f..c8d6cc4 100644
--- a/src/pages/settings.js
+++ b/src/settings/index.js
@@ -1,7 +1,7 @@
-import './settings.scss';
-import SettingComponent from 'components/setting';
-import settingReducer from 'reducers/setting';
-import { createStore } from 'store';
+import './site.scss';
+import SettingComponent from 'settings/components/setting';
+import settingReducer from 'settings/reducers/setting';
+import { createStore } from 'shared/store';
const store = createStore(settingReducer);
let settingComponent = null;
diff --git a/src/reducers/setting.js b/src/settings/reducers/setting.js
index 7326ed7..f7d9242 100644
--- a/src/reducers/setting.js
+++ b/src/settings/reducers/setting.js
@@ -1,4 +1,4 @@
-import actions from 'actions';
+import actions from 'settings/actions';
const defaultState = {
settings: {}
diff --git a/src/pages/settings.scss b/src/settings/site.scss
index 5707c8a..5707c8a 100644
--- a/src/pages/settings.scss
+++ b/src/settings/site.scss
diff --git a/src/content/messages.js b/src/shared/messages.js
index 138f0e0..138f0e0 100644
--- a/src/content/messages.js
+++ b/src/shared/messages.js
diff --git a/src/store/index.js b/src/shared/store/index.js
index 2fafdf1..2fafdf1 100644
--- a/src/store/index.js
+++ b/src/shared/store/index.js