Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pakastin committed Apr 5, 2017
0 parents commit 344caff
Show file tree
Hide file tree
Showing 15 changed files with 166 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
node_modules
dist.zip
42 changes: 42 additions & 0 deletions build.js
@@ -0,0 +1,42 @@
const fs = require('fs');
const archiver = require('archiver');

const pkg = require('./package.json');
const distPkg = require('./dist/manifest.json');

if (distPkg.version !== pkg.version) {
console.log('changing', 'dist/package.json from', distPkg.version, 'to', pkg.version);
distPkg.version = pkg.version;
fs.writeFileSync('./dist/manifest.json', JSON.stringify(distPkg, null, 2));
}

console.log('Creating dist.zip');

const zip = fs.createWriteStream('./dist.zip');
const archive = archiver('zip', {
zlib: { level: 9 }
});

zip.on('close', function () {
console.log('done!');
});

archive.on('error', function (err) {
throw err;
});

archive.pipe(zip);

fs.readdir('./dist', (err, files) => {
if (err) {
throw err;
}
files.forEach(file => {
if (file[0] === '.') {
return;
}
console.log(file);
archive.append(fs.createReadStream('./dist/' + file), { name: file });
});
archive.finalize();
});
6 changes: 6 additions & 0 deletions dist/devtools.html
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<html>
<body>
<script src="devtools.js"></script>
</body>
</html>
45 changes: 45 additions & 0 deletions dist/devtools.js
@@ -0,0 +1,45 @@
/* global chrome, $0 */
const getView = function () {
return $0 && $0.__redom_view;
};

const init = function () {
const view = window.$r = $0 && $0.__redom_view;

return view && view.constructor.name;
};

const findFirstViews = function () {
return iterate($0, []);

function iterate (node, results) {
let traverse = node.firstChild;

while (traverse) {
if (traverse.__redom_view) {
results.push(traverse);
} else {
iterate(traverse, results);
}
traverse = traverse.nextSibling;
}

return results;
}
};

chrome.devtools.panels.create('RE:DOM', 'icon48.png', 'doc.html');

chrome.devtools.panels.elements.createSidebarPane('RE:DOM', function (sidebar) {
const updateElementProperties = () => {
chrome.devtools.inspectedWindow.eval(`(${init.toString()})()`, function (result) {
if (result) {
sidebar.setExpression(`(${getView.toString()})()`, 'View: ' + result);
} else {
sidebar.setExpression(`(${findFirstViews.toString()})()`, 'Child views');
}
});
};
updateElementProperties();
chrome.devtools.panels.elements.onSelectionChanged.addListener(updateElementProperties);
});
38 changes: 38 additions & 0 deletions dist/doc.html
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>
<head>
<style>
body {
color: #222;
}
code {
font-size: inherit;
background-color: #e5e5e5;
margin: -.1rem 0;
padding: .1rem .2rem;
}
#logo {
position: absolute;
top: 0;
right: 0;
}
#screenshot {
display: block;
margin: 1.5rem auto;
max-width: calc(100% - 3rem);
box-shadow: 0 20px 50px -10px rgba(0, 0, 0, .25);
}
</style>
</head>
<body>
<h1>RE:DOM Developer Tools</h1>
<ul>
<li>Open elements panel</li>
<li>Select element you want to inspect</li>
<li>Open RE:DOM tab</li>
<li>Use <code>$r</code> shortcut in console</li>
</ul>
<img id="screenshot" src="screenshot.png">
<img id="logo" src="icon128.png">
</body>
</html>
Binary file added dist/icon128.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/icon16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/icon48.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions dist/manifest.json
@@ -0,0 +1,16 @@
{
"manifest_version": 2,
"name": "RE:DOM dev tools",
"version": "1.0.0",
"description": "RE:DOM extension for Chrome devtools",
"devtools_page": "devtools.html",
"web_accessible_resources": [
"devtools.html",
"sidebarpane.html"
],
"icons": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
}
}
Binary file added dist/screenshot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/1280x800.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/1400x560.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/440x280.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/920x680.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions package.json
@@ -0,0 +1,17 @@
{
"name": "redom-devtools",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "node build",
"version": "node run build && git add .",
"postversion": "git push --tags",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"archiver": "~1.3.0"
}
}

0 comments on commit 344caff

Please sign in to comment.