jsgui3-server 0.0.148 → 0.0.150

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 (154) hide show
  1. package/.github/agents/Mobile Developer.agent.md +89 -0
  2. package/.github/workflows/control-scan-manifest-check.yml +31 -0
  3. package/AGENTS.md +4 -0
  4. package/README.md +215 -3
  5. package/admin-ui/client.js +81 -51
  6. package/admin-ui/v1/admin_auth_service.js +197 -0
  7. package/admin-ui/v1/admin_user_store.js +71 -0
  8. package/admin-ui/v1/client.js +17 -0
  9. package/admin-ui/v1/controls/admin_shell.js +1399 -0
  10. package/admin-ui/v1/controls/group_box.js +84 -0
  11. package/admin-ui/v1/controls/stat_card.js +125 -0
  12. package/admin-ui/v1/server.js +658 -0
  13. package/admin-ui/v1/utils/formatters.js +68 -0
  14. package/dev-status.svg +139 -0
  15. package/docs/admin-extension-guide.md +345 -0
  16. package/docs/api-reference.md +301 -43
  17. package/docs/books/adaptive-control-improvements/01-control-candidate-matrix.md +122 -0
  18. package/docs/books/adaptive-control-improvements/02-tier-1-layout-playbooks.md +207 -0
  19. package/docs/books/adaptive-control-improvements/03-tier-2-navigation-form-overlay.md +140 -0
  20. package/docs/books/adaptive-control-improvements/04-cross-cutting-platform-functionality.md +141 -0
  21. package/docs/books/adaptive-control-improvements/05-styling-theming-density-upgrades.md +114 -0
  22. package/docs/books/adaptive-control-improvements/06-testing-quality-gates.md +97 -0
  23. package/docs/books/adaptive-control-improvements/07-delivery-roadmap-and-ownership.md +137 -0
  24. package/docs/books/adaptive-control-improvements/08-appendix-tier1-acceptance-and-pr-templates.md +261 -0
  25. package/docs/books/adaptive-control-improvements/README.md +66 -0
  26. package/docs/books/admin-ui-authentication/01-threat-model-and-goals.md +124 -0
  27. package/docs/books/admin-ui-authentication/02-session-model-and-token-model.md +75 -0
  28. package/docs/books/admin-ui-authentication/03-auth-middleware-patterns.md +77 -0
  29. package/docs/books/admin-ui-authentication/README.md +25 -0
  30. package/docs/books/creating-a-new-admin-ui/01-introduction-and-vision.md +130 -0
  31. package/docs/books/creating-a-new-admin-ui/02-architecture-and-data-flow.md +298 -0
  32. package/docs/books/creating-a-new-admin-ui/03-server-introspection.md +381 -0
  33. package/docs/books/creating-a-new-admin-ui/04-admin-module-adapter-layer.md +592 -0
  34. package/docs/books/creating-a-new-admin-ui/05-domain-controls-stat-cards-and-gauges.md +513 -0
  35. package/docs/books/creating-a-new-admin-ui/06-domain-controls-process-manager.md +544 -0
  36. package/docs/books/creating-a-new-admin-ui/07-domain-controls-resource-pool-inspector.md +493 -0
  37. package/docs/books/creating-a-new-admin-ui/08-domain-controls-route-table-and-api-explorer.md +586 -0
  38. package/docs/books/creating-a-new-admin-ui/09-domain-controls-log-viewer-and-activity-feed.md +490 -0
  39. package/docs/books/creating-a-new-admin-ui/10-domain-controls-build-status-and-bundle-inspector.md +526 -0
  40. package/docs/books/creating-a-new-admin-ui/11-domain-controls-configuration-panel.md +808 -0
  41. package/docs/books/creating-a-new-admin-ui/12-admin-shell-layout-sidebar-navigation.md +210 -0
  42. package/docs/books/creating-a-new-admin-ui/13-telemetry-integration.md +556 -0
  43. package/docs/books/creating-a-new-admin-ui/14-realtime-sse-observable-integration.md +485 -0
  44. package/docs/books/creating-a-new-admin-ui/15-styling-theming-aero-design-system.md +521 -0
  45. package/docs/books/creating-a-new-admin-ui/16-testing-and-quality-assurance.md +147 -0
  46. package/docs/books/creating-a-new-admin-ui/17-next-steps-process-resource-roadmap.md +356 -0
  47. package/docs/books/creating-a-new-admin-ui/README.md +68 -0
  48. package/docs/books/device-adaptive-composition/01-platform-feature-audit.md +177 -0
  49. package/docs/books/device-adaptive-composition/02-responsive-composition-model.md +187 -0
  50. package/docs/books/device-adaptive-composition/03-data-model-vs-view-model.md +231 -0
  51. package/docs/books/device-adaptive-composition/04-styling-theme-breakpoints.md +234 -0
  52. package/docs/books/device-adaptive-composition/05-showcase-app-multi-device-assessment.md +193 -0
  53. package/docs/books/device-adaptive-composition/06-implementation-patterns-and-apis.md +346 -0
  54. package/docs/books/device-adaptive-composition/07-testing-harness-and-quality-gates.md +265 -0
  55. package/docs/books/device-adaptive-composition/08-roadmap-and-adoption-plan.md +250 -0
  56. package/docs/books/device-adaptive-composition/README.md +47 -0
  57. package/docs/books/jsgui3-bundling-research-book/00-table-of-contents.md +35 -0
  58. package/docs/books/jsgui3-bundling-research-book/01-pipeline-and-runtime-semantics.md +34 -0
  59. package/docs/books/jsgui3-bundling-research-book/02-javascript-bundling-core.md +36 -0
  60. package/docs/books/jsgui3-bundling-research-book/03-style-extraction-and-css-compilation.md +35 -0
  61. package/docs/books/jsgui3-bundling-research-book/04-static-publishing-and-delivery.md +39 -0
  62. package/docs/books/jsgui3-bundling-research-book/05-current-limits-and-size-bloat-vectors.md +25 -0
  63. package/docs/books/jsgui3-bundling-research-book/06-unused-module-elimination-strategy.md +77 -0
  64. package/docs/books/jsgui3-bundling-research-book/07-jsgui3-html-control-and-mixin-pruning.md +63 -0
  65. package/docs/books/jsgui3-bundling-research-book/08-test-and-verification-methodology.md +43 -0
  66. package/docs/books/jsgui3-bundling-research-book/09-roadmap-and-rollout.md +42 -0
  67. package/docs/books/jsgui3-bundling-research-book/10-further-research-strategies-and-upgrades.md +211 -0
  68. package/docs/books/jsgui3-bundling-research-book/README.md +35 -0
  69. package/docs/bundling-system-deep-dive.md +9 -4
  70. package/docs/comparison-report-express-plex-cpanel.md +549 -0
  71. package/docs/comprehensive-documentation.md +49 -18
  72. package/docs/configuration-reference.md +152 -27
  73. package/docs/core/README.md +19 -0
  74. package/docs/core/jsgui3-server-core-book/00-table-of-contents.md +21 -0
  75. package/docs/core/jsgui3-server-core-book/01-startup-readiness-state-machine.md +41 -0
  76. package/docs/core/jsgui3-server-core-book/02-resource-abstraction-and-lifecycle.md +92 -0
  77. package/docs/core/jsgui3-server-core-book/03-resource-pool-and-event-topology.md +47 -0
  78. package/docs/core/jsgui3-server-core-book/04-sse-publisher-semantics.md +41 -0
  79. package/docs/core/jsgui3-server-core-book/05-serve-factory-resource-wiring.md +46 -0
  80. package/docs/core/jsgui3-server-core-book/06-e2e-testing-methodology.md +48 -0
  81. package/docs/core/jsgui3-server-core-book/07-defect-detection-and-hardening-loop.md +47 -0
  82. package/docs/designs/server-admin-interface-aero.svg +611 -0
  83. package/docs/publishers-guide.md +59 -4
  84. package/docs/resources-guide.md +184 -35
  85. package/docs/simple-server-api-design.md +72 -17
  86. package/docs/system-architecture.md +18 -14
  87. package/docs/troubleshooting.md +84 -53
  88. package/examples/controls/15) window, observable SSE/server.js +6 -1
  89. package/examples/controls/19) window, auto observable ui/server.js +9 -0
  90. package/examples/controls/20) window, task manager app/README.md +133 -0
  91. package/examples/controls/20) window, task manager app/client.js +797 -0
  92. package/examples/controls/20) window, task manager app/server.js +178 -0
  93. package/examples/controls/6) window, color_palette/client.js +165 -68
  94. package/examples/controls/9) window, date picker/client.js +362 -76
  95. package/examples/controls/9b) window, shared data.model mirrored date pickers/client.js +104 -83
  96. package/examples/jsgui3-html/06) theming/client.js +22 -1
  97. package/examples/jsgui3-html/10) binding-debugger/client.js +137 -1
  98. package/http/responders/static/Static_Route_HTTP_Responder.js +52 -34
  99. package/lab/experiments/capture-color-controls.js +196 -0
  100. package/lab/results/screenshots/color-controls/full_page.png +0 -0
  101. package/lab/results/screenshots/color-controls/section_1_color_grid_12x12.png +0 -0
  102. package/lab/results/screenshots/color-controls/section_2_color_grid_4x2.png +0 -0
  103. package/lab/results/screenshots/color-controls/section_3_color_palette.png +0 -0
  104. package/lab/results/screenshots/color-controls/section_4_palette_comparison.png +0 -0
  105. package/lab/results/screenshots/color-controls/section_5_raw_swatches.png +0 -0
  106. package/lab/results/screenshots/color-controls/section_6_optimized_crayola.png +0 -0
  107. package/lab/results/screenshots/color-controls/section_7_pastel_palette.png +0 -0
  108. package/lab/results/screenshots/color-controls/section_8_extended_144.png +0 -0
  109. package/lab/screenshot-utils.js +248 -0
  110. package/module.js +12 -0
  111. package/package.json +12 -2
  112. package/publishers/Publishers.js +4 -3
  113. package/publishers/helpers/assigners/static-compressed-response-buffers/Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner.js +5 -5
  114. package/publishers/http-sse-publisher.js +341 -0
  115. package/resources/process-resource.js +950 -0
  116. package/resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild.js +129 -33
  117. package/resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild.js +18 -7
  118. package/resources/processors/bundlers/js/esbuild/JSGUI3_HTML_Control_Optimizer.js +829 -0
  119. package/resources/remote-process-resource.js +355 -0
  120. package/resources/server-resource-pool.js +354 -41
  121. package/serve-factory.js +442 -259
  122. package/server.js +288 -13
  123. package/tests/README.md +71 -4
  124. package/tests/admin-ui-jsgui-controls.test.js +581 -0
  125. package/tests/admin-ui-render.test.js +24 -0
  126. package/tests/assigners.test.js +56 -40
  127. package/tests/bundling-default-control-elimination.puppeteer.test.js +260 -0
  128. package/tests/configuration-validation.test.js +21 -18
  129. package/tests/content-analysis.test.js +7 -6
  130. package/tests/control-optimizer-cache-behavior.test.js +52 -0
  131. package/tests/control-scan-manifest-regression.test.js +144 -0
  132. package/tests/end-to-end.test.js +15 -14
  133. package/tests/error-handling.test.js +222 -179
  134. package/tests/fixtures/bundling-default-button-client.js +37 -0
  135. package/tests/fixtures/bundling-default-window-client.js +34 -0
  136. package/tests/fixtures/control_scan_manifest_expectations.json +48 -0
  137. package/tests/fixtures/resource-monitor-client.js +319 -0
  138. package/tests/helpers/puppeteer-e2e-harness.js +317 -0
  139. package/tests/http-sse-publisher.test.js +136 -0
  140. package/tests/performance.test.js +69 -65
  141. package/tests/process-resource.test.js +138 -0
  142. package/tests/publishers.test.js +7 -7
  143. package/tests/remote-process-resource.test.js +160 -0
  144. package/tests/sass-controls.e2e.test.js +7 -1
  145. package/tests/serve-resources.test.js +270 -0
  146. package/tests/serve.test.js +120 -50
  147. package/tests/server-resource-pool.test.js +106 -0
  148. package/tests/small-controls-bundle-size.test.js +252 -0
  149. package/tests/test-runner.js +14 -1
  150. package/tests/window-examples.puppeteer.test.js +204 -1
  151. package/tests/window-resource-integration.puppeteer.test.js +585 -0
  152. package/tests/temp_invalid.js +0 -7
  153. package/tests/temp_invalid_utf8.js +0 -1
  154. package/tests/temp_malformed.js +0 -10
@@ -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
@@ -0,0 +1,63 @@
1
+ # 7. jsgui3-html Control and Mixin Pruning
2
+
3
+ ## Objective
4
+
5
+ Allow `jsgui3-html` to grow in feature breadth while keeping simple app bundles lightweight by pruning unused controls, mixins, and helper modules.
6
+
7
+ ## Constraint Surface
8
+
9
+ `jsgui3-html` usage often includes:
10
+
11
+ - direct imports (`const {Window} = require('jsgui3-html').controls`)
12
+ - registry-style access (`jsgui.controls.some_control`)
13
+ - inheritance chains and mixin composition
14
+
15
+ Pruning must account for all three.
16
+
17
+ ## Reachability Model
18
+
19
+ Build a typed symbol graph with nodes:
20
+
21
+ - controls
22
+ - mixins
23
+ - utility helpers
24
+ - transitive runtime support modules
25
+
26
+ Edges:
27
+
28
+ - static import/require edges
29
+ - inheritance edges
30
+ - mixin application edges
31
+ - registry publication edges
32
+
33
+ A module is retained if any retained symbol depends on it.
34
+
35
+ ## Beyond Controls and Mixins
36
+
37
+ The same graph can prune additional payload classes:
38
+
39
+ - optional theme packs
40
+ - optional icon packs
41
+ - optional debug instrumentation
42
+ - optional adapter layers (for features not used by the app)
43
+ - feature-local helper modules that are only referenced by pruned controls
44
+
45
+ ## Packaging Recommendation
46
+
47
+ Within `jsgui3-html`, define explicit boundaries:
48
+
49
+ - `core` (always lightweight baseline)
50
+ - optional feature groups (advanced controls, diagnostics, heavy widgets)
51
+
52
+ Then allow bundler elimination to prune unused optional groups based on symbol reachability.
53
+
54
+ ## Dynamic-Access Safety
55
+
56
+ When dynamic registry access is detected and symbol resolution is uncertain:
57
+
58
+ - `safe` profile retains uncertain candidates
59
+ - manifest records reason as `dynamic_access_uncertain`
60
+
61
+ ## Result
62
+
63
+ This produces consistent APIs while allowing bundle contents to shrink significantly for narrow use cases.
@@ -0,0 +1,43 @@
1
+ # 8. Test and Verification Methodology
2
+
3
+ ## Verification Principle
4
+
5
+ Bundle-size optimization is valid only if behavioral equivalence is maintained for supported usage profiles.
6
+
7
+ ## Test Layers
8
+
9
+ 1. Unit tests for elimination graph logic
10
+ 2. Integration tests for bundler output and route serving
11
+ 3. E2E browser tests for real interaction flows (Puppeteer)
12
+ 4. Size-regression tests with per-fixture budgets
13
+
14
+ ## Bundle Correctness Tests
15
+
16
+ For each fixture app:
17
+
18
+ - generate baseline bundle (elimination disabled)
19
+ - generate optimized bundle (elimination enabled)
20
+ - compare runtime outcomes and key DOM/event traces
21
+ - compare bundle size deltas against expected thresholds
22
+
23
+ ## Puppeteer Scenarios
24
+
25
+ For control-heavy examples:
26
+
27
+ - open page and wait for control activation markers
28
+ - perform high-specificity interactions (drag, resize, date pick, color pick, keyboard paths)
29
+ - assert expected UI state and emitted network/API behavior
30
+
31
+ For resource-integrated flows:
32
+
33
+ - verify client-visible state updates driven by server resources
34
+ - verify SSE/event paths where applicable
35
+ - confirm no missing-symbol/runtime errors caused by pruning
36
+
37
+ ## Gating Policy
38
+
39
+ A prune policy cannot be promoted from experimental to default unless:
40
+
41
+ - all functional suites pass
42
+ - bundle manifest diff is stable and explainable
43
+ - size regression thresholds are met across representative fixtures.
@@ -0,0 +1,42 @@
1
+ # 9. Roadmap and Rollout
2
+
3
+ ## Phase A: Baseline Instrumentation
4
+
5
+ - emit module graph manifest without pruning
6
+ - add CI artifact publishing for manifests
7
+ - add docs for reading retention reasons
8
+
9
+ Exit criteria:
10
+ - manifests generated for all target example fixtures
11
+ - no behavior changes
12
+
13
+ ## Phase B: Safe Pruning Profile
14
+
15
+ - implement `safe` elimination profile
16
+ - prune only proven unreachable and side-effect-safe modules
17
+ - add fail-fast option for uncertain prune attempts
18
+
19
+ Exit criteria:
20
+ - full test suite green
21
+ - measurable JS size reductions on simple apps
22
+ - zero runtime regressions
23
+
24
+ ## Phase C: jsgui3-html Symbol-Aware Pruning
25
+
26
+ - add control/mixin symbol graph pass
27
+ - integrate registry publication edge tracking
28
+ - support optional feature-group retention manifests
29
+
30
+ Exit criteria:
31
+ - significant size reductions for minimal-control apps
32
+ - controlled retention for dynamic access cases
33
+
34
+ ## Phase D: Operational Hardening
35
+
36
+ - add deterministic chunk/hash strategy if route model evolves
37
+ - enforce size budgets in CI
38
+ - document migration path for package authors to declare side effects explicitly
39
+
40
+ ## Non-Goal
41
+
42
+ Runtime hot-switching of elimination profiles is not required. Build-time consistency with predictable APIs is the target.
@@ -0,0 +1,211 @@
1
+ # 10. Further Research: Strategies and Upgrades
2
+
3
+ ## Purpose
4
+
5
+ This chapter extends the initial roadmap with additional strategies validated against current official tooling documentation. The goal is to improve both:
6
+
7
+ - elimination quality (more dead code removed safely)
8
+ - operational confidence (clear reason codes and controlled risk)
9
+
10
+ ## A. Strengthen Existing Esbuild-Centric Strategy
11
+
12
+ ### A1. Turn Build Metadata into First-Class Artifact
13
+
14
+ Current proposal already introduces a manifest. Upgrade it to include:
15
+
16
+ - esbuild `metafile` `inputs` and `outputs` mapping
17
+ - importer chains for each retained module
18
+ - side-effect reason code (`annotation`, `package_side_effects`, `plugin_side_effects`, `unknown`)
19
+ - unresolved dynamic-import reason code where relevant
20
+
21
+ Why: esbuild exposes a structured metadata graph and textual analysis hooks suitable for deterministic retention explanations.
22
+
23
+ ### A2. Add Plugin-Level Side-Effect Overrides (Safe Allowlist Only)
24
+
25
+ Esbuild plugin `onResolve` supports returning `sideEffects: false`. Use this only through a strict allowlist generated from audited modules, never broad regex defaults.
26
+
27
+ Why: this provides precision beyond package-level `sideEffects` fields and enables selective pruning of known-safe internal modules.
28
+
29
+ ### A3. Improve Annotation Fault Tolerance
30
+
31
+ Support an explicit fallback mode for bad third-party annotations:
32
+
33
+ - default: respect annotations (`/* @__PURE__ */`, `package.json sideEffects`)
34
+ - safe fallback: set `ignoreAnnotations: true` for known-problem dependency subsets
35
+
36
+ Why: esbuild documents annotation misuse as a real breakage source; controlled fallback prevents production outages.
37
+
38
+ ### A4. Prefer ESM Paths Where Safe
39
+
40
+ For packages that expose both CommonJS and ESM, prefer ESM paths where validated to improve tree shaking.
41
+
42
+ Why: esbuild explicitly notes tree shaking depends on ESM `import`/`export` and does not work on CommonJS modules the same way.
43
+
44
+ ## B. Add Multi-Chunk Strategy (Not Just Single /js/js.js)
45
+
46
+ ### B1. Optional ESM Split Build Profile
47
+
48
+ Add an optional bundler profile that emits ESM with splitting enabled (`format: 'esm'`, `splitting: true`) and chunk names with content hashes.
49
+
50
+ Use for:
51
+
52
+ - multi-page apps
53
+ - heavy optional controls loaded by `import()`
54
+
55
+ Do not force this profile for simple examples where a single file remains desirable.
56
+
57
+ ### B2. Route and HTML Preparation Upgrade
58
+
59
+ Current static route assigner assumes one JS and one CSS file. Add a preparer mode that:
60
+
61
+ - maps every emitted JS/CSS asset to static routes
62
+ - injects `<script type="module">` plus chunk graph references where required
63
+ - supports content-hash file names for cache correctness
64
+
65
+ ## C. Use Safety Ladder from Rollup Research as Policy Design Input
66
+
67
+ Even if the implementation remains esbuild-first, Rollup's treeshake policy surface is a useful design model:
68
+
69
+ - `safest`
70
+ - `recommended`
71
+ - `smallest`
72
+
73
+ Adopt equivalent policy semantics in `jsgui3-server` elimination config:
74
+
75
+ - `safe` (strict side-effect conservatism)
76
+ - `balanced` (some side-effect assumptions)
77
+ - `aggressive` (max pruning, stronger contracts)
78
+
79
+ Include explicit controls for assumptions analogous to:
80
+
81
+ - module side effects
82
+ - property-read side effects
83
+ - try/catch deoptimization behavior
84
+ - manually pure function sets
85
+
86
+ ## D. Package Boundary Strategy for jsgui3-html
87
+
88
+ ### D1. Subpath Exports for Feature Addressability
89
+
90
+ Restructure `jsgui3-html` package exports so controls and mixins have stable subpath entry points (for example, `./controls/date_picker.js`, `./mixins/draggable.js`, `./core/...`).
91
+
92
+ Why: Node package `exports` and subpath exports give explicit package contracts and allow bundlers to consume narrow entry points instead of broad index hubs.
93
+
94
+ ### D2. Core vs Optional Feature Groups
95
+
96
+ Define package layers:
97
+
98
+ - `core` minimal runtime
99
+ - optional groups (`advanced-controls`, `diagnostics`, `themes`, etc.)
100
+
101
+ Then bind elimination policies to these boundaries for predictable pruning.
102
+
103
+ ### D3. Internal Imports Field for Maintainability
104
+
105
+ Use package `imports` (private `#...` aliases) inside `jsgui3-html` to stabilize internal paths while allowing refactors that do not leak into public imports.
106
+
107
+ ## E. Compression and Minification Escalation Path
108
+
109
+ ### E1. Keep Esbuild as Default Minifier
110
+
111
+ Esbuild is very fast and adequate for most builds.
112
+
113
+ ### E2. Optional High-Compression Pass
114
+
115
+ For release artifacts that need additional byte reduction, provide an optional second minification pass profile (e.g., Terser pure-function tuning). Keep this opt-in due to risk/perf tradeoffs.
116
+
117
+ ### E3. Experimental Extreme Profile
118
+
119
+ Document (not default) an experimental path for Closure Compiler `ADVANCED_OPTIMIZATIONS` for controlled targets only, with strict compatibility guardrails.
120
+
121
+ ## F. Coverage-Guided Optimization (Puppeteer + CDP)
122
+
123
+ ### F1. Coverage Collection Pipeline
124
+
125
+ Use Puppeteer coverage APIs in E2E suites:
126
+
127
+ - `page.coverage.startJSCoverage(...)`
128
+ - `page.coverage.startCSSCoverage(...)`
129
+ - stop coverage and persist per-script ranges
130
+
131
+ Enable block-level coverage for high resolution.
132
+
133
+ ### F2. Precise CDP Coverage for Deep Diagnostics
134
+
135
+ For targeted diagnostics, integrate CDP Profiler precise coverage APIs (`startPreciseCoverage`, `takePreciseCoverage`) in controlled runs.
136
+
137
+ ### F3. Correct Interpretation Rule
138
+
139
+ Coverage is advisory, not authoritative:
140
+
141
+ - never auto-prune solely from observed runtime coverage
142
+ - use coverage to identify candidates for lazy loading or refactor, then validate with static safety rules
143
+
144
+ ## G. Concrete Upgrades to Existing jsgui3-server Plan
145
+
146
+ ### G1. New Config Surface (Proposed)
147
+
148
+ ```js
149
+ bundler: {
150
+ elimination: {
151
+ enabled: true,
152
+ profile: 'safe', // safe | balanced | aggressive
153
+ emit_manifest: true,
154
+ include_importer_chains: true,
155
+ fail_on_uncertain_prune: true,
156
+ plugin_side_effect_overrides: {
157
+ allowlist: []
158
+ }
159
+ },
160
+ chunking: {
161
+ profile: 'single', // single | esm_split
162
+ chunk_names: 'chunks/[name]-[hash]'
163
+ }
164
+ }
165
+ ```
166
+
167
+ ### G2. Manifest Enrichment (Proposed)
168
+
169
+ Add fields:
170
+
171
+ - `retained_reason_code`
172
+ - `side_effect_source`
173
+ - `importer_chain`
174
+ - `dynamic_access_risk`
175
+ - `runtime_coverage_seen` (optional diagnostic field)
176
+
177
+ ### G3. Test Expansion
178
+
179
+ - policy conformance tests per profile (`safe`, `balanced`, `aggressive`)
180
+ - split profile routing/injection tests
181
+ - manifest stability snapshots
182
+ - Puppeteer coverage capture and diff reporting
183
+
184
+ ## H. Prioritized Execution Order
185
+
186
+ 1. Implement manifest enrichment on top of current esbuild flow.
187
+ 2. Add safe plugin-side-effect allowlist mechanism.
188
+ 3. Add ESM split profile behind feature flag.
189
+ 4. Add package-boundary changes in `jsgui3-html` (`exports`/subpaths/core layering).
190
+ 5. Add optional secondary minifier profile.
191
+ 6. Integrate coverage-guided diagnostics into CI reports.
192
+
193
+ ## Source Notes
194
+
195
+ External strategies in this chapter are based on current official docs for esbuild, Rollup, webpack, Node package exports/imports, Puppeteer coverage APIs, and Chrome DevTools Protocol coverage APIs.
196
+
197
+ Primary references:
198
+
199
+ - https://esbuild.github.io/api/
200
+ - https://esbuild.github.io/plugins/
201
+ - https://rollupjs.org/configuration-options/
202
+ - https://webpack.js.org/guides/tree-shaking/
203
+ - https://webpack.js.org/plugins/split-chunks-plugin/
204
+ - https://nodejs.org/api/packages.html
205
+ - https://babeljs.io/docs/babel-plugin-transform-modules-commonjs
206
+ - https://terser.org/docs/options/#compress-options
207
+ - https://developers.google.com/closure/compiler/docs/compilation_levels
208
+ - https://developers.google.com/closure/compiler/docs/api-tutorial3
209
+ - https://pptr.dev/api/puppeteer.coverage.startjscoverage
210
+ - https://pptr.dev/api/puppeteer.coverage.startcsscoverage
211
+ - https://chromedevtools.github.io/devtools-protocol/tot/Profiler/#method-startPreciseCoverage
@@ -0,0 +1,35 @@
1
+ # JSGUI3 Bundling Research Book
2
+
3
+ This book documents how JS and CSS bundling currently works in `jsgui3-server`, then defines a practical path to remove unused modules, controls, mixins, and related code from final bundles without breaking runtime behavior.
4
+
5
+ ## Scope
6
+
7
+ - Current runtime bundling semantics (implementation-first, file-path grounded)
8
+ - Existing optimization surface and current limits
9
+ - Dead-module elimination strategy for application code and `jsgui3-html`
10
+ - Control/mixin reachability and pruning model
11
+ - Verification strategy (unit, integration, e2e, and size-regression)
12
+
13
+ ## Intended Readers
14
+
15
+ - Maintainers changing bundling internals
16
+ - Contributors adding controls or mixins to `jsgui3-html`
17
+ - Agents implementing bundle-size reduction work
18
+
19
+ ## Reading Order
20
+
21
+ 1. [00 Table of Contents](00-table-of-contents.md)
22
+ 2. [01 Pipeline and Runtime Semantics](01-pipeline-and-runtime-semantics.md)
23
+ 3. [02 JavaScript Bundling Core](02-javascript-bundling-core.md)
24
+ 4. [03 Style Extraction and CSS Compilation](03-style-extraction-and-css-compilation.md)
25
+ 5. [04 Static Publishing and Delivery](04-static-publishing-and-delivery.md)
26
+ 6. [05 Current Limits and Size-Bloat Vectors](05-current-limits-and-size-bloat-vectors.md)
27
+ 7. [06 Unused Module Elimination Strategy](06-unused-module-elimination-strategy.md)
28
+ 8. [07 jsgui3-html Control and Mixin Pruning](07-jsgui3-html-control-and-mixin-pruning.md)
29
+ 9. [08 Test and Verification Methodology](08-test-and-verification-methodology.md)
30
+ 10. [09 Roadmap and Rollout](09-roadmap-and-rollout.md)
31
+ 11. [10 Further Research: Strategies and Upgrades](10-further-research-strategies-and-upgrades.md)
32
+
33
+ ## Status
34
+
35
+ This is a working research book. It is designed to be updated as the bundling system evolves.
@@ -1,6 +1,11 @@
1
- # Bundling System Deep Dive
2
-
3
- ## When to Read
1
+ # Bundling System Deep Dive
2
+
3
+ ## Research Track
4
+
5
+ For the active, chaptered research track on lightweight bundle strategy and unused-module elimination, use:
6
+ `docs/books/jsgui3-bundling-research-book/README.md`
7
+
8
+ ## When to Read
4
9
 
5
10
  This document provides detailed technical documentation of JSGUI3 Server's bundling system. Read this when:
6
11
  - You need to understand how JavaScript and CSS bundling works internally
@@ -522,4 +527,4 @@ Key takeaways:
522
527
  - **Debugging**: Use debug mode and logging for troubleshooting
523
528
  - **Performance**: Fast for development, optimizable for production
524
529
 
525
- For issues not covered here, check the [troubleshooting guide](docs/troubleshooting.md) or create an issue in the repository.
530
+ For issues not covered here, check the [troubleshooting guide](docs/troubleshooting.md) or create an issue in the repository.