11# GitHub Copilot Instructions for moebius-web
22
3+ > [ !NOTE]
4+ > this project, ` moebius-web ` is being rebranded as ` teXt0wnz ` or ` text.0w.nz `
5+
36## Project Overview
47
5- Moebius-web is a web-based ANSI art editor that operates in two modes: server-side (collaborative) and client-side (standalone).
8+ teXt0wnz is a web-based ANSI art editor that operates in two modes: server-side (collaborative) and client-side (standalone).
69
710This is a single-page application for creating ANSI/ASCII art with various drawing tools, color palettes, export capabilities, and real-time collaboration features.
811
9- ## Architecture & Key Files
10-
11- ### Client-Side Application (Primary Focus)
12+ ### Client-Side Implementation (Drawing Editor)
1213
13- ** Entry Point & Core:**
14- - ` public/index.html ` - Single HTML page, includes all necessary scripts
15- - ` public/js/document_onload.js ` - ** Main entry point** , initializes all tools and UI
16- - ` public/js/core.js ` - ** Core application logic** , canvas management, rendering
14+ Important Files:
1715
18- ** UI & Interaction:**
19- - ` public/js/ui.js ` - UI components, overlays, toolbar management
20- - ` public/js/keyboard.js ` - Keyboard event handlers and shortcuts
21- - ` public/js/elementhelper.js ` - DOM utility functions
16+ #### Sources
17+ ```
18+ public/
19+ ├── css/
20+ │ └── style.css # tailwindcss style sheet
21+ ├── fonts/ # folder of png format fonts
22+ ├── img/ # static assets
23+ ├── js/
24+ │ ├── canvas.js # textArtCanvas
25+ │ ├── file.js # File open/save
26+ │ ├── font.js # font management
27+ │ ├── freehand_tools.js # drawing tool logic
28+ │ ├── keyboard.js # keybind listeners/handlers
29+ │ ├── main.js # main interypoint
30+ │ ├── network.js # WebSocket handler
31+ │ ├── palette.js # color palette logic
32+ │ ├── state.js # global state machine
33+ │ ├── toolbar.js # ui toolbar
34+ │ ├── ui.js # ui helpers
35+ │ └── worker.js # webworker hanlder (not built)
36+ └── index.html # single page application
37+ ```
2238
23- ** Drawing & Tools:**
24- - ` public/js/freehand_tools.js ` - ** Drawing tools implementation** (freehand, line, circle, square)
25- - ` public/js/file.js ` - File operations (load/save ANSI, PNG, etc.)
26- - ` public/js/savers.js ` - Export functionality for different formats
27- - ` public/js/loaders.js ` - Import functionality for various file types
39+ #### built files
40+ ```
41+ dist/
42+ ├── ui/ # all static assets moved into this dir
43+ │ ├── fonts/ # same as public/fonts
44+ │ ├── editor-[has].js # minified js
45+ │ └── stylez-[hash].css # minified css
46+ └── index.html # single page app (vite updated)
47+ ```
2848
29- ** Collaboration & Networking:**
30- - ` public/js/network.js ` - ** Core collaboration logic** , WebSocket/server communication, canvas settings synchronization
31- - ` public/js/worker.js ` - ** WebSocket worker** , handles real-time collaboration protocol and message passing
49+ ** See the project ` README.md ` for more info about the frontend.**
3250
33- ** Unused in Client Mode: **
51+ ---
3452
3553### Server-Side Implementation (Collaboration Engine)
3654- ` server.js ` - ** Express server entry point** , WebSocket setup, SSL configuration, session management
3755- ` src/ansiedit.js ` - ** Core collaboration engine** , message handling, canvas state management, persistence
3856- ` src/binary_text.js ` - ** Binary format handler** for ANSI art storage and loading
3957
40- ### Reference Implementations
41- - ` tools/ ` - ** Use as examples** when implementing new drawing tools or features
42-
4358## Development Guidelines
4459
4560### 1. Code Structure Patterns
4661
4762** Tool Implementation Pattern** (see ` public/js/freehand_tools.js ` ):
4863``` javascript
49- function createToolController () {
64+ const createToolController = () => {
5065 " use strict" ;
5166
5267 function enable () {
@@ -90,15 +105,11 @@ function $(divName) {
90105
91106### 2. Adding New Features
92107
93- 1 . ** For new drawing tools** : Use ` tools/ ` directory examples as reference
94- 2 . ** Follow the factory pattern** : Create functions that return objects with enable/disable methods
951083 . ** Canvas interaction** : Use the established event system (` onTextCanvasDown ` , etc.)
961094 . ** UI integration** : Register with ` Toolbar.add() ` and create corresponding HTML elements
97110
98111### 3. Code Style
99112
100- - Use ` "use strict"; ` in all functions
101- - Prefer factory functions over classes
102113- Use meaningful variable names (` textArtCanvas ` , ` characterBrush ` , etc.)
103114- Follow existing indentation (tabs)
104115- Use explicit returns with named properties: ` return { "enable": enable, "disable": disable }; `
@@ -108,7 +119,7 @@ function $(divName) {
108119** Canvas System:**
109120- ` textArtCanvas ` - Main drawing surface
110121- Uses character-based coordinates (not pixel-based)
111- - Supports undo/redo operations via ` textArtCanvas.startUndo() `
122+ - Supports undo/redo operations via ` State. textArtCanvas.startUndo()`
112123
113124** Color Management:**
114125- ` palette ` - Color palette management
@@ -225,13 +236,13 @@ case "newFeature":
225236** Client-Side Integration Pattern:**
226237``` javascript
227238// In public/js/network.js
228- function sendNewFeature ( value ) {
239+ const sendNewFeature = value => {
229240 if (collaborationMode && connected && ! applyReceivedSettings && ! initializing) {
230241 worker .postMessage ({ " cmd" : " newFeature" , " someProperty" : value });
231242 }
232243}
233244
234- function onNewFeature ( value ) {
245+ const onNewFeature = value => {
235246 if (applyReceivedSettings) return ; // Prevent loops
236247 applyReceivedSettings = true ;
237248 // Apply the change to UI/canvas
@@ -271,38 +282,35 @@ function onNewFeature(value) {
271282
272283## How to Run
273284
274- This project ** does not use Node.js or package.json** .
275- ** There is nothing to build.**
276- All you need is a static web server pointed at the ` public/ ` directory.
285+ ### build and install
286+
287+ ```
288+ bun i
289+ bun bake
290+ ```
291+
292+ - these commands will setup the node_modules and build the application to the ` dist ` folder
293+ - Now you need is a static web server pointed at the ` dist/ ` directory.
277294
278295### Fastest way to run (from the project root):
279296
280297``` sh
281- cd public
298+ cd dist
282299python3 -m http.server 8080
283300```
284301
285302Then open [ http://localhost:8080/ ] ( http://localhost:8080/ ) in your browser.
286303
287304- ** Any static web server will work** (e.g. Python, PHP, Ruby, ` npx serve ` , etc).
288- - Just make sure your web server's root is the ` public /` directory.
305+ - Just make sure your web server's root is the ` dist /` directory.
289306
290307## Summary
291308
292- - ** No build step**
293- - ** No package.json**
294- - ** Just serve the ` public/ ` folder as static files.**
295-
296- ## For Copilot and Automation Agents
297-
298- - Do ** not** look for ` npm start ` , ` yarn ` , or ` package.json ` .
299- - The only requirement is to start a static server in the ` public/ ` directory.
300- - Example: ` cd public && python3 -m http.server 8080 `
301- - For CI, simply check that all files are present in ` public/ ` .
309+ - ** Just build and serve the ` dist/ ` folder as static files.**
302310
303311### Local Development Setup
3043121 . ** Client-only** : Start local server: ` python3 -m http.server 8080 ` from ` public/ ` directory
305- 2 . ** With collaboration** : Run ` node server.js ` then access at ` http://localhost:1337 `
313+ 2 . ** With collaboration** : Run ` bun server 1337 ` then access at ` http://localhost:1337 `
3063143 . Use browser dev tools for debugging
3073154 . Test collaboration with multiple browser tabs/windows
308316
@@ -326,9 +334,8 @@ await page.goto('http://localhost:8080'); // or 1337 for collaboration
326334## Common Tasks
327335
328336### Adding a New Drawing Tool
329- 1 . Study examples in ` tools/ ` directory (e.g., ` tools/freehand.js ` )
3303372 . Implement in ` public/js/freehand_tools.js ` or create new file
331- 3 . Register with toolbar in ` public/js/document_onload .js `
338+ 3 . Register with toolbar in ` public/js/main .js `
3323394 . Add HTML elements to ` public/index.html ` if needed
3333405 . Add keyboard shortcut to paint shortcuts configuration
334341
@@ -358,17 +365,15 @@ await page.goto('http://localhost:8080'); // or 1337 for collaboration
358365## Important Notes
359366
360367- ** Always test changes locally** before committing
368+ - ** Always run ` bun lint:fix ` ** before committing
361369- ** Preserve existing functionality** - this is a working art editor used by artists
362370- ** Test both local and collaboration modes** when making changes that affect canvas or UI
363- - ** Use the tools/ directory** as reference for complex feature implementations
364371- ** Maintain the established patterns** for consistency and reliability
365372- ** Validate server message protocol changes** with multiple connected clients
366- - ** Consider backwards compatibility** when modifying server message formats
367373
368374## Dependencies & Browser Support
369375
370- - Pure JavaScript (ES5 compatible) for client-side
376+ - Pure JavaScript for client-side
371377- Node.js with Express framework for server-side collaboration
372- - No external client libraries or frameworks
373378- Works in modern browsers with Canvas, File API, and WebSocket support
374379- Uses Web Workers for real-time collaboration communication
0 commit comments