diff options
| author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-11 21:45:48 +0900 | 
|---|---|---|
| committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-11 21:45:48 +0900 | 
| commit | b2cddcd69b4ae06770d66808624fc43f3dcbcb0e (patch) | |
| tree | 548eb65f678cfa1dca36773f01c635ec6c0e2066 /src/shared | |
| parent | 15d39a479aa7f2c4b804bac8c4352dd0a120bc75 (diff) | |
| parent | 7bc569eac745b97137e1db8b9271493b3e5c8a20 (diff) | |
Merge branch 'message-passing-refactoring'
Diffstat (limited to 'src/shared')
| -rw-r--r-- | src/shared/actions.js | 54 | ||||
| -rw-r--r-- | src/shared/messages.js | 19 | 
2 files changed, 0 insertions, 73 deletions
| diff --git a/src/shared/actions.js b/src/shared/actions.js deleted file mode 100644 index 7151dd1..0000000 --- a/src/shared/actions.js +++ /dev/null @@ -1,54 +0,0 @@ -export const CMD_OPEN = 'cmd.open'; -export const CMD_TABS_OPEN = 'cmd.tabs.open'; -export const CMD_BUFFER = 'cmd.buffer'; -export const TABS_CLOSE = 'tabs.close'; -export const TABS_REOPEN = 'tabs.reopen'; -export const TABS_PREV = 'tabs.prev'; -export const TABS_NEXT = 'tabs.next'; -export const TABS_RELOAD = 'tabs.reload'; -export const SCROLL_LINES = 'scroll.lines'; -export const SCROLL_PAGES = 'scroll.pages'; -export const SCROLL_TOP = 'scroll.top'; -export const SCROLL_BOTTOM = 'scroll.bottom'; -export const SCROLL_LEFT= 'scroll.left'; -export const SCROLL_RIGHT= 'scroll.right'; -export const FOLLOW_START = 'follow.start'; -export const HISTORY_PREV = 'history.prev'; -export const HISTORY_NEXT = 'history.next'; -export const ZOOM_IN = 'zoom.in'; -export const ZOOM_OUT = 'zoom.out'; -export const ZOOM_NEUTRAL = 'zoom.neutral'; - -const BACKGROUND_ACTION_SET = new Set([ -  TABS_CLOSE, -  TABS_REOPEN, -  TABS_PREV, -  TABS_NEXT, -  TABS_RELOAD, -  ZOOM_IN, -  ZOOM_OUT, -  ZOOM_NEUTRAL -]); - -const CONTENT_ACTION_SET = new Set([ -  CMD_OPEN, -  CMD_TABS_OPEN, -  CMD_BUFFER, -  SCROLL_LINES, -  SCROLL_PAGES, -  SCROLL_TOP, -  SCROLL_BOTTOM, -  SCROLL_LEFT, -  SCROLL_RIGHT, -  FOLLOW_START, -  HISTORY_PREV, -  HISTORY_NEXT -]); - -export const isBackgroundAction = (action) => { -  return BACKGROUND_ACTION_SET.has(action); -}; - -export const isContentAction = (action) => { -  return CONTENT_ACTION_SET.has(action); -}; diff --git a/src/shared/messages.js b/src/shared/messages.js deleted file mode 100644 index 517fc4c..0000000 --- a/src/shared/messages.js +++ /dev/null @@ -1,19 +0,0 @@ -const receive = (win, callback) => { -  win.addEventListener('message', (e) => { -    let message; -    try { -      message = JSON.parse(e.data); -    } catch (e) { -      // ignore message posted by author of web page -      return; -    } - -    callback(message); -  }) -} - -const send = (win, message) => { -  win.postMessage(JSON.stringify(message), '*'); -} - -export { receive, send }; | 
