jsgui3-server 0.0.147 → 0.0.149

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 (145) hide show
  1. package/.github/workflows/control-scan-manifest-check.yml +31 -0
  2. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-071799b982906680f5fd699d.js +40 -0
  3. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-07352945ad5c92654fcb8b65.js +39 -0
  4. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-138a601fadb6191ea314c6fd.js +39 -0
  5. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-171f6c381c2cadf2e9fa7087.js +39 -0
  6. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-1d973388156b84a04373fac9.js +39 -0
  7. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-20e117bc8a10d2cd16234bbe.js +40 -0
  8. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-2b028a82b0e5efddba42425f.js +39 -0
  9. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-4518556cd5c7e059e82b22b8.js +40 -0
  10. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-5bac1aa0f213902f718ed74f.js +40 -0
  11. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-5f9996ac7822caf777d92f56.js +39 -0
  12. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-60a92c702e65fd9cf748e3ec.js +39 -0
  13. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-6164c1f8f738995c541895d2.js +44 -0
  14. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-6718a85eb9e5aa782dd47a05.js +45 -0
  15. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-69e280f14e37aee76a1d4675.js +39 -0
  16. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-7570d1b030d44b111ed59c4c.js +39 -0
  17. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-7798c9bbd55e510d5039f936.js +42 -0
  18. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-78cd511ea1ef18ecb03d1be5.js +40 -0
  19. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-7d482e0b95bcb5e3c543118b.js +43 -0
  20. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-80e9476d1127c55b40fdb36f.js +40 -0
  21. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-810ced55d5320a3088a05b13.js +40 -0
  22. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-8423565f1a40e329afc8c6cf.js +40 -0
  23. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-900bef783b8cee36506ec282.js +39 -0
  24. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-a1a37aff6416fdad74040ddf.js +39 -0
  25. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-ad48d5e8eda40f175b4df090.js +39 -0
  26. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-aec5a2d963015528c9099462.js +39 -0
  27. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-af9d34e0f1722fab9e28c269.js +39 -0
  28. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-b818e4015e2f1fe86280b5ab.js +41 -0
  29. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-bcb2541adc70b7aba61768c5.js +44 -0
  30. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-bfe89d2c78ed44f95ed7dd73.js +40 -0
  31. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-c06f04806a1e688e1187110c.js +40 -0
  32. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-c3f3adf904f585afc544b96a.js +39 -0
  33. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-d45acb873e1d8e32d5e60f2e.js +39 -0
  34. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-db06f132533706f4a0163b8c.js +39 -0
  35. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-f660f40d78b135fc8560a862.js +39 -0
  36. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-f9dee4ec18a96e09bee06bae.js +39 -0
  37. package/README.md +85 -3
  38. package/admin-ui/client.js +213 -0
  39. package/admin-ui/server.js +104 -0
  40. package/client/controls/auto-observable.js +207 -0
  41. package/dev-status.svg +139 -0
  42. package/docs/api-reference.md +301 -43
  43. package/docs/books/admin-ui/01-introduction.md +32 -0
  44. package/docs/books/admin-ui/02-architecture.md +92 -0
  45. package/docs/books/admin-ui/03-controls.md +194 -0
  46. package/docs/books/admin-ui/04-implementation-plan.md +62 -0
  47. package/docs/books/admin-ui/README.md +26 -0
  48. package/docs/books/jsgui3-bundling-research-book/00-table-of-contents.md +35 -0
  49. package/docs/books/jsgui3-bundling-research-book/01-pipeline-and-runtime-semantics.md +34 -0
  50. package/docs/books/jsgui3-bundling-research-book/02-javascript-bundling-core.md +36 -0
  51. package/docs/books/jsgui3-bundling-research-book/03-style-extraction-and-css-compilation.md +35 -0
  52. package/docs/books/jsgui3-bundling-research-book/04-static-publishing-and-delivery.md +39 -0
  53. package/docs/books/jsgui3-bundling-research-book/05-current-limits-and-size-bloat-vectors.md +25 -0
  54. package/docs/books/jsgui3-bundling-research-book/06-unused-module-elimination-strategy.md +77 -0
  55. package/docs/books/jsgui3-bundling-research-book/07-jsgui3-html-control-and-mixin-pruning.md +63 -0
  56. package/docs/books/jsgui3-bundling-research-book/08-test-and-verification-methodology.md +43 -0
  57. package/docs/books/jsgui3-bundling-research-book/09-roadmap-and-rollout.md +42 -0
  58. package/docs/books/jsgui3-bundling-research-book/10-further-research-strategies-and-upgrades.md +211 -0
  59. package/docs/books/jsgui3-bundling-research-book/README.md +35 -0
  60. package/docs/bundling-system-deep-dive.md +9 -4
  61. package/docs/comprehensive-documentation.md +49 -18
  62. package/docs/configuration-reference.md +152 -27
  63. package/docs/core/README.md +19 -0
  64. package/docs/core/jsgui3-server-core-book/00-table-of-contents.md +21 -0
  65. package/docs/core/jsgui3-server-core-book/01-startup-readiness-state-machine.md +41 -0
  66. package/docs/core/jsgui3-server-core-book/02-resource-abstraction-and-lifecycle.md +92 -0
  67. package/docs/core/jsgui3-server-core-book/03-resource-pool-and-event-topology.md +47 -0
  68. package/docs/core/jsgui3-server-core-book/04-sse-publisher-semantics.md +41 -0
  69. package/docs/core/jsgui3-server-core-book/05-serve-factory-resource-wiring.md +46 -0
  70. package/docs/core/jsgui3-server-core-book/06-e2e-testing-methodology.md +48 -0
  71. package/docs/core/jsgui3-server-core-book/07-defect-detection-and-hardening-loop.md +47 -0
  72. package/docs/publishers-guide.md +59 -4
  73. package/docs/resources-guide.md +184 -35
  74. package/docs/simple-server-api-design.md +72 -17
  75. package/docs/system-architecture.md +18 -14
  76. package/examples/controls/15) window, observable SSE/server.js +6 -1
  77. package/examples/controls/19) window, auto observable ui/client.js +125 -0
  78. package/examples/controls/19) window, auto observable ui/server.js +73 -0
  79. package/examples/controls/20) window, task manager app/README.md +133 -0
  80. package/examples/controls/20) window, task manager app/client.js +797 -0
  81. package/examples/controls/20) window, task manager app/server.js +178 -0
  82. package/examples/controls/6) window, color_palette/client.js +165 -68
  83. package/examples/controls/9) window, date picker/client.js +362 -76
  84. package/examples/controls/9b) window, shared data.model mirrored date pickers/client.js +104 -83
  85. package/examples/jsgui3-html/06) theming/client.js +22 -1
  86. package/examples/jsgui3-html/10) binding-debugger/client.js +137 -1
  87. package/http/responders/static/Static_Route_HTTP_Responder.js +52 -34
  88. package/lab/experiments/capture-color-controls.js +196 -0
  89. package/lab/results/screenshots/color-controls/full_page.png +0 -0
  90. package/lab/results/screenshots/color-controls/section_1_color_grid_12x12.png +0 -0
  91. package/lab/results/screenshots/color-controls/section_2_color_grid_4x2.png +0 -0
  92. package/lab/results/screenshots/color-controls/section_3_color_palette.png +0 -0
  93. package/lab/results/screenshots/color-controls/section_4_palette_comparison.png +0 -0
  94. package/lab/results/screenshots/color-controls/section_5_raw_swatches.png +0 -0
  95. package/lab/results/screenshots/color-controls/section_6_optimized_crayola.png +0 -0
  96. package/lab/results/screenshots/color-controls/section_7_pastel_palette.png +0 -0
  97. package/lab/results/screenshots/color-controls/section_8_extended_144.png +0 -0
  98. package/lab/screenshot-utils.js +248 -0
  99. package/module.js +11 -4
  100. package/package.json +14 -4
  101. package/publishers/Publishers.js +4 -3
  102. package/publishers/helpers/assigners/static-compressed-response-buffers/Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner.js +5 -5
  103. package/publishers/http-observable-publisher.js +8 -0
  104. package/publishers/http-sse-publisher.js +341 -0
  105. package/publishers/http-webpage-publisher.js +13 -3
  106. package/publishers/http-webpageorsite-publisher.js +18 -0
  107. package/resources/process-resource.js +950 -0
  108. package/resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild.js +164 -46
  109. package/resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild.js +18 -7
  110. package/resources/processors/bundlers/js/esbuild/JSGUI3_HTML_Control_Optimizer.js +829 -0
  111. package/resources/remote-process-resource.js +355 -0
  112. package/resources/server-resource-pool.js +354 -41
  113. package/serve-factory.js +441 -259
  114. package/server.js +161 -16
  115. package/tests/README.md +66 -4
  116. package/tests/admin-ui-render.test.js +24 -0
  117. package/tests/assigners.test.js +56 -40
  118. package/tests/bundling-default-control-elimination.puppeteer.test.js +260 -0
  119. package/tests/configuration-validation.test.js +21 -18
  120. package/tests/content-analysis.test.js +7 -6
  121. package/tests/control-optimizer-cache-behavior.test.js +52 -0
  122. package/tests/control-scan-manifest-regression.test.js +144 -0
  123. package/tests/end-to-end.test.js +15 -14
  124. package/tests/error-handling.test.js +222 -179
  125. package/tests/fixtures/bundling-default-button-client.js +37 -0
  126. package/tests/fixtures/bundling-default-window-client.js +34 -0
  127. package/tests/fixtures/control_scan_manifest_expectations.json +48 -0
  128. package/tests/fixtures/resource-monitor-client.js +319 -0
  129. package/tests/helpers/puppeteer-e2e-harness.js +317 -0
  130. package/tests/http-sse-publisher.test.js +136 -0
  131. package/tests/performance.test.js +69 -65
  132. package/tests/process-resource.test.js +138 -0
  133. package/tests/publishers.test.js +7 -7
  134. package/tests/remote-process-resource.test.js +160 -0
  135. package/tests/sass-controls.e2e.test.js +7 -1
  136. package/tests/serve-resources.test.js +270 -0
  137. package/tests/serve.test.js +120 -50
  138. package/tests/server-resource-pool.test.js +106 -0
  139. package/tests/small-controls-bundle-size.test.js +252 -0
  140. package/tests/test-runner.js +13 -1
  141. package/tests/window-examples.puppeteer.test.js +204 -1
  142. package/tests/window-resource-integration.puppeteer.test.js +585 -0
  143. package/tests/temp_invalid.js +0 -7
  144. package/tests/temp_invalid_utf8.js +0 -1
  145. package/tests/temp_malformed.js +0 -10
@@ -32,13 +32,30 @@ Server.serve(options?: ServerOptions): Promise<Server>
32
32
  - `DiscoveryError`: Cannot find client files or controls
33
33
  - `BindingError`: Cannot bind to specified host/port
34
34
 
35
- **Example:**
36
- ```javascript
37
- const server = await Server.serve({
38
- port: 3000,
39
- ctrl: MyControl
40
- });
41
- ```
35
+ **Example:**
36
+ ```javascript
37
+ const server = await Server.serve({
38
+ port: 3000,
39
+ ctrl: MyControl,
40
+ resources: {
41
+ worker_direct: {
42
+ type: 'process',
43
+ command: process.execPath,
44
+ args: ['worker.js']
45
+ },
46
+ remote_worker: {
47
+ type: 'remote',
48
+ host: '127.0.0.1',
49
+ port: 3400
50
+ }
51
+ },
52
+ events: true
53
+ });
54
+ ```
55
+
56
+ **Serve-specific options:**
57
+ - `resources`: Registers managed resources (in-process resource objects, local process resources, remote HTTP process resources).
58
+ - `events`: Enables built-in SSE publisher for resource lifecycle events (`/events` by default).
42
59
 
43
60
  ### Server Constructor
44
61
 
@@ -54,12 +71,27 @@ new Server(options?: ServerOptions)
54
71
 
55
72
  **Returns:** Server instance
56
73
 
57
- **Events:**
58
- - `'ready'`: Emitted when bundling is complete
59
- - `'started'`: Emitted when HTTP server is listening
60
- - `'error'`: Emitted on server errors
61
-
62
- ## Server Instance Methods
74
+ **Events:**
75
+ - `'ready'`: Emitted when bundling is complete
76
+ - `'started'`: Emitted when HTTP server is listening
77
+ - `'error'`: Emitted on server errors
78
+
79
+ ### Module Exports
80
+
81
+ ```javascript
82
+ const jsgui = require('jsgui3-server');
83
+
84
+ // Top-level exports
85
+ jsgui.Process_Resource;
86
+ jsgui.Remote_Process_Resource;
87
+ jsgui.HTTP_SSE_Publisher;
88
+
89
+ // Resource namespace aliases
90
+ jsgui.Resource.Process;
91
+ jsgui.Resource.Remote_Process;
92
+ ```
93
+
94
+ ## Server Instance Methods
63
95
 
64
96
  ### server.start(port, callback)
65
97
 
@@ -74,7 +106,7 @@ server.start(port?: number, callback?: (err?: Error) => void): void
74
106
  - `port` (number, optional): Port to listen on (default: 8080)
75
107
  - `callback` (function, optional): Called when server starts or fails
76
108
 
77
- ### server.publish(route, handler)
109
+ ### server.publish(route, handler)
78
110
 
79
111
  Adds an API endpoint (legacy API).
80
112
 
@@ -83,13 +115,45 @@ Adds an API endpoint (legacy API).
83
115
  server.publish(route: string, handler: Function): void
84
116
  ```
85
117
 
86
- **Parameters:**
87
- - `route` (string): Route path (automatically prefixed with `/api/`)
88
- - `handler` (Function): Request handler function
89
-
90
- ### server.use(middleware)
91
-
92
- Adds middleware to the server.
118
+ **Parameters:**
119
+ - `route` (string): Route path (automatically prefixed with `/api/`)
120
+ - `handler` (Function): Request handler function
121
+
122
+ ### server.publish_observable(route, observable, options)
123
+
124
+ Adds an observable-backed SSE endpoint.
125
+
126
+ **Signature:**
127
+ ```javascript
128
+ server.publish_observable(route: string, observable: Observable, options?: object): HTTP_Observable_Publisher
129
+ ```
130
+
131
+ **Parameters:**
132
+ - `route` (string): Route path. If it does not start with `/`, it is prefixed with `/api/`.
133
+ - `observable` (Observable): Source observable stream.
134
+ - `options` (object, optional): Publisher options.
135
+
136
+ **Returns:** `HTTP_Observable_Publisher` instance.
137
+
138
+ **Alias:** `server.publishObservable(route, observable, options)`
139
+
140
+ ### server.close(callback)
141
+
142
+ Stops managed resources and closes all bound HTTP servers.
143
+
144
+ **Signature:**
145
+ ```javascript
146
+ server.close(callback?: (err?: Error | null) => void): void
147
+ ```
148
+
149
+ **Behavior:**
150
+ - Calls `resource_pool.stop()` when available
151
+ - Stops `sse_publisher` when present
152
+ - Closes all HTTP listeners
153
+
154
+ ### server.use(middleware)
155
+
156
+ Adds middleware to the server.
93
157
 
94
158
  **Signature:**
95
159
  ```javascript
@@ -443,7 +507,7 @@ Serves CSS files.
443
507
  serve(request: IncomingMessage, response: ServerResponse): Promise<void>
444
508
  ```
445
509
 
446
- ### HTTP_API_Publisher
510
+ ### HTTP_API_Publisher
447
511
 
448
512
  Handles API endpoints.
449
513
 
@@ -461,13 +525,162 @@ new HTTP_API_Publisher(spec?: PublisherSpec)
461
525
  Handles API requests.
462
526
 
463
527
  **Signature:**
464
- ```javascript
465
- serve(request: IncomingMessage, response: ServerResponse): Promise<void>
466
- ```
467
-
468
- ## Resource Classes
469
-
470
- ### File_System_Resource
528
+ ```javascript
529
+ serve(request: IncomingMessage, response: ServerResponse): Promise<void>
530
+ ```
531
+
532
+ ### HTTP_SSE_Publisher
533
+
534
+ General-purpose SSE publisher for explicit event fan-out.
535
+
536
+ **Extends:** `HTTP_Publisher`
537
+
538
+ **Constructor:**
539
+ ```javascript
540
+ new HTTP_SSE_Publisher(spec?: {
541
+ name?: string,
542
+ keepaliveIntervalMs?: number,
543
+ maxClients?: number,
544
+ eventHistorySize?: number
545
+ })
546
+ ```
547
+
548
+ **Methods:**
549
+ - `handle_http(req, res)`
550
+ - `broadcast(event_name, data_value)`
551
+ - `send(client_id, event_name, data_value)`
552
+ - `stop(callback?)`
553
+
554
+ **Properties:**
555
+ - `client_count` (number)
556
+
557
+ ## Resource Classes
558
+
559
+ ### Process_Resource
560
+
561
+ Represents a local process as a resource with a unified lifecycle API.
562
+
563
+ **Extends:** `Resource`
564
+
565
+ **Constructor:**
566
+ ```javascript
567
+ new Process_Resource(spec?: {
568
+ name?: string,
569
+ command?: string,
570
+ args?: string[],
571
+ cwd?: string,
572
+ env?: object,
573
+ autoRestart?: boolean,
574
+ maxRestarts?: number,
575
+ processManager?: 'direct' | {
576
+ type: 'direct' | 'pm2',
577
+ pm2Path?: string,
578
+ ecosystem?: string
579
+ },
580
+ healthCheck?: {
581
+ type: 'http' | 'tcp' | 'custom',
582
+ url?: string,
583
+ host?: string,
584
+ port?: number,
585
+ fn?: Function,
586
+ intervalMs?: number,
587
+ timeoutMs?: number,
588
+ failuresBeforeUnhealthy?: number
589
+ }
590
+ })
591
+ ```
592
+
593
+ **Core Methods:**
594
+ - `start(callback?)`
595
+ - `stop(callback?)`
596
+ - `restart(callback?)`
597
+ - `get_abstract()`
598
+
599
+ **Status:**
600
+ ```javascript
601
+ {
602
+ state: 'stopped' | 'starting' | 'running' | 'stopping' | 'restarting' | 'crashed',
603
+ pid: number | null,
604
+ uptime: number,
605
+ restartCount: number,
606
+ lastHealthCheck: object | null,
607
+ memoryUsage: object | null,
608
+ processManager: { type: 'direct' | 'pm2' }
609
+ }
610
+ ```
611
+
612
+ **Events:**
613
+ - `state_change`
614
+ - `stdout`
615
+ - `stderr`
616
+ - `exit`
617
+ - `health_check`
618
+ - `unhealthy`
619
+ - `crashed`
620
+
621
+ ### Remote_Process_Resource
622
+
623
+ Represents a remote HTTP-controlled process using the same lifecycle-oriented API style as `Process_Resource`.
624
+
625
+ **Extends:** `Resource`
626
+
627
+ **Constructor:**
628
+ ```javascript
629
+ new Remote_Process_Resource(spec?: {
630
+ name?: string,
631
+ host: string,
632
+ port: number,
633
+ protocol?: 'http' | 'https',
634
+ pollIntervalMs?: number,
635
+ httpTimeoutMs?: number,
636
+ historySize?: number,
637
+ unreachableFailuresBeforeEvent?: number,
638
+ endpoints?: {
639
+ status?: string,
640
+ start?: string,
641
+ stop?: string,
642
+ health?: string
643
+ }
644
+ })
645
+ ```
646
+
647
+ **Core Methods:**
648
+ - `start(callback?)`
649
+ - `stop(callback?)`
650
+ - `restart(callback?)`
651
+ - `get_abstract()`
652
+
653
+ **Status:** Includes `state`, `pid`, `uptime`, `restartCount`, `lastHealthCheck`, `memoryUsage`, and `processManager: { type: 'remote' }`.
654
+
655
+ **Events:**
656
+ - `state_change`
657
+ - `unreachable`
658
+ - `recovered`
659
+
660
+ ### Server_Resource_Pool
661
+
662
+ Server-specific resource pool with lifecycle orchestration and event forwarding.
663
+
664
+ **Extends:** `Resource_Pool`
665
+
666
+ **Methods:**
667
+ - `add(resource)`
668
+ - `remove(name, callback?)`
669
+ - `start(callback?)`
670
+ - `stop(callback?)`
671
+ - `get_resources_by_type(type)`
672
+
673
+ **Properties:**
674
+ - `summary`: Aggregated state summary grouped by resource type.
675
+
676
+ **Forwarded Events:**
677
+ - `resource_state_change`
678
+ - `crashed`
679
+ - `unhealthy`
680
+ - `unreachable`
681
+ - `recovered`
682
+
683
+ ### File_System_Resource
471
684
 
472
685
  Provides access to local file system.
473
686
 
@@ -699,10 +912,10 @@ ensure_route_leading_slash(route: string): string
699
912
  ### ServerOptions
700
913
 
701
914
  ```typescript
702
- interface ServerOptions {
703
- ctrl?: Function;
704
- Ctrl?: Function;
705
- src_path_client_js?: string;
915
+ interface ServerOptions {
916
+ ctrl?: Function;
917
+ Ctrl?: Function;
918
+ src_path_client_js?: string;
706
919
  port?: number;
707
920
  host?: string;
708
921
  debug?: boolean;
@@ -715,15 +928,60 @@ interface ServerOptions {
715
928
  api?: Record<string, Function>;
716
929
  static?: Record<string, string>;
717
930
 
718
- // Advanced options
719
- cors?: CorsConfig;
720
- https?: HttpsConfig;
721
- middleware?: Function[];
722
- publishers?: Record<string, Publisher>;
723
- resources?: Record<string, Resource>;
724
- bundler?: BundlerConfig;
725
- }
726
- ```
931
+ // Advanced options
932
+ cors?: CorsConfig;
933
+ https?: HttpsConfig;
934
+ middleware?: Function[];
935
+ publishers?: Record<string, Publisher>;
936
+ resources?: ResourceEntries;
937
+ events?: boolean | EventsOptions;
938
+ bundler?: BundlerConfig;
939
+ }
940
+ ```
941
+
942
+ ```typescript
943
+ type ResourceEntries = Record<string, ResourceEntry> | ResourceEntry[];
944
+
945
+ type ResourceEntry =
946
+ | Resource
947
+ | {
948
+ type?: 'process' | 'local';
949
+ command?: string;
950
+ args?: string[];
951
+ processManager?: 'direct' | {
952
+ type?: 'direct' | 'pm2';
953
+ pm2Path?: string;
954
+ ecosystem?: string;
955
+ };
956
+ [key: string]: any;
957
+ }
958
+ | {
959
+ type?: 'remote' | 'http';
960
+ host?: string;
961
+ port?: number;
962
+ protocol?: 'http' | 'https';
963
+ endpoints?: Record<string, string>;
964
+ [key: string]: any;
965
+ }
966
+ | {
967
+ type?: 'resource' | 'in_process' | 'in-process';
968
+ instance?: Resource;
969
+ resource?: Resource;
970
+ class?: new (spec?: any) => Resource;
971
+ Ctor?: new (spec?: any) => Resource;
972
+ constructor_fn?: new (spec?: any) => Resource;
973
+ spec?: Record<string, any>;
974
+ [key: string]: any;
975
+ };
976
+
977
+ interface EventsOptions {
978
+ route?: string;
979
+ name?: string;
980
+ keepaliveIntervalMs?: number;
981
+ maxClients?: number;
982
+ eventHistorySize?: number;
983
+ }
984
+ ```
727
985
 
728
986
  ### PageConfig
729
987
 
@@ -1029,4 +1287,4 @@ const server = await Server.serve({
1029
1287
 
1030
1288
  ---
1031
1289
 
1032
- This API reference provides comprehensive technical documentation for JSGUI3 Server internals. For practical usage examples and tutorials, refer to the user-facing documentation.
1290
+ This API reference provides comprehensive technical documentation for JSGUI3 Server internals. For practical usage examples and tutorials, refer to the user-facing documentation.
@@ -0,0 +1,32 @@
1
+ # Chapter 1: Introduction
2
+
3
+ ## Vision
4
+
5
+ The Admin UI is the **go-to interface** for developers and operators to administer `jsgui3-server` instances. It should be:
6
+
7
+ - **Instantaneous**: Zero setup required; just navigate to `/admin`
8
+ - **Insightful**: Surface the internal state of the server in real-time
9
+ - **Actionable**: Allow common admin tasks directly from the UI
10
+
11
+ ## Goals
12
+
13
+ 1. **Visibility into Observables**: If a server publishes an observable (e.g., for crawl progress, metrics), the Admin UI should display it automatically with an appropriate control.
14
+ 2. **Resource Browser**: List all registered resources (routes, publishers, static paths) with introspection.
15
+ 3. **Configuration Panel**: View and modify server configuration (where safe).
16
+ 4. **Performance Metrics**: Display throughput, active connections, memory usage.
17
+
18
+ ## Inspiration
19
+
20
+ The design is inspired by:
21
+ - Database admin tools (pgAdmin, phpMyAdmin)
22
+ - Monitoring dashboards (Grafana, Kibana)
23
+ - The jsgui3 Window control aesthetic
24
+
25
+ ## Target Experience
26
+
27
+ A developer starts a jsgui3-server, then navigates to `http://localhost:PORT/admin`. They immediately see:
28
+ - A sidebar listing all resources
29
+ - A main panel showing the selected resource's details
30
+ - Real-time updates for any observables
31
+
32
+ No extra code required—the Admin UI is built into jsgui3-server and activates automatically.
@@ -0,0 +1,92 @@
1
+ # Chapter 2: Architecture
2
+
3
+ ## High-Level Overview
4
+
5
+ ```
6
+ ┌─────────────────────────────────────────────────────────────┐
7
+ │ jsgui3-server │
8
+ │ │
9
+ │ ┌──────────────────┐ ┌────────────────┐ │
10
+ │ │ Admin UI Module │◄──│ Server Router │ │
11
+ │ │ (admin-ui/) │ └───────┬────────┘ │
12
+ │ └────────┬─────────┘ │ │
13
+ │ │ ┌───────┴────────┐ │
14
+ │ ▼ │ Resource Pool │ │
15
+ │ ┌─────────────────┐ │ (resources/) │ │
16
+ │ │ Admin_Page │ └───────┬────────┘ │
17
+ │ │ (client.js) │ │ │
18
+ │ └────────┬────────┘ ┌───────┴────────┐ │
19
+ │ │ │ Publishers │ │
20
+ │ ▼ │ (observables) │ │
21
+ │ ┌─────────────────┐ └────────────────┘ │
22
+ │ │ Controls: │ │
23
+ │ │ - Resource_List │ │
24
+ │ │ - Observable_ │ │
25
+ │ │ Monitor │ │
26
+ │ │ - Config_Panel │ │
27
+ │ └─────────────────┘ │
28
+ └─────────────────────────────────────────────────────────────┘
29
+ ```
30
+
31
+ ## Module Structure
32
+
33
+ ```
34
+ admin-ui/
35
+ ├── client.js # Main client control (Admin_Page)
36
+ ├── server.js # API routes for admin data
37
+ ├── controls/ # UI components
38
+ │ ├── Resource_List.js
39
+ │ ├── Observable_Monitor.js
40
+ │ ├── Config_Panel.js
41
+ │ └── Metrics_Dashboard.js
42
+ └── styles/ # CSS modules
43
+ └── admin.css
44
+ ```
45
+
46
+ ## Key Patterns (from Window examples)
47
+
48
+ 1. **`client.js`** exports a jsgui module with controls registered on `jsgui.controls`
49
+ 2. **`server.js`** creates a `Server` instance, passes `Ctrl` and `src_path_client_js`
50
+ 3. Controls extend `Active_HTML_Document` for full-page apps
51
+ 4. CSS is defined as a static `.css` property on the control class
52
+ 5. `activate()` sets up client-side interactivity
53
+
54
+ ## Data Flow
55
+
56
+ 1. **Server Start** → Admin module registers `/admin` route
57
+ 2. **Client Request** → SSR renders Admin_Page with initial state
58
+ 3. **Activation** → Client connects to `/api/admin/resources` (SSE)
59
+ 4. **Updates** → Resource changes stream to client in real-time
60
+
61
+ ## Integration with `publish_observable`
62
+
63
+ The Admin UI leverages the schema-aware observable system:
64
+ - Server exposes `/api/admin/observables` listing all published observables
65
+ - Each observable has a schema describing its data type
66
+ - `Auto_Observable_UI` renders appropriate controls automatically
67
+
68
+ ## Server Lifecycle Events
69
+
70
+ The server emits two distinct lifecycle events:
71
+
72
+ | Event | Fired When | Use Case |
73
+ |-------|------------|----------|
74
+ | `ready` | Publishers/bundlers complete | Safe to call `server.start()`, publish routes |
75
+ | `listening` | HTTP server bound to ports | Server accepting connections |
76
+
77
+ **Example usage:**
78
+ ```javascript
79
+ server.on('ready', () => {
80
+ // Publish observables and set up routes
81
+ server.publish_observable('/api/data', myObservable);
82
+
83
+ // Now start accepting connections
84
+ server.start(port, (err) => {
85
+ console.log('Server running');
86
+ });
87
+ });
88
+
89
+ server.on('listening', () => {
90
+ console.log('Server accepting connections');
91
+ });
92
+ ```