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
@@ -6,19 +6,45 @@ const Bundler_Using_ESBuild = require('./Bundler_Using_ESBuild');
6
6
  const {is_array} = require('lang-tools');
7
7
 
8
8
  const Core_JS_Single_File_Minifying_Bundler_Using_ESBuild = require('./Core_JS_Single_File_Minifying_Bundler_Using_ESBuild');
9
+ const JSGUI3_HTML_Control_Optimizer = require('./JSGUI3_HTML_Control_Optimizer');
9
10
 
10
11
  //const CSS_Extractor = require('./_Old_CSS_Extractor');
11
12
 
12
13
  // Use a different CSS extractor.
13
14
 
14
15
 
15
- const Bundle = require('../../bundle');
16
-
16
+ const Bundle = require('../../bundle');
17
+
17
18
  const CSS_And_JS_From_JS_String_Extractor = require('../../../extractors/js/css_and_js/CSS_And_JS_From_JS_String_Extractor');
18
19
  const {compile_styles} = require('../../style-bundler');
19
-
20
-
21
- class Advanced_JS_Bundler_Using_ESBuild extends Bundler_Using_ESBuild {
20
+
21
+ const await_bundle_observable = (bundle_result) => {
22
+ if (!bundle_result || typeof bundle_result.on !== 'function') {
23
+ return Promise.resolve(bundle_result);
24
+ }
25
+
26
+ const normalize_result = (value) => {
27
+ if (Array.isArray(value)) return value;
28
+ if (value && value._arr) return [value];
29
+ return value;
30
+ };
31
+
32
+ return new Promise((resolve, reject) => {
33
+ let settled = false;
34
+ const settle_once = (settle_fn, value) => {
35
+ if (settled) return;
36
+ settled = true;
37
+ settle_fn(value);
38
+ };
39
+
40
+ bundle_result.on('error', (error) => settle_once(reject, error));
41
+ bundle_result.on('next', (value) => settle_once(resolve, normalize_result(value)));
42
+ bundle_result.on('complete', (value) => settle_once(resolve, normalize_result(value)));
43
+ });
44
+ };
45
+
46
+
47
+ class Advanced_JS_Bundler_Using_ESBuild extends Bundler_Using_ESBuild {
22
48
  constructor(spec = {}) {
23
49
  super(spec);
24
50
 
@@ -26,6 +52,16 @@ class Advanced_JS_Bundler_Using_ESBuild extends Bundler_Using_ESBuild {
26
52
 
27
53
  // Store bundler configuration
28
54
  this.bundler_config = spec.bundler || {};
55
+
56
+ // Enable elimination by default, while preserving explicit opt-out.
57
+ const raw_elimination_config = this.bundler_config.elimination;
58
+ if (raw_elimination_config === false) {
59
+ this.elimination_config = {enabled: false};
60
+ } else if (raw_elimination_config && typeof raw_elimination_config === 'object') {
61
+ this.elimination_config = raw_elimination_config;
62
+ } else {
63
+ this.elimination_config = {};
64
+ }
29
65
  const style_config = spec.style || this.bundler_config.style || {};
30
66
  this.style_config = Object.assign({debug: this.debug === true}, style_config);
31
67
 
@@ -42,14 +78,45 @@ class Advanced_JS_Bundler_Using_ESBuild extends Bundler_Using_ESBuild {
42
78
 
43
79
 
44
80
  // Probably don't use that minifying bundler in debug mode.
45
- this.minifying_js_single_file_bundler = new Core_JS_Single_File_Minifying_Bundler_Using_ESBuild({
46
- minify: this.bundler_config.minify
47
- });
48
-
49
- }
81
+ this.minifying_js_single_file_bundler = new Core_JS_Single_File_Minifying_Bundler_Using_ESBuild({
82
+ minify: this.bundler_config.minify
83
+ });
84
+
85
+ const control_elimination_config = this.elimination_config.jsgui3_html_controls || {};
86
+ const elimination_enabled = this.elimination_config.enabled !== false;
87
+ const control_elimination_enabled = elimination_enabled &&
88
+ control_elimination_config.enabled !== false;
89
+
90
+ if (control_elimination_enabled) {
91
+ const cache_config = control_elimination_config.cache && typeof control_elimination_config.cache === 'object'
92
+ ? control_elimination_config.cache
93
+ : {};
94
+ this.jsgui3_html_control_optimizer = new JSGUI3_HTML_Control_Optimizer({
95
+ package_name: control_elimination_config.package_name || 'jsgui3-html',
96
+ emit_manifest: control_elimination_config.emit_manifest === true,
97
+ allow_dynamic_controls: control_elimination_config.allow_dynamic_controls === true,
98
+ include_controls: control_elimination_config.include_controls,
99
+ exclude_controls: control_elimination_config.exclude_controls,
100
+ cacheEnabled: cache_config.enabled !== false,
101
+ sharedCache: cache_config.shared !== false,
102
+ log: control_elimination_config.log === true,
103
+ manifest_dir: control_elimination_config.manifest_dir,
104
+ shim_dir: control_elimination_config.shim_dir
105
+ });
106
+ } else {
107
+ this.jsgui3_html_control_optimizer = null;
108
+ }
109
+
110
+ }
50
111
 
51
112
  bundle(js_file_path) {
52
- const {non_minifying_bundler, css_and_js_from_js_string_extractor, minifying_js_single_file_bundler, style_config} = this;
113
+ const {
114
+ non_minifying_bundler,
115
+ css_and_js_from_js_string_extractor,
116
+ minifying_js_single_file_bundler,
117
+ style_config,
118
+ jsgui3_html_control_optimizer
119
+ } = this;
53
120
 
54
121
  // Validate input
55
122
  if (typeof js_file_path !== 'string' || js_file_path.trim() === '') {
@@ -64,11 +131,27 @@ class Advanced_JS_Bundler_Using_ESBuild extends Bundler_Using_ESBuild {
64
131
 
65
132
 
66
133
 
67
- const res_obs = obs(async(next, complete, error) => {
68
-
69
- //console.log('Advanced_JS_Bundler_Using_ESBuild bundle js_file_path:', js_file_path);
70
-
71
- const res_nmb = await non_minifying_bundler.bundle(js_file_path);
134
+ const res_obs = obs(async(next, complete, error) => {
135
+
136
+ try {
137
+ //console.log('Advanced_JS_Bundler_Using_ESBuild bundle js_file_path:', js_file_path);
138
+
139
+ let entry_build_overrides = {};
140
+ let control_scan_manifest = null;
141
+
142
+ if (jsgui3_html_control_optimizer) {
143
+ const optimization_result = await jsgui3_html_control_optimizer.optimize(js_file_path);
144
+ if (optimization_result && optimization_result.enabled && optimization_result.plugin) {
145
+ entry_build_overrides.plugins = [optimization_result.plugin];
146
+ }
147
+ if (optimization_result && optimization_result.manifest) {
148
+ control_scan_manifest = optimization_result.manifest;
149
+ }
150
+ }
151
+
152
+ const res_nmb = await await_bundle_observable(
153
+ non_minifying_bundler.bundle(js_file_path, entry_build_overrides)
154
+ );
72
155
 
73
156
  //console.log('res_nmb', res_nmb);
74
157
 
@@ -88,21 +171,23 @@ class Advanced_JS_Bundler_Using_ESBuild extends Bundler_Using_ESBuild {
88
171
  const {text} = bundle_item;
89
172
  // Then use the css and js from js extractor.
90
173
 
91
- const res_extract_styles_and_js = await css_and_js_from_js_string_extractor.extract(text);
92
- const {
93
- css = '',
94
- scss = '',
95
- sass = '',
96
- style_segments = [],
97
- js = text
98
- } = res_extract_styles_and_js || {};
99
-
100
- const style_bundle = compile_styles({css, scss, sass, style_segments}, style_config);
101
- const compiled_css = style_bundle.css || '';
174
+ const res_extract_styles_and_js = await css_and_js_from_js_string_extractor.extract(text);
175
+ const {
176
+ css = '',
177
+ scss = '',
178
+ sass = '',
179
+ style_segments = [],
180
+ js = text
181
+ } = res_extract_styles_and_js || {};
182
+
183
+ const style_bundle = compile_styles({css, scss, sass, style_segments}, style_config);
184
+ const compiled_css = style_bundle.css || '';
102
185
 
103
186
  if (this.debug) {
104
187
  // Generate source maps for CSS-free JS
105
- const css_free_bundle_result = await non_minifying_bundler.bundle_js_string(js);
188
+ const css_free_bundle_result = await await_bundle_observable(
189
+ non_minifying_bundler.bundle_js_string(js)
190
+ );
106
191
  const css_free_bundle_item = css_free_bundle_result[0]._arr[0];
107
192
 
108
193
  const res_bundle = new Bundle();
@@ -112,14 +197,18 @@ class Advanced_JS_Bundler_Using_ESBuild extends Bundler_Using_ESBuild {
112
197
  text: css_free_bundle_item.text
113
198
  }
114
199
  res_bundle.push(o_js_bundle_item);
115
- const o_css_bundle_item = {
116
- type: 'CSS',
117
- extension: 'css',
118
- text: compiled_css
200
+ const o_css_bundle_item = {
201
+ type: 'CSS',
202
+ extension: 'css',
203
+ text: compiled_css
204
+ }
205
+ res_bundle.push(o_css_bundle_item);
206
+ if (control_scan_manifest) {
207
+ res_bundle.bundle_analysis = res_bundle.bundle_analysis || {};
208
+ res_bundle.bundle_analysis.jsgui3_html_control_scan = control_scan_manifest;
119
209
  }
120
- res_bundle.push(o_css_bundle_item);
121
- next(res_bundle);
122
- complete(res_bundle);
210
+ next(res_bundle);
211
+ complete(res_bundle);
123
212
 
124
213
 
125
214
 
@@ -129,9 +218,13 @@ class Advanced_JS_Bundler_Using_ESBuild extends Bundler_Using_ESBuild {
129
218
 
130
219
  } else {
131
220
  // Generate source maps for CSS-free JS and minify
132
- const css_free_bundle_result = await non_minifying_bundler.bundle_js_string(js);
133
- const css_free_bundle_item = css_free_bundle_result[0]._arr[0];
134
- const minified_js = await minifying_js_single_file_bundler.bundle(css_free_bundle_item.text);
221
+ const css_free_bundle_result = await await_bundle_observable(
222
+ non_minifying_bundler.bundle_js_string(js)
223
+ );
224
+ const css_free_bundle_item = css_free_bundle_result[0]._arr[0];
225
+ const minified_js = await await_bundle_observable(
226
+ minifying_js_single_file_bundler.bundle(css_free_bundle_item.text)
227
+ );
135
228
 
136
229
  //console.log('minified_js', minified_js);
137
230
  //console.log('minified_js.length', minified_js.length);
@@ -140,14 +233,18 @@ class Advanced_JS_Bundler_Using_ESBuild extends Bundler_Using_ESBuild {
140
233
 
141
234
  if (is_array(minified_js) && minified_js.length === 1) {
142
235
  const minified_bundle = minified_js[0];
143
- const o_css_bundle_item = {
144
- type: 'CSS',
145
- extension: 'css',
146
- text: compiled_css
236
+ const o_css_bundle_item = {
237
+ type: 'CSS',
238
+ extension: 'css',
239
+ text: compiled_css
147
240
  }
148
- minified_bundle.push(o_css_bundle_item);
149
- next(minified_bundle);
150
- complete(minified_bundle);
241
+ minified_bundle.push(o_css_bundle_item);
242
+ if (control_scan_manifest) {
243
+ minified_bundle.bundle_analysis = minified_bundle.bundle_analysis || {};
244
+ minified_bundle.bundle_analysis.jsgui3_html_control_scan = control_scan_manifest;
245
+ }
246
+ next(minified_bundle);
247
+ complete(minified_bundle);
151
248
  } else {
152
249
  console.trace();
153
250
  throw 'Unexpected minified JS structure';
@@ -241,6 +338,27 @@ class Advanced_JS_Bundler_Using_ESBuild extends Bundler_Using_ESBuild {
241
338
  // Need to use a non minifying bundler (first).
242
339
 
243
340
 
341
+ } catch (bundleError) {
342
+ // Defensive programming: Log error but don't crash the server
343
+ console.error('[Advanced_JS_Bundler_Using_ESBuild] Bundling failed:', bundleError.message || bundleError);
344
+ console.error('[Advanced_JS_Bundler_Using_ESBuild] Returning empty bundle to allow server startup.');
345
+
346
+ // Return an empty bundle so the server can continue
347
+ const fallback_bundle = new Bundle();
348
+ fallback_bundle.push({
349
+ type: 'JavaScript',
350
+ extension: 'js',
351
+ text: '/* Bundling failed - see server logs */'
352
+ });
353
+ fallback_bundle.push({
354
+ type: 'CSS',
355
+ extension: 'css',
356
+ text: '/* Bundling failed - see server logs */'
357
+ });
358
+ next(fallback_bundle);
359
+ complete(fallback_bundle);
360
+ }
361
+
244
362
  const _old_code = async() => {
245
363
 
246
364
  const css_extractor_res = await css_extractor.separate_css_and_js(js_file_path)
@@ -290,4 +408,4 @@ class Advanced_JS_Bundler_Using_ESBuild extends Bundler_Using_ESBuild {
290
408
  }
291
409
 
292
410
 
293
- module.exports = Advanced_JS_Bundler_Using_ESBuild;
411
+ module.exports = Advanced_JS_Bundler_Using_ESBuild;
@@ -13,14 +13,15 @@ const Bundler_Using_ESBuild = require('./Bundler_Using_ESBuild');
13
13
 
14
14
 
15
15
 
16
- class Core_JS_Non_Minifying_Bundler_Using_ESBuild extends Bundler_Using_ESBuild {
17
- constructor(spec = {}) {
18
- super(spec);
16
+ class Core_JS_Non_Minifying_Bundler_Using_ESBuild extends Bundler_Using_ESBuild {
17
+ constructor(spec = {}) {
18
+ super(spec);
19
19
 
20
20
  if (spec.debug !== undefined) this.debug = spec.debug;
21
21
 
22
- // Store sourcemap configuration
23
- this.sourcemap_config = spec.sourcemaps || {};
22
+ // Store sourcemap configuration
23
+ this.sourcemap_config = spec.sourcemaps || {};
24
+ this.build_plugins = Array.isArray(spec.plugins) ? spec.plugins : [];
24
25
 
25
26
  }
26
27
 
@@ -44,7 +45,7 @@ class Core_JS_Non_Minifying_Bundler_Using_ESBuild extends Bundler_Using_ESBuild
44
45
 
45
46
 
46
47
 
47
- bundle_js_string(js_string) {
48
+ bundle_js_string(js_string, build_overrides = {}) {
48
49
  const res_obs = obs(async(next, complete, error) => {
49
50
  try {
50
51
  const o_build = {
@@ -63,6 +64,11 @@ class Core_JS_Non_Minifying_Bundler_Using_ESBuild extends Bundler_Using_ESBuild
63
64
  o_build.sourcemap = this.sourcemap_config.format || 'inline';
64
65
  }
65
66
 
67
+ const plugins = Array.isArray(build_overrides.plugins) ? build_overrides.plugins : this.build_plugins;
68
+ if (plugins.length > 0) {
69
+ o_build.plugins = plugins;
70
+ }
71
+
66
72
  const result = await esbuild.build(o_build);
67
73
 
68
74
  if (result.outputFiles.length === 1) {
@@ -87,7 +93,7 @@ class Core_JS_Non_Minifying_Bundler_Using_ESBuild extends Bundler_Using_ESBuild
87
93
  return res_obs;
88
94
  }
89
95
 
90
- bundle(js_file_path) {
96
+ bundle(js_file_path, build_overrides = {}) {
91
97
 
92
98
 
93
99
  const res_obs = obs(async(next, complete, error) => {
@@ -110,6 +116,11 @@ class Core_JS_Non_Minifying_Bundler_Using_ESBuild extends Bundler_Using_ESBuild
110
116
  o_build.sourcemap = this.sourcemap_config.format || 'inline';
111
117
  }
112
118
 
119
+ const plugins = Array.isArray(build_overrides.plugins) ? build_overrides.plugins : this.build_plugins;
120
+ if (plugins.length > 0) {
121
+ o_build.plugins = plugins;
122
+ }
123
+
113
124
  const result = await esbuild.build(o_build);
114
125
  //console.log('result.outputFiles:\n\n');
115
126
  //for (let out of result.outputFiles) {