jsgui3-server 0.0.148 → 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 (134) 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 +8 -8
  39. package/dev-status.svg +139 -0
  40. package/docs/api-reference.md +301 -43
  41. package/docs/books/jsgui3-bundling-research-book/00-table-of-contents.md +35 -0
  42. package/docs/books/jsgui3-bundling-research-book/01-pipeline-and-runtime-semantics.md +34 -0
  43. package/docs/books/jsgui3-bundling-research-book/02-javascript-bundling-core.md +36 -0
  44. package/docs/books/jsgui3-bundling-research-book/03-style-extraction-and-css-compilation.md +35 -0
  45. package/docs/books/jsgui3-bundling-research-book/04-static-publishing-and-delivery.md +39 -0
  46. package/docs/books/jsgui3-bundling-research-book/05-current-limits-and-size-bloat-vectors.md +25 -0
  47. package/docs/books/jsgui3-bundling-research-book/06-unused-module-elimination-strategy.md +77 -0
  48. package/docs/books/jsgui3-bundling-research-book/07-jsgui3-html-control-and-mixin-pruning.md +63 -0
  49. package/docs/books/jsgui3-bundling-research-book/08-test-and-verification-methodology.md +43 -0
  50. package/docs/books/jsgui3-bundling-research-book/09-roadmap-and-rollout.md +42 -0
  51. package/docs/books/jsgui3-bundling-research-book/10-further-research-strategies-and-upgrades.md +211 -0
  52. package/docs/books/jsgui3-bundling-research-book/README.md +35 -0
  53. package/docs/bundling-system-deep-dive.md +9 -4
  54. package/docs/comprehensive-documentation.md +49 -18
  55. package/docs/configuration-reference.md +152 -27
  56. package/docs/core/README.md +19 -0
  57. package/docs/core/jsgui3-server-core-book/00-table-of-contents.md +21 -0
  58. package/docs/core/jsgui3-server-core-book/01-startup-readiness-state-machine.md +41 -0
  59. package/docs/core/jsgui3-server-core-book/02-resource-abstraction-and-lifecycle.md +92 -0
  60. package/docs/core/jsgui3-server-core-book/03-resource-pool-and-event-topology.md +47 -0
  61. package/docs/core/jsgui3-server-core-book/04-sse-publisher-semantics.md +41 -0
  62. package/docs/core/jsgui3-server-core-book/05-serve-factory-resource-wiring.md +46 -0
  63. package/docs/core/jsgui3-server-core-book/06-e2e-testing-methodology.md +48 -0
  64. package/docs/core/jsgui3-server-core-book/07-defect-detection-and-hardening-loop.md +47 -0
  65. package/docs/publishers-guide.md +59 -4
  66. package/docs/resources-guide.md +184 -35
  67. package/docs/simple-server-api-design.md +72 -17
  68. package/docs/system-architecture.md +18 -14
  69. package/examples/controls/15) window, observable SSE/server.js +6 -1
  70. package/examples/controls/19) window, auto observable ui/server.js +9 -0
  71. package/examples/controls/20) window, task manager app/README.md +133 -0
  72. package/examples/controls/20) window, task manager app/client.js +797 -0
  73. package/examples/controls/20) window, task manager app/server.js +178 -0
  74. package/examples/controls/6) window, color_palette/client.js +165 -68
  75. package/examples/controls/9) window, date picker/client.js +362 -76
  76. package/examples/controls/9b) window, shared data.model mirrored date pickers/client.js +104 -83
  77. package/examples/jsgui3-html/06) theming/client.js +22 -1
  78. package/examples/jsgui3-html/10) binding-debugger/client.js +137 -1
  79. package/http/responders/static/Static_Route_HTTP_Responder.js +52 -34
  80. package/lab/experiments/capture-color-controls.js +196 -0
  81. package/lab/results/screenshots/color-controls/full_page.png +0 -0
  82. package/lab/results/screenshots/color-controls/section_1_color_grid_12x12.png +0 -0
  83. package/lab/results/screenshots/color-controls/section_2_color_grid_4x2.png +0 -0
  84. package/lab/results/screenshots/color-controls/section_3_color_palette.png +0 -0
  85. package/lab/results/screenshots/color-controls/section_4_palette_comparison.png +0 -0
  86. package/lab/results/screenshots/color-controls/section_5_raw_swatches.png +0 -0
  87. package/lab/results/screenshots/color-controls/section_6_optimized_crayola.png +0 -0
  88. package/lab/results/screenshots/color-controls/section_7_pastel_palette.png +0 -0
  89. package/lab/results/screenshots/color-controls/section_8_extended_144.png +0 -0
  90. package/lab/screenshot-utils.js +248 -0
  91. package/module.js +11 -4
  92. package/package.json +12 -2
  93. package/publishers/Publishers.js +4 -3
  94. package/publishers/helpers/assigners/static-compressed-response-buffers/Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner.js +5 -5
  95. package/publishers/http-sse-publisher.js +341 -0
  96. package/resources/process-resource.js +950 -0
  97. package/resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild.js +129 -33
  98. package/resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild.js +18 -7
  99. package/resources/processors/bundlers/js/esbuild/JSGUI3_HTML_Control_Optimizer.js +829 -0
  100. package/resources/remote-process-resource.js +355 -0
  101. package/resources/server-resource-pool.js +354 -41
  102. package/serve-factory.js +441 -259
  103. package/server.js +89 -13
  104. package/tests/README.md +66 -4
  105. package/tests/admin-ui-render.test.js +24 -0
  106. package/tests/assigners.test.js +56 -40
  107. package/tests/bundling-default-control-elimination.puppeteer.test.js +260 -0
  108. package/tests/configuration-validation.test.js +21 -18
  109. package/tests/content-analysis.test.js +7 -6
  110. package/tests/control-optimizer-cache-behavior.test.js +52 -0
  111. package/tests/control-scan-manifest-regression.test.js +144 -0
  112. package/tests/end-to-end.test.js +15 -14
  113. package/tests/error-handling.test.js +222 -179
  114. package/tests/fixtures/bundling-default-button-client.js +37 -0
  115. package/tests/fixtures/bundling-default-window-client.js +34 -0
  116. package/tests/fixtures/control_scan_manifest_expectations.json +48 -0
  117. package/tests/fixtures/resource-monitor-client.js +319 -0
  118. package/tests/helpers/puppeteer-e2e-harness.js +317 -0
  119. package/tests/http-sse-publisher.test.js +136 -0
  120. package/tests/performance.test.js +69 -65
  121. package/tests/process-resource.test.js +138 -0
  122. package/tests/publishers.test.js +7 -7
  123. package/tests/remote-process-resource.test.js +160 -0
  124. package/tests/sass-controls.e2e.test.js +7 -1
  125. package/tests/serve-resources.test.js +270 -0
  126. package/tests/serve.test.js +120 -50
  127. package/tests/server-resource-pool.test.js +106 -0
  128. package/tests/small-controls-bundle-size.test.js +252 -0
  129. package/tests/test-runner.js +13 -1
  130. package/tests/window-examples.puppeteer.test.js +204 -1
  131. package/tests/window-resource-integration.puppeteer.test.js +585 -0
  132. package/tests/temp_invalid.js +0 -7
  133. package/tests/temp_invalid_utf8.js +0 -1
  134. 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,35 @@
1
+ # 0. Table of Contents
2
+
3
+ ## Part I: What the Bundler Does Today
4
+
5
+ 1. [Pipeline and Runtime Semantics](01-pipeline-and-runtime-semantics.md)
6
+ 2. [JavaScript Bundling Core](02-javascript-bundling-core.md)
7
+ 3. [Style Extraction and CSS Compilation](03-style-extraction-and-css-compilation.md)
8
+ 4. [Static Publishing and Delivery](04-static-publishing-and-delivery.md)
9
+
10
+ ## Part II: Why Bundles Are Still Larger Than Needed
11
+
12
+ 5. [Current Limits and Size-Bloat Vectors](05-current-limits-and-size-bloat-vectors.md)
13
+
14
+ ## Part III: How to Get to Lightweight Bundles
15
+
16
+ 6. [Unused Module Elimination Strategy](06-unused-module-elimination-strategy.md)
17
+ 7. [jsgui3-html Control and Mixin Pruning](07-jsgui3-html-control-and-mixin-pruning.md)
18
+ 8. [Test and Verification Methodology](08-test-and-verification-methodology.md)
19
+ 9. [Roadmap and Rollout](09-roadmap-and-rollout.md)
20
+ 10. [Further Research: Strategies and Upgrades](10-further-research-strategies-and-upgrades.md)
21
+
22
+ ## Primary Code Surfaces Referenced
23
+
24
+ - `publishers/http-webpageorsite-publisher.js`
25
+ - `publishers/http-webpage-publisher.js`
26
+ - `publishers/helpers/preparers/static/bundle/Static_Routes_Responses_Webpage_Bundle_Preparer.js`
27
+ - `publishers/helpers/assigners/static-routes/Single_Control_Webpage_Server_Static_Routes_Assigner.js`
28
+ - `publishers/helpers/assigners/static-uncompressed-response-buffers/Single_Control_Webpage_Server_Static_Uncompressed_Response_Buffers_Assigner.js`
29
+ - `publishers/helpers/assigners/static-compressed-response-buffers/Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner.js`
30
+ - `publishers/helpers/assigners/static-headers/Single_Control_Webpage_Server_Static_Headers_Assigner.js`
31
+ - `resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild.js`
32
+ - `resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild.js`
33
+ - `resources/processors/bundlers/js/esbuild/Core_JS_Single_File_Minifying_Bundler_Using_ESBuild.js`
34
+ - `resources/processors/extractors/js/css_and_js/AST_Node/CSS_And_JS_From_JS_String_Using_AST_Node_Extractor.js`
35
+ - `resources/processors/bundlers/style-bundler.js`
@@ -0,0 +1,34 @@
1
+ # 1. Pipeline and Runtime Semantics
2
+
3
+ ## System Entry Point
4
+
5
+ For webpage/site publishing, the active bundling entry path is:
6
+
7
+ 1. `HTTP_Webpage_Publisher.get_ready()`
8
+ 2. `HTTP_Webpageorsite_Publisher.get_ready()`
9
+ 3. `JS_Bundler.bundle(src_path_client_js)`
10
+ 4. static route/response preparation
11
+
12
+ The concrete orchestrator is `publishers/http-webpageorsite-publisher.js`, which constructs `JS_Bundler` and awaits `js_bundler.bundle(...)`.
13
+
14
+ ## Bundle Payload Contract
15
+
16
+ The bundle object is `Bundle` (a `Collection`) from `resources/processors/bundlers/bundle.js`. Effective convention is:
17
+
18
+ - bundle array with one `Bundle` instance
19
+ - `Bundle._arr` containing items such as:
20
+ - `{ type: 'JavaScript', extension: 'js', text: '...' }`
21
+ - `{ type: 'CSS', extension: 'css', text: '...' }`
22
+ - `{ type: 'HTML', extension: 'html', text: '...' }` (added by webpage publisher)
23
+
24
+ This contract is implicit and shared by publishers/assigners.
25
+
26
+ ## Readiness and Failure Semantics
27
+
28
+ `HTTP_Webpage_Publisher` starts an async readiness flow in constructor and emits `'ready'` on success. On error, it emits `'error'` and then still emits `'ready'` with `{}` so upstream startup can continue.
29
+
30
+ `HTTP_Webpageorsite_Publisher.get_ready()` also has defensive fallback for missing `src_path_client_js`, returning placeholder JS/CSS text items.
31
+
32
+ ## Consequence
33
+
34
+ The current design prioritizes startup continuity over hard failure. This is operationally useful, but for strict production correctness a separate "fail-fast bundling" mode should exist.
@@ -0,0 +1,36 @@
1
+ # 2. JavaScript Bundling Core
2
+
3
+ ## Active JS Bundler Chain
4
+
5
+ `resources/processors/bundlers/js-bundler.js` exports `./js/JS_Bundler`, which exports `./esbuild/Advanced_JS_Bundler_Using_ESBuild`.
6
+
7
+ That advanced bundler composes two core stages:
8
+
9
+ 1. `Core_JS_Non_Minifying_Bundler_Using_ESBuild`
10
+ 2. `Core_JS_Single_File_Minifying_Bundler_Using_ESBuild` (production branch)
11
+
12
+ ## Stage A: Non-Minifying Bundle
13
+
14
+ `Core_JS_Non_Minifying_Bundler_Using_ESBuild` executes `esbuild.build` with:
15
+
16
+ - `bundle: true`
17
+ - `treeShaking: true`
18
+ - `write: false`
19
+ - optional sourcemap, controlled by `sourcemaps.enabled`, `debug`, and `includeInProduction`
20
+
21
+ It returns a one-item `Bundle` containing JavaScript text.
22
+
23
+ ## Stage B: Style-Assignment Removal
24
+
25
+ `Advanced_JS_Bundler_Using_ESBuild` parses the Stage A JS, extracts style assignments, and produces CSS-free JS text for a second JS pass.
26
+
27
+ ## Stage C: Debug/Production Split
28
+
29
+ - Debug path: re-bundle CSS-free JS without minification.
30
+ - Production path: re-bundle CSS-free JS, then run minifier bundler.
31
+
32
+ Minifier behavior is configurable by `bundler.minify` with levels `conservative | normal | aggressive` and option overrides.
33
+
34
+ ## Existing Optimization Character
35
+
36
+ The current model is "bundle then sanitize" rather than "module graph first with explicit retained-module manifest." It relies heavily on esbuild tree shaking plus post-bundle style extraction.
@@ -0,0 +1,35 @@
1
+ # 3. Style Extraction and CSS Compilation
2
+
3
+ ## Extraction Target
4
+
5
+ `CSS_And_JS_From_JS_String_Using_AST_Node_Extractor` scans bundled JS AST and finds assignment expressions where:
6
+
7
+ - left side is a member expression ending in `css`, `scss`, or `sass`
8
+ - right side is a template literal
9
+
10
+ Matched style source is collected, and assignment source spans are removed from JS output.
11
+
12
+ ## Output Shape
13
+
14
+ Extractor returns:
15
+
16
+ - `css` (concatenated)
17
+ - `scss` (concatenated)
18
+ - `sass` (concatenated)
19
+ - `style_segments` (ordered typed segments)
20
+ - `js` (style-assignment-free JS)
21
+
22
+ ## Compilation Phase
23
+
24
+ `resources/processors/bundlers/style-bundler.js` compiles style payloads via `SASS_Compiler` when SCSS/SASS is present (or when CSS is configured to compile through sass). It supports:
25
+
26
+ - mixed segment compilation
27
+ - load paths
28
+ - output style
29
+ - optional inline sourcemaps
30
+
31
+ The compiled CSS is appended as a `CSS` bundle item.
32
+
33
+ ## Current Limits
34
+
35
+ Extraction currently depends on a specific syntactic shape (`AssignmentExpression` + template literal). Non-matching style declaration patterns can evade extraction and remain in JS, which both bloats JS and risks duplicate style semantics.
@@ -0,0 +1,39 @@
1
+ # 4. Static Publishing and Delivery
2
+
3
+ ## Preparation Chain
4
+
5
+ `Static_Routes_Responses_Webpage_Bundle_Preparer.prepare(...)` runs:
6
+
7
+ 1. route assignment
8
+ 2. identity buffer assignment
9
+ 3. compressed buffer assignment
10
+ 4. response header assignment
11
+
12
+ ## Route Model
13
+
14
+ `Single_Control_Webpage_Server_Static_Routes_Assigner` maps by type:
15
+
16
+ - JavaScript -> `/js/js.js`
17
+ - CSS -> `/css/css.css`
18
+ - HTML -> `/`
19
+
20
+ This is deterministic but static; no fingerprinted asset paths yet.
21
+
22
+ ## Encoding Model
23
+
24
+ `Single_Control_Webpage_Server_Static_Uncompressed_Response_Buffers_Assigner` writes `response_buffers.identity`.
25
+
26
+ `Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner` optionally adds:
27
+
28
+ - `response_buffers.gzip`
29
+ - `response_buffers.br`
30
+
31
+ Configurable controls include `enabled`, `algorithms`, `gzip.level`, `brotli.quality`, and `threshold`.
32
+
33
+ ## Header Model
34
+
35
+ `Single_Control_Webpage_Server_Static_Headers_Assigner` writes headers per encoding variant under `item.response_headers[encoding]`, including `Content-Length`, `Content-Type`, and `Content-Encoding` where applicable.
36
+
37
+ ## Practical Implication
38
+
39
+ The delivery layer is currently path-stable and content-encoding-aware but not cache-fingerprint-aware. Lightweight bundles can still be produced, but CDN/browser cache efficiency is constrained by fixed asset names.
@@ -0,0 +1,25 @@
1
+ # 5. Current Limits and Size-Bloat Vectors
2
+
3
+ ## Bloat Vector 1: Entry-Point Over-Inclusion
4
+
5
+ If the client entry imports a broad namespace (or re-export hub), esbuild includes reachable modules conservatively. Tree shaking helps, but side-effect ambiguity limits elimination.
6
+
7
+ ## Bloat Vector 2: Side Effects and Dynamic Access
8
+
9
+ Patterns like dynamic member access, side-effectful module initialization, or broad registry mutation make safe elimination harder. Bundlers retain uncertain modules by design.
10
+
11
+ ## Bloat Vector 3: Post-Bundle Style Extraction Cost
12
+
13
+ Current strategy performs non-minifying bundle first, then AST style extraction, then JS rebundle/minify. This gives clean CSS separation but incurs additional processing and can retain JS content not representable as removable style assignments.
14
+
15
+ ## Bloat Vector 4: Fixed Aggregate Assets
16
+
17
+ Everything converges to a single `/js/js.js` and `/css/css.css` asset pair. This simplifies runtime, but does not naturally support granular shared-chunk caching.
18
+
19
+ ## Bloat Vector 5: Startup-Continuity Fallbacks
20
+
21
+ Bundling fallback behavior favors server startup continuity. If fallback text assets are accepted too loosely in operational workflows, latent size/perf regressions may go unnoticed.
22
+
23
+ ## Core Observation
24
+
25
+ The system is robust and functionally coherent, but it lacks a first-class "reachability report + elimination policy" layer that explains exactly what was retained and why.
@@ -0,0 +1,77 @@
1
+ # 6. Unused Module Elimination Strategy
2
+
3
+ ## Design Goal
4
+
5
+ Add deterministic dead-module elimination while preserving runtime correctness and keeping current high-level APIs stable.
6
+
7
+ ## Phase 1: Observability First
8
+
9
+ Introduce a bundle analysis artifact per build:
10
+
11
+ - `module_graph_manifest.json`
12
+ - fields: module path, retained/pruned flag, retention reason, side-effect classification, importer chain
13
+
14
+ Use esbuild `metafile` as baseline graph input. Do not prune yet in this phase.
15
+
16
+ ## Phase 2: Policy-Based Pruning
17
+
18
+ Add pruning policies:
19
+
20
+ - `safe`: prune only modules proven side-effect free and unreachable from entry exports
21
+ - `balanced`: allow package-level side-effect allowlists
22
+ - `aggressive`: opt-in broader pruning with explicit risk declaration
23
+
24
+ Each pruned module must carry an auditable reason code.
25
+
26
+ ## Phase 3: Runtime Safety Guardrails
27
+
28
+ Add optional runtime checks in debug mode:
29
+
30
+ - missing symbol trap hooks for known registries
31
+ - warning when dynamic lookup requests pruned modules
32
+
33
+ ## Proposed Configuration Surface
34
+
35
+ ```js
36
+ bundler: {
37
+ elimination: {
38
+ enabled: true,
39
+ profile: 'safe',
40
+ emit_manifest: true,
41
+ fail_on_uncertain_prune: true
42
+ }
43
+ }
44
+ ```
45
+
46
+ ## Contract
47
+
48
+ The contract must be: "No silent pruning." Every elimination decision is traceable in emitted metadata.
49
+
50
+ ## Current Implementation (Initial)
51
+
52
+ `jsgui3-server` now includes an initial `jsgui3-html` control scan-and-package path in the advanced esbuild bundler.
53
+
54
+ Enable it with:
55
+
56
+ ```js
57
+ bundler: {
58
+ elimination: {
59
+ enabled: true,
60
+ jsgui3_html_controls: {
61
+ enabled: true
62
+ }
63
+ }
64
+ }
65
+ ```
66
+
67
+ Behavior:
68
+
69
+ - scans reachable source files from the entry file
70
+ - detects static `jsgui3-html` control usage patterns
71
+ - builds a lightweight shim exporting only selected controls
72
+ - aliases `require('jsgui3-html')` to that shim during bundling
73
+ - attaches scan metadata at `bundle.bundle_analysis.jsgui3_html_control_scan`
74
+
75
+ Safety:
76
+
77
+ - if dynamic control indexing is detected (`controls[some_var]`), optimization is disabled by default