-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 98734b7
Showing
127 changed files
with
7,397 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"presets": [ | ||
"env", "stage-2" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "semistandard", | ||
"env": { "es6": true }, | ||
"plugins": ["import"], | ||
"globals": { | ||
"chrome": false, | ||
"document": false | ||
}, | ||
"rules": { | ||
"comma-dangle": ["error", "always-multiline"], | ||
"space-before-function-paren": ["error", "never"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
### https://raw.github.com/github/gitignore/0f88fa75def7ed7d96935b8630793e51953df9b0/node.gitignore | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
|
||
### https://raw.github.com/github/gitignore/0f88fa75def7ed7d96935b8630793e51953df9b0/Global/macos.gitignore | ||
|
||
*.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import init from './lib/background/init'; | ||
init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import init from './lib/content/init'; | ||
init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
chrome.devtools.panels.create( | ||
'nezumi', | ||
'', | ||
'panel.html' | ||
); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!doctype html> | ||
<html> | ||
<body> | ||
<script src='./devtools.js'></script> | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"manifest_version": 2, | ||
"name": "nezumi", | ||
"description": "Test code generator for Capybara/RSpec.", | ||
"version": "1.0", | ||
"icons": { | ||
"16": "icon16.png", | ||
"48": "icon48.png", | ||
"128": "icon128.png" | ||
}, | ||
"devtools_page": "devtools.html", | ||
"background": { | ||
"scripts": ["background.js"], | ||
"persistent": false | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": ["file://*/*", "http://*/*", "https://*/*"], | ||
"js": ["content.js"], | ||
"run_at": "document_start" | ||
} | ||
], | ||
"permissions": [ | ||
"tabs" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#container { | ||
min-width: 300px; | ||
min-height: 300px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!doctype html> | ||
<html> | ||
<body> | ||
<div id="app"></div> | ||
<script src='./panel.js'></script> | ||
</body> | ||
</html> |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { EventEmitter } from 'events'; | ||
export const emitter = new EventEmitter(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { emitter } from './emitter'; | ||
|
||
export default function() { | ||
connectToDevtool(); | ||
connectToContent(); | ||
} | ||
|
||
const connectToDevtool = () => { | ||
chrome.runtime.onConnect.addListener((port) => { | ||
if (port.name !== 'devtool') return; | ||
|
||
console.log('background <--> devtool connected.'); | ||
|
||
const sendToDevtool = (store) => { | ||
console.log('background -> devtool', store); | ||
port.postMessage(store); | ||
}; | ||
emitter.on('devtool.send', sendToDevtool); | ||
port.onDisconnect.addListener(() => emitter.removeListener('devtool.send', sendToDevtool)); | ||
|
||
port.onMessage.addListener((msg) => { | ||
console.log('devtool -> background', msg); | ||
emitter.emit('devtool.receive', msg); | ||
}); | ||
|
||
// pass to content | ||
port.onMessage.addListener((msg) => emitter.emit('content.send', Object.assign({ location: 'devtool' }, msg || {}))); | ||
}); | ||
}; | ||
|
||
const connectToContent = () => { | ||
chrome.runtime.onConnect.addListener((port) => { | ||
if (port.name !== 'content') return; | ||
|
||
console.log('background <--> content connected.'); | ||
|
||
const sendToContent = (store) => { | ||
console.log('background -> content', store); | ||
port.postMessage(store); | ||
}; | ||
emitter.on('content.send', sendToContent); | ||
port.onDisconnect.addListener(() => emitter.removeListener('content.send', sendToContent)); | ||
|
||
port.onMessage.addListener((msg) => { | ||
console.log('content -> background', msg); | ||
emitter.emit('content.receive', msg); | ||
}); | ||
|
||
// pass to devtool | ||
port.onMessage.addListener((msg) => emitter.emit('devtool.send', Object.assign({ location: 'content' }, msg || {}))); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { EventEmitter } from 'events'; | ||
export const emitter = new EventEmitter(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { emitter } from './emitter'; | ||
import { watcher } from './watcher/Watcher'; | ||
import * as devtoolMutationTypes from '../panel/store/mutation-types'; | ||
|
||
const devtoolHandler = (msg) => { | ||
switch (msg.type) { | ||
case devtoolMutationTypes.PANEL_TOGGLE_WATCHING: | ||
watcher.toggle(msg.payload); | ||
break; | ||
default: | ||
// nothing to do; | ||
} | ||
}; | ||
|
||
const backgroundHandler = (msg) => { | ||
// nothing to do. | ||
}; | ||
|
||
export default function() { | ||
emitter.on('background.receive', (msg) => { | ||
switch (msg.location) { | ||
case 'devtool': | ||
devtoolHandler(msg); | ||
break; | ||
case 'background': | ||
backgroundHandler(msg); | ||
break; | ||
default: | ||
// nothing to do. | ||
} | ||
}); | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const port = chrome.runtime.connect({name: 'content'}); | ||
|
||
const sendToBackground = (store) => { | ||
console.log('content -> background', store); | ||
port.postMessage(store); | ||
}; | ||
emitter.on('background.send', sendToBackground); | ||
port.onDisconnect.addListener(() => emitter.removeListener('background.send', sendToBackground)); | ||
|
||
port.onMessage.addListener((msg) => { | ||
console.log('background -> content', msg); | ||
emitter.emit('background.receive', msg); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import _ from 'lodash'; | ||
import events from './events'; | ||
|
||
class Watcher { | ||
constructor() { | ||
this.watching = false; | ||
this.events = _.map(events, EventClass => new EventClass()); | ||
} | ||
|
||
on() { | ||
if (this.watching) return; | ||
this.watching = true; | ||
this.events.forEach(e => e.on()); | ||
|
||
console.log('[🐭nezumi] 👀watching start.'); | ||
} | ||
|
||
off() { | ||
this.watching = false; | ||
this.events.forEach(e => e.off()); | ||
|
||
console.log('[🐭nezumi] 💤watching stop.'); | ||
} | ||
|
||
toggle(newWatchingValue = !this.watching) { | ||
if (newWatchingValue) { | ||
this.on(); | ||
} else { | ||
this.off(); | ||
} | ||
} | ||
} | ||
|
||
// export singleton watcher | ||
export const watcher = new Watcher(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import $ from 'jquery'; | ||
|
||
import { emitter } from '../../emitter'; | ||
import { analyze } from '../utils/analyze'; | ||
|
||
export default class Base { | ||
hundler = (e) => { | ||
const analyzeResult = analyze(e.originalEvent.target); | ||
const eventName = this.eventName(); | ||
|
||
emitter.emit('background.send', { | ||
type: 'fire', | ||
value: Object.assign({ event: eventName }, analyzeResult), | ||
}); | ||
} | ||
|
||
on() { | ||
$(document).on(this.eventName(), this.hundler); | ||
} | ||
|
||
off() { | ||
$(document).off(this.eventName(), this.hundler); | ||
} | ||
|
||
eventName() { | ||
return ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Base from './Base'; | ||
|
||
export default class Change extends Base { | ||
eventName() { | ||
return 'change'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Base from './Base'; | ||
|
||
export default class Click extends Base { | ||
eventName() { | ||
return 'click'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Change from './Change'; | ||
import Click from './Click'; | ||
|
||
export default { | ||
Change, | ||
Click, | ||
}; |
Oops, something went wrong.