Repository: asfktz/devtools-playground
Branch: master
Commit: 96dc9a4e9661
Files: 12
Total size: 7.5 KB
Directory structure:
gitextract_6rxww82j/
├── .eslintrc.js
├── .gitignore
├── LICENSE.md
├── README.md
├── cli.js
├── createSettings.js
├── index.html
├── main.js
├── package.json
├── renderer.js
├── version.js
└── watch.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .eslintrc.js
================================================
module.exports = {
"env": {
"es6": true,
"node": true,
"browser": true
},
"extends": "eslint:recommended",
"rules": {
"no-console": 0,
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
};
================================================
FILE: .gitignore
================================================
node_modules
.esm-cache
================================================
FILE: LICENSE.md
================================================
MIT License
Copyright (c) 2017 Asaf Katz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# devtools-playground
Standalone Devtools for prototyping & debugging.
<img src="./animation.gif" />
# Features
- Standalone DevTools
- Live reloading
- Support for ES modules (import/export)
- Built on top of electron, which means that both Node.js modules & the Browser's APIs are available
# Install
```
npm i -g devtools-playground
```
# Usage
Run:
```
devtools ./file.js
```
It'll open Devtools and reload automatically on every file change.
### ES Modules
By default, it uses commonJS modules.
But you can enable support for ES module too:
```
devtools ./file.js --esm
```
It uses `@std/esm` under the hood
---
Inspired by [Jam3/devtool](https://github.com/Jam3/devtool)
================================================
FILE: cli.js
================================================
#! /usr/bin/env node
const electron = require('electron');
const proc = require('child_process');
const version = require('./version');
const args = process.argv.slice(2);
const { log } = console;
if (['--version', '-v'].includes(args[0])) {
return log(version);
}
// spawn Electron
proc.spawn(electron, [__dirname, ...args], {
// stdio: 'inherit'
});
================================================
FILE: createSettings.js
================================================
const { join } = require('path');
const pkgDir = require('pkg-dir');
const minimist = require('minimist');
const get = require('lodash/get');
const first = require('lodash/first');
const parseArgs = processArgs => {
const args = minimist(processArgs.slice(2));
return {
entry: first(args._),
esm: !!args.esm
};
};
const resolveEntry = (dir, entry) => {
if (entry) return entry;
// If no entry specified, take the main entry from package.json
// if there's no package.json,either, take './index.js'
try {
const pkg = require(join(dir, './package.json'));
return get(pkg, 'main');
} catch (err) {
return './index.js';
}
};
module.exports = function(processArgs) {
const args = parseArgs(processArgs);
const dir = pkgDir.sync() || process.cwd();
const entry = join(dir, resolveEntry(dir, args.entry));
const { esm } = args;
return { entry, dir, esm };
};
================================================
FILE: index.html
================================================
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Devtools</title>
</head>
<body>
<script>
[
{ type: 'Node', version: process.versions.node },
{ type: 'Chromium', version: process.versions.chrome },
{ type: 'Electron', version: process.versions.electron }
].forEach(({ type, version }) => {
document.write(`<p>${type}: ${version}</p>`);
});
</script>
</body>
<script>
require('./renderer');
</script>
</html>
================================================
FILE: main.js
================================================
const electron = require('electron');
// Module to control application life.
const app = electron.app;
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow;
const path = require('path');
const url = require('url');
const watch = require('./watch');
const createSettings = require('./createSettings');
const settings = createSettings(process.argv);
// expose settings to renderer process
global.settings = settings;
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
const quit = app.quit.bind(app);
function createWindow() {
// Create the browser window.
mainWindow = new BrowserWindow({ width: 0, height: 0 });
// and load the index.html of the app.
mainWindow.loadURL(
url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
})
);
// Open the DevTools.
mainWindow.webContents.openDevTools({ mode: 'detach' });
// kill the process when devtools is closed
mainWindow.webContents.on('devtools-closed', quit);
// live-reload devtools
// watch for changes in the user's project
const unwatch = watch(settings.dir, () => {
mainWindow.reload();
});
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
unwatch();
});
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);
// Quit when all windows are closed.
app.on('window-all-closed', quit);
app.on('activate', function() {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
});
================================================
FILE: package.json
================================================
{
"name": "devtools-playground",
"version": "0.1.0",
"description": "Standalone Devtools for prototyping & debugging.",
"main": "main.js",
"bin": {
"devtools": "./cli.js"
},
"repository": "https://github.com/asfktz/devtools-playground",
"keywords": [
"devtools",
"inspect",
"debugging",
"live-reload"
],
"author": "Asaf Katz",
"license": "MIT",
"dependencies": {
"@std/esm": "^0.11.0",
"chokidar": "^1.7.0",
"electron": "~1.7.8",
"lodash": "^4.17.4",
"minimist": "^1.2.0",
"pkg-dir": "^2.0.0"
}
}
================================================
FILE: renderer.js
================================================
const { remote } = require('electron');
// Get the settings exposed by the main process (see main.js).
const { entry, esm } = remote.getGlobal('settings');
// Get enhanced require.
const getRequire = esm => {
// No enhancements are needed.
if (!esm) return require;
// With support for ES modules.
return require('@std/esm')(module, {
cjs: true,
esm: 'js',
sourceMap: true
});
};
// Call the entry with the enhanced require method.
getRequire(esm)(entry);
================================================
FILE: version.js
================================================
const { name, version } = require('./package.json');
module.exports = `${name} ${version}`;
================================================
FILE: watch.js
================================================
const chokidar = require('chokidar');
const path = require('path');
const debounce = require('lodash/debounce');
module.exports = (dir, callback) => {
const watcher = chokidar
.watch(dir, {
ignored: [
path.join(dir, 'node_modules'),
path.join(dir, '.esm-cache')
],
ignoreInitial: true
})
.on('all', debounce(callback, 30));
return () => watcher.close();
};
gitextract_6rxww82j/ ├── .eslintrc.js ├── .gitignore ├── LICENSE.md ├── README.md ├── cli.js ├── createSettings.js ├── index.html ├── main.js ├── package.json ├── renderer.js ├── version.js └── watch.js
SYMBOL INDEX (1 symbols across 1 files)
FILE: main.js
function createWindow (line 26) | function createWindow() {
Condensed preview — 12 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (9K chars).
[
{
"path": ".eslintrc.js",
"chars": 480,
"preview": "module.exports = {\n \"env\": {\n \"es6\": true,\n \"node\": true,\n \"browser\": true\n },\n \"extends\":"
},
{
"path": ".gitignore",
"chars": 23,
"preview": "node_modules\n.esm-cache"
},
{
"path": "LICENSE.md",
"chars": 1065,
"preview": "MIT License\n\nCopyright (c) 2017 Asaf Katz\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\n"
},
{
"path": "README.md",
"chars": 688,
"preview": "# devtools-playground\nStandalone Devtools for prototyping & debugging.\n\n<img src=\"./animation.gif\" />\n\n# Features\n- Stan"
},
{
"path": "cli.js",
"chars": 360,
"preview": "#! /usr/bin/env node\n\nconst electron = require('electron');\nconst proc = require('child_process');\nconst version = requi"
},
{
"path": "createSettings.js",
"chars": 907,
"preview": "const { join } = require('path');\nconst pkgDir = require('pkg-dir');\nconst minimist = require('minimist');\nconst get = r"
},
{
"path": "index.html",
"chars": 502,
"preview": "<!DOCTYPE html>\n<html>\n <head>\n <meta charset=\"UTF-8\">\n <title>Devtools</title>\n </head>\n <body>\n <script>\n "
},
{
"path": "main.js",
"chars": 2125,
"preview": "const electron = require('electron');\n// Module to control application life.\nconst app = electron.app;\n\n// Module to cre"
},
{
"path": "package.json",
"chars": 567,
"preview": "{\n \"name\": \"devtools-playground\",\n \"version\": \"0.1.0\",\n \"description\": \"Standalone Devtools for prototyping & debuggi"
},
{
"path": "renderer.js",
"chars": 480,
"preview": "const { remote } = require('electron');\n// Get the settings exposed by the main process (see main.js).\nconst { entry, es"
},
{
"path": "version.js",
"chars": 91,
"preview": "const { name, version } = require('./package.json');\nmodule.exports = `${name} ${version}`;"
},
{
"path": "watch.js",
"chars": 409,
"preview": "const chokidar = require('chokidar');\nconst path = require('path');\nconst debounce = require('lodash/debounce');\n\nmodule"
}
]
About this extraction
This page contains the full source code of the asfktz/devtools-playground GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 12 files (7.5 KB), approximately 2.1k tokens, and a symbol index with 1 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.