A lightweight JavaScript playground framework for rapid prototyping and experimentation. Test²Sandbox provides an intuitive API for creating interactive web applications with real-time console output and dynamic DOM manipulation.
- Instant Playground: No complex setup required - start coding immediately
- Real-time Console: Captured console output with interactive display
- Dynamic DOM Builder: Fluent API for creating and styling HTML elements
- Hot Reload: Development server with automatic refresh
- Clean Architecture: Modular design with separation of concerns
- Browser Integration: Seamless browser launching and control
- Clone or download the repository
- Install dependencies:
npm installStart the development server:
npm run dev
# or
npm startThe playground will be available at http://localhost:5173
Interactive Controls:
- Press
oto open the playground in your browser - Press
qto quit the server Ctrl+Cto force shutdown
Create your playground in main.js:
import { playground } from "./github/lib/playground.js";
// Initialize the playground
playground.init();
// Build your DOM structure
playground.struct(() => {
const title = document.createElement("h1");
title.textContent = "Hello World";
const button = document.createElement("button");
button.textContent = "Click me!";
button.onclick = () => console.log("Button clicked!");
});
// Add custom styles
playground.style({
'h1': {
color: '#007acc',
textAlign: 'center'
},
'button': {
padding: '10px 20px',
fontSize: '16px'
}
});Initializes the playground container. Creates a #playground div if it doesn't exist.
Builds DOM structure using a callback function.
Parameters:
callback: Function that creates and returns DOM elementsoptions: Configuration objectclear: Boolean - Clear playground before adding content
Return values from callback:
- Single Node: Appends the node
- Array of Nodes: Appends all nodes
- DocumentFragment: Appends fragment contents
- Nothing: Auto-collects all created elements
Applies CSS styles to the playground.
Parameters:
definition: String (raw CSS) or Object (selector-based rules)options: Configuration objectreplace: Boolean - Replace existing stylesid: String - Style element ID
The framework automatically captures console.log() output and displays it in the #javascript-output element with syntax highlighting and formatting.
TestSquared-Playground/
├── main.js # Your playground code
├── package.json # Project dependencies
├── server/
│ └── dev-server.js # Express development server
└── github/
└── lib/
├── playground.js # Core playground API
└── webStyle.css # Default styling
The framework includes a dark theme by default. You can customize the appearance by:
- Using the playground.style() API:
playground.style({
'.my-class': {
backgroundColor: '#f0f0f0',
padding: '1rem'
}
});-
Modifying
github/lib/webStyle.cssfor global changes -
Adding your own CSS files and linking them in the server template
The development server (server/dev-server.js) provides:
- Static file serving for assets
- Hot reload functionality
- Automatic browser launching
- Interactive terminal controls
- Environment variable support (
PORT,AUTO_OPEN)
Default port: 5173 (configurable via PORT environment variable)
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the terms specified in the LICENSE file.
Created by syntaxMORG0
Happy coding! 🚀