jsgui3-server 0.0.138 → 0.0.140

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/AGENTS.md +87 -0
  2. package/README.md +12 -0
  3. package/docs/GUIDE_TO_AGENTIC_WORKFLOWS_BY_GROK.md +19 -0
  4. package/docs/advanced-usage-examples.md +1360 -0
  5. package/docs/agent-development-guide.md +386 -0
  6. package/docs/api-reference.md +916 -0
  7. package/docs/broken-functionality-tracker.md +285 -0
  8. package/docs/bundling-system-deep-dive.md +525 -0
  9. package/docs/cli-reference.md +393 -0
  10. package/docs/comprehensive-documentation.md +1403 -0
  11. package/docs/configuration-reference.md +808 -0
  12. package/docs/controls-development.md +859 -0
  13. package/docs/documentation-review/CURRENT_REVIEW.md +95 -0
  14. package/docs/function-publishers-json-apis.md +847 -0
  15. package/docs/getting-started-with-json.md +518 -0
  16. package/docs/minification-compression-sourcemaps-status.md +482 -0
  17. package/docs/minification-compression-sourcemaps-test-results.md +205 -0
  18. package/docs/publishers-guide.md +313 -0
  19. package/docs/resources-guide.md +615 -0
  20. package/docs/serve-helpers.md +406 -0
  21. package/docs/simple-server-api-design.md +13 -0
  22. package/docs/system-architecture.md +275 -0
  23. package/docs/troubleshooting.md +698 -0
  24. package/examples/json/README.md +115 -0
  25. package/examples/json/basic-api/README.md +345 -0
  26. package/examples/json/basic-api/server.js +199 -0
  27. package/examples/json/simple-api/README.md +125 -0
  28. package/examples/json/simple-api/diagnostic-report.json +73 -0
  29. package/examples/json/simple-api/diagnostic-test.js +433 -0
  30. package/examples/json/simple-api/server-debug.md +58 -0
  31. package/examples/json/simple-api/server.js +91 -0
  32. package/examples/json/simple-api/test.js +215 -0
  33. package/http/responders/static/Static_Route_HTTP_Responder.js +1 -2
  34. package/package.json +19 -8
  35. package/publishers/helpers/assigners/static-compressed-response-buffers/Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner.js +65 -12
  36. package/publishers/helpers/preparers/static/bundle/Static_Routes_Responses_Webpage_Bundle_Preparer.js +6 -1
  37. package/publishers/http-function-publisher.js +59 -38
  38. package/publishers/http-webpage-publisher.js +48 -1
  39. package/resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild.js +38 -146
  40. package/resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild.js +54 -5
  41. package/resources/processors/bundlers/js/esbuild/Core_JS_Single_File_Minifying_Bundler_Using_ESBuild.js +36 -4
  42. package/serve-factory.js +36 -9
  43. package/server.js +10 -4
  44. package/test-report.json +0 -0
  45. package/tests/README.md +250 -0
  46. package/tests/assigners.test.js +316 -0
  47. package/tests/bundlers.test.js +329 -0
  48. package/tests/configuration-validation.test.js +530 -0
  49. package/tests/content-analysis.test.js +641 -0
  50. package/tests/end-to-end.test.js +496 -0
  51. package/tests/error-handling.test.js +746 -0
  52. package/tests/performance.test.js +653 -0
  53. package/tests/publishers.test.js +395 -0
  54. package/tests/temp_invalid.js +7 -0
  55. package/tests/temp_invalid_utf8.js +1 -0
  56. package/tests/temp_malformed.js +10 -0
  57. package/tests/test-runner.js +261 -0
@@ -0,0 +1,386 @@
1
+ # Agent Development Guide for JSGUI3 Server
2
+
3
+ ## When to Read
4
+
5
+ This document is specifically for AI agents working on the JSGUI3 Server codebase. Read this when:
6
+ - You're an AI agent tasked with maintaining or extending JSGUI3 Server
7
+ - You need to understand the codebase structure and development patterns
8
+ - You want to know what still needs to be implemented
9
+ - You discover broken functionality that needs documentation
10
+ - You need guidance on how to contribute to this project
11
+
12
+ **Note:** This is the central place to document broken functionality and implementation gaps. If you find something broken or incomplete, document it here immediately.
13
+
14
+ ## Agent Responsibilities
15
+
16
+ ### Documentation Maintenance
17
+ - **Document broken functionality** in the "Known Issues" section below
18
+ - **Update implementation status** as you complete tasks
19
+ - **Add new findings** from code analysis to relevant sections
20
+ - **Keep this guide current** with the evolving codebase
21
+
22
+ ### Code Quality Standards
23
+ - Use `snake_case` for variables, functions, and utilities
24
+ - Use `PascalCase` for classes and constructors
25
+ - Follow existing patterns for control creation and lifecycle
26
+ - Include comprehensive error handling and logging
27
+ - Add JSDoc comments for public APIs
28
+
29
+ ### Development Workflow
30
+ 1. **Analyze the task** and understand requirements
31
+ 2. **Check existing code** for patterns and conventions
32
+ 3. **Implement changes** following established patterns
33
+ 4. **Test thoroughly** and document any issues found
34
+ 5. **Update documentation** including this guide
35
+
36
+ ## Codebase Structure Overview
37
+
38
+ ### Core Architecture
39
+
40
+ ```
41
+ jsgui3-server/
42
+ ├── server.js # Main server class (JSGUI_Single_Process_Server)
43
+ ├── serve-factory.js # Server.serve() API factory
44
+ ├── cli.js # Command-line interface
45
+ ├── page-context.js # Server-side page context
46
+ ├── static-page-context.js # Static rendering context
47
+ ├── controls/ # UI control classes
48
+ ├── publishers/ # HTTP content publishers
49
+ ├── resources/ # Data resource abstractions
50
+ ├── website/ # Website and webpage abstractions
51
+ └── docs/ # Documentation
52
+ ```
53
+
54
+ ### Key Components
55
+
56
+ #### Server Core (`server.js`)
57
+ - **JSGUI_Single_Process_Server**: Main server class extending Evented_Class
58
+ - **Resource Pool**: Manages server resources (Local_Server_Info, Router)
59
+ - **Router**: Routes HTTP requests to appropriate handlers
60
+ - **Publisher System**: Handles different content types (HTML, JS, CSS, API)
61
+
62
+ #### Serve Factory (`serve-factory.js`)
63
+ - **Server.serve() API**: Simplified server startup interface
64
+ - **Auto-discovery**: Finds client.js and control constructors automatically
65
+ - **Configuration merging**: Combines programmatic and environment config
66
+ - **Promise-based**: Modern async/await compatible
67
+
68
+ #### Publishers
69
+ - **HTTP_Webpage_Publisher**: Serves bundled controls as complete web pages
70
+ - **HTTP_Website_Publisher**: Serves multi-page websites
71
+ - **HTTP_Function_Publisher**: Handles API endpoints
72
+ - **HTTP_Webpageorsite_Publisher**: Base class for webpage/website publishers
73
+
74
+ #### Resources
75
+ - **Server_Resource_Pool**: Container for all server resources
76
+ - **Local_Server_Info**: Provides network interface and system information
77
+ - **Website_Resource**: Wraps website objects for serving
78
+
79
+ ## Implementation Status
80
+
81
+ ### ✅ Completed Features
82
+
83
+ #### Server API
84
+ - [x] `Server.serve()` simplified API with auto-discovery
85
+ - [x] Environment variable support (PORT, HOST, JSGUI_DEBUG)
86
+ - [x] Promise-based server startup
87
+ - [x] Multi-page application support
88
+ - [x] API endpoint publishing
89
+ - [x] Static file serving
90
+
91
+ #### CLI Interface
92
+ - [x] Basic CLI in `cli.js` with serve command
93
+ - [x] Port and host options
94
+ - [x] Environment variable integration
95
+ - [x] Help and version commands
96
+
97
+ #### Bundling System
98
+ - [x] ESBuild integration for JavaScript bundling
99
+ - [x] CSS extraction from control classes
100
+ - [x] Debug vs production bundling modes
101
+ - [x] Source map generation
102
+
103
+ #### Control System
104
+ - [x] Active_HTML_Document base class
105
+ - [x] Control lifecycle (constructor → activate)
106
+ - [x] Data binding with observable models
107
+ - [x] CSS as static properties
108
+
109
+ ### 🚧 In Progress / Partially Complete
110
+
111
+ #### Website Publisher
112
+ - [x] Basic HTTP_Website_Publisher class exists
113
+ - [ ] Website publishing code may be incomplete (see "Possibly missing website publishing code" comment)
114
+ - [ ] Multi-page website serving needs verification
115
+
116
+ #### Admin Interface
117
+ - [x] Basic admin controls exist (Web_Admin_Page_Control, Web_Admin_Panel_Control)
118
+ - [ ] Default admin interface at `/admin` not fully implemented
119
+ - [ ] Admin routes not automatically configured
120
+
121
+ #### File Manager
122
+ - [ ] File manager interface planned but not implemented
123
+ - [ ] File system resource exists but no UI
124
+
125
+ ### ❌ Known Issues and Broken Functionality
126
+
127
+ #### Critical Issues
128
+ 1. **Website Publisher Incomplete**
129
+ - **Location**: `publishers/http-website-publisher.js`
130
+ - **Issue**: Contains comment "Possibly missing website publishing code"
131
+ - **Impact**: Multi-page websites may not work correctly
132
+ - **Status**: Needs investigation and completion
133
+
134
+ 2. **Server Ready Signal**
135
+ - **Location**: `server.js` start() method
136
+ - **Issue**: Multiple "ready" events emitted, unclear when server is truly ready
137
+ - **Impact**: Race conditions in startup, unclear status reporting
138
+ - **Status**: Needs consolidation to single clear ready signal
139
+
140
+ 3. **Default Holding Page**
141
+ - **Location**: Server startup logic
142
+ - **Issue**: No default page served when no content configured
143
+ - **Impact**: Server fails to start or serves errors when misconfigured
144
+ - **Status**: TODO item exists but not implemented
145
+
146
+ #### Moderate Issues
147
+ 4. **Admin Route Not Available**
148
+ - **Location**: Server startup and routing
149
+ - **Issue**: `/admin` route not automatically configured
150
+ - **Impact**: No default admin interface accessible
151
+ - **Status**: Admin controls exist but not wired up
152
+
153
+ 5. **Bundle Path Issues**
154
+ - **Location**: Various bundling code
155
+ - **Issue**: Legacy bundle paths and dead code (NYI markers)
156
+ - **Impact**: CSS bundling may be unreliable
157
+ - **Status**: Needs cleanup and consolidation
158
+
159
+ 6. **Error Handling Inconsistent**
160
+ - **Location**: Throughout codebase
161
+ - **Issue**: Mix of callback and promise patterns, some errors not properly propagated
162
+ - **Impact**: Unclear error reporting and debugging difficulties
163
+ - **Status**: Needs standardization
164
+
165
+ #### Minor Issues
166
+ 7. **Obsolete Code**
167
+ - **Location**: `website/website.js` contains `Obselete_Style_Website` class
168
+ - **Issue**: Dead code not removed
169
+ - **Impact**: Codebase confusion
170
+ - **Status**: Should be cleaned up
171
+
172
+ 8. **Inconsistent Naming**
173
+ - **Location**: Various files
174
+ - **Issue**: Mix of `src_path_client_js`, `disk_path_client_js`, `source_path_client_js`
175
+ - **Impact**: API confusion
176
+ - **Status**: Should standardize on single naming convention
177
+
178
+ ## Implementation Gaps (TODO Items)
179
+
180
+ ### High Priority
181
+ 1. **Complete Website Publisher**
182
+ - Investigate and fix website publishing code
183
+ - Ensure multi-page websites work correctly
184
+ - Add comprehensive tests
185
+
186
+ 2. **Default Admin Interface**
187
+ - Wire up `/admin` route by default
188
+ - Create basic status panel showing server info
189
+ - Add resource pool summary
190
+
191
+ 3. **Server Ready Signal Consolidation**
192
+ - Emit single clear "Server ready" message
193
+ - Ensure all publishers are ready before signaling
194
+ - Update CLI to wait for proper ready signal
195
+
196
+ 4. **Default Holding Page**
197
+ - Serve simple HTML when no content configured
198
+ - Include helpful getting started information
199
+ - Allow configuration override
200
+
201
+ ### Medium Priority
202
+ 5. **File Manager Interface**
203
+ - Create admin UI for browsing/serving directories
204
+ - Integrate with file system resource
205
+ - Add upload/download capabilities
206
+
207
+ 6. **CSS Bundling Cleanup**
208
+ - Remove legacy bundle paths
209
+ - Consolidate CSS extraction logic
210
+ - Ensure reliable CSS bundling
211
+
212
+ 7. **Configuration File Support**
213
+ - Add `jsgui.config.js` support
214
+ - Implement `--config` CLI option
215
+ - Document configuration patterns
216
+
217
+ 8. **Graceful Shutdown**
218
+ - Handle SIGINT/SIGTERM signals
219
+ - Clean up resources properly
220
+ - Print shutdown confirmation
221
+
222
+ ### Low Priority
223
+ 9. **Watch/Dev Mode**
224
+ - Add file watching for automatic restarts
225
+ - Implement `node cli.js dev` command
226
+ - Add hot reload for development
227
+
228
+ 10. **Enhanced Logging**
229
+ - Add configurable log levels
230
+ - Implement `--verbose` and `--quiet` options
231
+ - Add structured logging output
232
+
233
+ ## Development Patterns
234
+
235
+ ### Control Creation Pattern
236
+ ```javascript
237
+ class MyControl extends Active_HTML_Document {
238
+ constructor(spec = {}) {
239
+ spec.__type_name = spec.__type_name || 'my_control';
240
+ super(spec);
241
+ const { context } = this;
242
+
243
+ // Defensive programming
244
+ if (typeof this.body.add_class === 'function') {
245
+ this.body.add_class('my-control');
246
+ }
247
+
248
+ const compose = () => {
249
+ // UI composition logic here
250
+ };
251
+
252
+ if (!spec.el) { compose(); }
253
+ }
254
+
255
+ activate() {
256
+ if (!this.__active) {
257
+ super.activate();
258
+ const { context } = this;
259
+ // Activation logic here
260
+ }
261
+ }
262
+ }
263
+
264
+ MyControl.css = `/* CSS styles */`;
265
+ ```
266
+
267
+ ### Publisher Creation Pattern
268
+ ```javascript
269
+ class CustomPublisher extends HTTP_Publisher {
270
+ constructor(spec = {}) {
271
+ super(spec);
272
+ // Publisher-specific initialization
273
+ }
274
+
275
+ async serve(request, response) {
276
+ // Custom serving logic
277
+ // Return appropriate response
278
+ }
279
+ }
280
+ ```
281
+
282
+ ### Resource Creation Pattern
283
+ ```javascript
284
+ class CustomResource extends Resource {
285
+ constructor(spec = {}) {
286
+ super(spec);
287
+ // Resource-specific initialization
288
+ }
289
+
290
+ async get(path) {
291
+ // Implement data retrieval
292
+ }
293
+
294
+ async put(path, data) {
295
+ // Implement data storage
296
+ }
297
+ }
298
+ ```
299
+
300
+ ## Testing Guidelines
301
+
302
+ ### Unit Tests
303
+ - Test control logic without DOM
304
+ - Test resource operations
305
+ - Test publisher responses
306
+ - Use minimal dependencies
307
+
308
+ ### Integration Tests
309
+ - Test server startup and shutdown
310
+ - Test API endpoints
311
+ - Test static file serving
312
+ - Test multi-page applications
313
+
314
+ ### CLI Tests
315
+ - Test command-line options
316
+ - Test environment variable handling
317
+ - Test error conditions
318
+ - Use child_process for testing
319
+
320
+ ## Code Analysis Findings
321
+
322
+ ### Architecture Insights
323
+ - **Event-Driven Design**: Heavy use of Evented_Class and observable patterns
324
+ - **Resource Pool Pattern**: Centralized resource management
325
+ - **Publisher Abstraction**: Clean separation of content types
326
+ - **Context System**: Runtime environment management
327
+
328
+ ### Complexity Areas
329
+ - **Bundling System**: Multi-stage CSS/JS processing
330
+ - **Routing Logic**: Complex route resolution and publisher selection
331
+ - **Lifecycle Management**: Control activation and resource cleanup
332
+ - **Configuration Resolution**: Multiple source merging with precedence
333
+
334
+ ### Quality Issues Found
335
+ - **Inconsistent Error Handling**: Mix of callbacks, promises, and events
336
+ - **Dead Code**: Obsolete classes and unused imports
337
+ - **Naming Inconsistencies**: Multiple ways to specify same concept
338
+ - **Documentation Gaps**: Many internal APIs undocumented
339
+
340
+ ## Contribution Guidelines
341
+
342
+ ### Before Starting Work
343
+ 1. Check this guide for known issues
344
+ 2. Review TODO.md for current priorities
345
+ 3. Understand existing patterns and conventions
346
+ 4. Check if feature already exists partially
347
+
348
+ ### During Development
349
+ 1. Follow established naming conventions
350
+ 2. Add comprehensive error handling
351
+ 3. Include logging for debugging
352
+ 4. Test thoroughly before committing
353
+
354
+ ### After Completion
355
+ 1. Update this guide with any new findings
356
+ 2. Document broken functionality discovered
357
+ 3. Update implementation status
358
+ 4. Add examples and usage patterns
359
+
360
+ ### Code Review Checklist
361
+ - [ ] Follows naming conventions (snake_case vs PascalCase)
362
+ - [ ] Includes proper error handling
363
+ - [ ] Has comprehensive logging
364
+ - [ ] Follows existing patterns
365
+ - [ ] Includes tests
366
+ - [ ] Updates documentation
367
+ - [ ] No dead code or unused imports
368
+
369
+ ## Emergency Contacts
370
+
371
+ If you discover critical issues:
372
+ 1. Document them immediately in "Known Issues" section above
373
+ 2. Mark with appropriate severity level
374
+ 3. Note impact and potential workarounds
375
+ 4. Flag for immediate attention
376
+
377
+ ## Version History
378
+
379
+ - **v0.0.138**: Server.serve() API, enhanced CLI
380
+ - **v0.0.137**: Publisher system improvements
381
+ - **v0.0.136**: API endpoint enhancements
382
+ - **Current**: Multiple known issues documented, implementation gaps identified
383
+
384
+ ---
385
+
386
+ **Remember**: This guide is the central place for agents to document broken functionality and implementation gaps. If you find something broken or incomplete, document it here immediately with details about location, impact, and status.