jsgui3-server 0.0.98 → 0.0.100

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 (53) hide show
  1. package/examples/box/{square_box_client.js → 1) square box/client.js } +40 -5
  2. package/examples/box/{square_box.js → 1) square box/server.js } +10 -3
  3. package/examples/box/2) twenty square boxes/css flex wrap/client.js +248 -0
  4. package/examples/box/2) twenty square boxes/css flex wrap/server.js +113 -0
  5. package/examples/controls/1) window/client.js +184 -0
  6. package/examples/controls/1) window/server.js +114 -0
  7. package/examples/controls/{_html-server-color-palette.js → __old/_html-server-color-palette.js} +2 -2
  8. package/examples/controls/{scs-month-view.js → __old/scs-month-view.js} +0 -1
  9. package/http/responders/HTTP_Responder.js +16 -0
  10. package/http/responders/static/Static_Route_HTTP_Responder.js +106 -0
  11. package/package.json +9 -8
  12. package/page-context.js +15 -0
  13. package/publishers/helpers/assigners/Assigner.js +11 -0
  14. package/publishers/helpers/assigners/static-compressed-response-buffers/Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner.js +150 -0
  15. package/publishers/helpers/assigners/static-headers/Single_Control_Webpage_Server_Static_Headers_Assigner.js +110 -0
  16. package/publishers/helpers/assigners/static-routes/Single_Control_Webpage_Server_Static_Routes_Assigner.js +92 -0
  17. package/publishers/helpers/assigners/static-uncompressed-response-buffers/Single_Control_Webpage_Server_Static_Uncompressed_Response_Buffers_Assigner.js +104 -0
  18. package/publishers/helpers/preparers/static/bundle/Ready_To_Serve_Preparer.js +19 -0
  19. package/publishers/helpers/preparers/static/bundle/Static_Routes_Responses_Webpage_Bundle_Preparer.js +45 -0
  20. package/publishers/http-webpage-publisher.js +483 -3
  21. package/publishers/http-webpageorsite-publisher.js +343 -0
  22. package/publishers/http-website-publisher.js +51 -2
  23. package/resources/compile/server-resource-compilation.js +2 -0
  24. package/resources/jsbuilder/JS_AST/JS_AST_Node_0-Core.js +26 -0
  25. package/resources/processors/bundlers/css-bundler.js +24 -1
  26. package/resources/processors/bundlers/js/JS_Bundler.js +52 -0
  27. package/resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild.js +389 -0
  28. package/resources/processors/bundlers/js/esbuild/Bundler_Using_ESBuild.js +9 -0
  29. package/resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild.js +186 -0
  30. package/resources/processors/bundlers/js/esbuild/Core_JS_Single_File_Minifying_Bundler_Using_ESBuild.js +191 -0
  31. package/resources/processors/bundlers/js/esbuild/_Old_CSS_Extractor.js +240 -0
  32. package/resources/processors/bundlers/js-bundler.js +201 -193
  33. package/resources/processors/bundlers/webpage-bundler.js +15 -0
  34. package/resources/processors/extractors/Extractor.js +10 -0
  35. package/resources/processors/extractors/js/css_and_js/AST_Node/CSS_And_JS_From_JS_String_Using_AST_Node_Extractor.js +239 -0
  36. package/resources/processors/extractors/js/css_and_js/CSS_And_JS_From_JS_String_Extractor.js +4 -0
  37. package/resources/processors/extractors/string/Pos_Span_String_Extractor.js +94 -0
  38. package/server.js +188 -5
  39. package/static-page-context.js +14 -0
  40. package/examples/box/box.css +0 -8
  41. package/examples/box/out_square_box_client.js +0 -48
  42. /package/examples/controls/{html-server-combo-box.js → __old/html-server-combo-box.js} +0 -0
  43. /package/examples/controls/{html-server-list.js → __old/html-server-list.js} +0 -0
  44. /package/examples/controls/{html-server-popup-menu-button.js → __old/html-server-popup-menu-button.js} +0 -0
  45. /package/examples/controls/{html-server-start-stop-toggle-button.js → __old/html-server-start-stop-toggle-button.js} +0 -0
  46. /package/examples/controls/{scs-arrow-button.js → __old/scs-arrow-button.js} +0 -0
  47. /package/examples/controls/{scs-date-picker.js → __old/scs-date-picker.js} +0 -0
  48. /package/examples/controls/{scs-file-browser.js → __old/scs-file-browser.js} +0 -0
  49. /package/examples/controls/{scs-item.js → __old/scs-item.js} +0 -0
  50. /package/examples/controls/{scs-month-arrow-selector.js → __old/scs-month-arrow-selector.js} +0 -0
  51. /package/examples/controls/{scs-start-stop-toggle-button.js → __old/scs-start-stop-toggle-button.js} +0 -0
  52. /package/examples/controls/{scs-tree.js → __old/scs-tree.js} +0 -0
  53. /package/examples/controls/{scs-year-arrow-selector.js → __old/scs-year-arrow-selector.js} +0 -0
@@ -0,0 +1,104 @@
1
+
2
+
3
+ // Making such specific classes with such long names seems kind of silly, but will help to keep the higher level code
4
+ // both explicit and easy to follow.
5
+
6
+ // These classes will do specific things, to specific things (in specific ways)
7
+
8
+ // Basically middleware that the app dev should not need to pay much attention to usually.
9
+
10
+
11
+
12
+
13
+ // And likely will have some other class (system), maybe assigners, to set the routes on the server / server router.
14
+ // Or within the website resource???
15
+
16
+ // So everything (main) that the server does will be done using various interchangable classes.
17
+ // Some classes will cover some very specific use cases.
18
+
19
+
20
+
21
+
22
+ const Assigner = require('../Assigner');
23
+
24
+ const {is_array} = require('lang-tools');
25
+
26
+ // And will have some very or less specific assigners for some other things.
27
+ // Like the compressed (text?) response headers.
28
+
29
+
30
+
31
+
32
+ class Single_Control_Webpage_Server_Static_Uncompressed_Response_Buffers_Assigner extends Assigner {
33
+
34
+ constructor(spec = {}) {
35
+ super(spec);
36
+ }
37
+
38
+ // assign to bundle....
39
+ // or array would be better.
40
+
41
+ // assign to (bundle) items in array.
42
+
43
+ async assign(arr_bundled_items) {
44
+ // go through them....
45
+
46
+ // Maybe check that the correct items are in the bundle.
47
+
48
+ // Perhaps check for 1 of each js, css, html
49
+ // And could use a specific other class to assign these.
50
+
51
+ // Should be OK to make classes for really specific things.
52
+ // At this part of the system / API, it's not necessary / important to limit complexity in that way.
53
+
54
+ // The goal is to provide a very simple high level interface. Powerful too.
55
+
56
+ // Could assign a static_route property to the items in the bundles.
57
+
58
+
59
+
60
+
61
+
62
+ if (is_array(arr_bundled_items)) {
63
+
64
+ for (const item of arr_bundled_items) {
65
+ //console.log('item', item);
66
+
67
+ const {type} = item;
68
+
69
+ // And need to create the uncompressed response buffer.
70
+
71
+ // // response_buffers.identity I think....
72
+
73
+ if (item.text) {
74
+ const buf_identity_response = Buffer.from(item.text, 'utf-8');
75
+
76
+ item.response_buffers = item.response_buffers || {};
77
+ item.response_buffers.identity = buf_identity_response;
78
+ } else {
79
+
80
+ }
81
+
82
+
83
+
84
+ //console.trace();
85
+ //throw 'stop';
86
+ }
87
+
88
+ } else {
89
+ console.trace();
90
+ throw 'stop';
91
+ }
92
+
93
+
94
+
95
+
96
+ }
97
+
98
+
99
+ }
100
+
101
+
102
+ module.exports = Single_Control_Webpage_Server_Static_Uncompressed_Response_Buffers_Assigner;
103
+
104
+
@@ -0,0 +1,19 @@
1
+
2
+
3
+ class Static_Bundle_Ready_To_Serve_Preparer {
4
+ constructor(spec) {
5
+
6
+ }
7
+ prepare(bundle) {
8
+
9
+
10
+ // Maybe only very specific code cases.
11
+
12
+
13
+
14
+
15
+ }
16
+ }
17
+
18
+
19
+ module.exports = Static_Bundle_Ready_To_Serve_Preparer;
@@ -0,0 +1,45 @@
1
+ const Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner = require('../../../assigners/static-compressed-response-buffers/Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner');
2
+ const Single_Control_Webpage_Server_Static_Uncompressed_Response_Buffers_Assigner = require('../../../assigners/static-uncompressed-response-buffers/Single_Control_Webpage_Server_Static_Uncompressed_Response_Buffers_Assigner');
3
+
4
+ const Single_Control_Webpage_Server_Static_Headers_Assigner = require('../../../assigners/static-headers/Single_Control_Webpage_Server_Static_Headers_Assigner');
5
+
6
+ const Single_Control_Webpage_Server_Static_Routes_Assigner = require('../../../assigners/static-routes/Single_Control_Webpage_Server_Static_Routes_Assigner');
7
+
8
+
9
+ class Static_Routes_Responses_Webpage_Bundle_Preparer {
10
+
11
+ constructor(spec = {}) {
12
+
13
+ // Probably should be able to operate in debug mode.
14
+ // Not minifying the js, and including the js debug symbols / map as well.
15
+
16
+ // But something else prepares the bundle....
17
+
18
+ //if (spec.debug !== undefined) this.debug = spec.debug;
19
+
20
+ this.routes_assigner = new Single_Control_Webpage_Server_Static_Routes_Assigner();
21
+
22
+ // And the uncompressed response buffer(s) assigner....?
23
+
24
+ this.uncompressed_response_buffers_assigner = new Single_Control_Webpage_Server_Static_Uncompressed_Response_Buffers_Assigner();
25
+ this.compressed_response_buffers_assigner = new Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner();
26
+ this.headers_assigner = new Single_Control_Webpage_Server_Static_Headers_Assigner();
27
+
28
+
29
+ }
30
+ async prepare(bundle) {
31
+ const {routes_assigner, uncompressed_response_buffers_assigner, compressed_response_buffers_assigner, headers_assigner} = this;
32
+
33
+ const arr_bundle_items = bundle._arr;
34
+
35
+ await routes_assigner.assign(arr_bundle_items);
36
+ await uncompressed_response_buffers_assigner.assign(arr_bundle_items);
37
+ await compressed_response_buffers_assigner.assign(arr_bundle_items);
38
+ await headers_assigner.assign(arr_bundle_items);
39
+
40
+ return bundle;
41
+
42
+ }
43
+ }
44
+
45
+ module.exports = Static_Routes_Responses_Webpage_Bundle_Preparer;
@@ -6,22 +6,42 @@
6
6
 
7
7
 
8
8
 
9
+ // Later on will probably make some new very specific classes to encapsulate things the HTTP_Webpage_Publisher does.
10
+
11
+ // Maybe have the publisher use Preparer or other (slightly) more specific classes.
12
+
13
+
14
+
15
+
16
+ // The publisher will need to do a few things / have some things done, but make it rely on the helpers
17
+ // and bundlers and extractors.
18
+
19
+ // The helpers maybe could call the bundlers and extractors.
20
+
21
+
22
+
23
+
24
+
25
+
9
26
 
10
27
 
11
28
  // A publisher handles HTTP requests.
12
29
 
13
30
  // This is going to take over some of the responsibilities of the old website resource, which was unfocused code that was
14
31
  // doing some of the main / most important parts of serving the website.
15
-
32
+ const jsgui_client = require('jsgui3-client');
16
33
 
17
34
  const HTTP_Publisher = require('./http-publisher');
35
+ const Server_Static_Page_Context = require('../static-page-context');
36
+
37
+ const HTTP_Webpageorsite_Publisher = require('./http-webpageorsite-publisher');
18
38
  const {obs} = require('fnl');
19
39
 
20
40
  // May want / need to more carefully and specifically define APIs.
21
41
  // It's nice to have classes for specific things like this, but need to make them do what is needed.
22
42
  // Maybe get a 'Website' object or control ready to be served.
23
43
  //
24
-
44
+ const Static_Routes_Responses_Webpage_Bundle_Preparer = require('./helpers/preparers/static/bundle/Static_Routes_Responses_Webpage_Bundle_Preparer');
25
45
 
26
46
 
27
47
 
@@ -67,7 +87,18 @@ obs((next, complete, error) => {
67
87
  // Should include or use various other publishers, such as html or js?
68
88
 
69
89
 
70
- class HTTP_Webpage_Publisher extends HTTP_Publisher {
90
+ // HTTP_Static_Webpage_Publisher perhaps....
91
+
92
+
93
+ // Also have various Authorisers ...
94
+ // Have Authenticators ...
95
+
96
+
97
+
98
+
99
+
100
+
101
+ class HTTP_Webpage_Publisher extends HTTP_Webpageorsite_Publisher {
71
102
 
72
103
  // Website generally serves JS from a single address.
73
104
  // Webpage could have its specific JS.
@@ -95,6 +126,16 @@ class HTTP_Webpage_Publisher extends HTTP_Publisher {
95
126
  }
96
127
  });
97
128
 
129
+
130
+
131
+
132
+ // But like the website publisher, this would need to bundle the page (JS, CSS, maybe more).
133
+ // Consider that an SPA may reference images. May not exactly be one page in some ways.
134
+
135
+
136
+
137
+
138
+
98
139
  // Probably best to come up with a bundle here, or at an early stage.
99
140
 
100
141
  // .prepare_bundle?
@@ -108,13 +149,448 @@ class HTTP_Webpage_Publisher extends HTTP_Publisher {
108
149
 
109
150
  // Bundling and compiling web content seems like a better thing to get working before serving (or attempting to serve) it.
110
151
  // .build?
152
+
153
+ /*
111
154
  setTimeout(() => {
155
+
156
+
112
157
  this.raise('ready');
113
158
  }, 0);
114
159
 
160
+ */
161
+
162
+ this.static_routes_responses_webpage_bundle_preparer = new Static_Routes_Responses_Webpage_Bundle_Preparer();
163
+
164
+ (async() => {
165
+
166
+ const res_get_ready = await this.get_ready();
167
+
168
+
169
+ // Is the HTML to be static or regenerated on page calls?
170
+ // Want an easy way to specify it.
171
+
172
+
173
+
174
+ // Then set things (a single static route???) up for the webpage.
175
+ // Be very explicit with classes to do specific things like this so they will be easier to find and change.
176
+
177
+ // Should render the webpage (once)
178
+ // Maybe use a class on a higher level to choose this important rendering / caching setting.
179
+
180
+ // Maybe the server could render multiple times over a few minutes before deciding it's not going to change.
181
+
182
+ // Though telling the server it's static would help in some / many cases.
183
+ // Have it as a sensible default depending on the situation.
184
+
185
+ // Could even look at the controls to see if anything is non-static.
186
+ // Or mark things somehow.
187
+
188
+ // At least want to make this setting very clear in the future.
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+ this.raise('ready', res_get_ready);
197
+
198
+ })();
199
+
200
+ }
201
+
202
+ async get_ready() {
203
+ //await super.get_ready();
204
+
205
+ const {static_routes_responses_webpage_bundle_preparer} = this;
206
+
207
+
208
+ // Its a bundle....
209
+ const webpage_or_website_res_get_ready = await super.get_ready();
210
+
211
+ //console.log('webpage_or_website_res_get_ready', webpage_or_website_res_get_ready);
212
+
213
+
214
+
215
+
216
+ const render_webpage = async () => {
217
+
218
+ // Activate it or not.... As in serve active JSGUI control content. HTML ready to be activated on the client.
219
+
220
+ // .active();
221
+ // Generally would want that as standard.
222
+
223
+ // Need to be very clear about generating active content on the server side.
224
+ // Ready to be activated on the client-side.
225
+ // Though could possibly activate using CSS classes.
226
+
227
+
228
+
229
+
230
+ // Probably best to make a Server_Page_Context here.
231
+ // Server_Static_Page_Context perhaps.
232
+
233
+
234
+
235
+ // Maybe a class to render the single page into the bundle?
236
+ // Maybe only worth doing when there become (many) more options and divisions seem clearer.
237
+
238
+ const {webpage} = this;
239
+ const Ctrl = webpage.content;
240
+
241
+ // In business activating it with the page context.
242
+
243
+ const static_page_context = new Server_Static_Page_Context();
244
+
245
+ const ctrl = new Ctrl({
246
+ context: static_page_context
247
+ });
248
+
249
+ // Webpage_CSS_JS_HTML_Bundle_Ready_To_Serve_Preparer
250
+
251
+ if (ctrl.head && ctrl.body) {
252
+
253
+
254
+ // Create the CSS link control
255
+
256
+ //console.log('jsgui_client.controls', jsgui_client.controls);
257
+
258
+ //console.log('jsgui_client.controls', Object.keys(jsgui_client.controls));
259
+
260
+ const ctrl_css_link = new jsgui_client.controls.link({
261
+ context: static_page_context
262
+ });
263
+ ctrl_css_link.dom.attributes.rel = 'stylesheet';
264
+ ctrl_css_link.dom.attributes.href = '/css/css.css';
265
+
266
+ ctrl.head.add(ctrl_css_link);
267
+
268
+
269
+ // Then add the JS Script ref (with href) to the (end of the) body.
270
+
271
+ // Content_Incorporator perhaps???
272
+ // Bundle_Content_Incorporator?
273
+
274
+ // Will be worth making classes to do this when there is more variety of settings and operations.
275
+
276
+ const ctrl_js_script_link = new jsgui_client.controls.script({
277
+ context: static_page_context
278
+ });
279
+
280
+ ctrl_js_script_link.dom.attributes.src = '/js/js.js';
281
+
282
+ ctrl.body.add(ctrl_js_script_link);
283
+
284
+ // <script src="myscripts.js"></script>
285
+
286
+
287
+ //console.log('!!ctrl.head', !!ctrl.head);
288
+ //console.log('!!ctrl.body', !!ctrl.body);
289
+
290
+ // add the css ref to the head, then the script ref to the body.
291
+
292
+ // ctrl.body????
293
+
294
+ // or add it to the body....
295
+ // ctrl.head.add(new jsgui.script(...))
296
+
297
+
298
+ // Adding script references...?
299
+
300
+ // or .activate with it working on the server...?
301
+
302
+
303
+
304
+ // Could have settings which determine which HTML elements get activated into controls, which don't.
305
+ ctrl.active();
306
+
307
+
308
+
309
+ // .active should do enough I think....
310
+
311
+ // Server_Page_Context being the context of a publisher doing a one-time static rendering of a only page's HTML
312
+ // Does seem like the Servier_Page_Context will be needed for this to work properly.
313
+ // Want to hide some details that won't need changing from the top level API.
314
+ // All kinds of things like page contexts will help in the background, they should be there to make
315
+ // things easier.
316
+
317
+
318
+
319
+
320
+
321
+
322
+ // do we need a Server_Page_Context first?
323
+
324
+ const html = await ctrl.all_html_render();
325
+
326
+ // Produces the HTML fairly well here....
327
+
328
+
329
+ // Want to provide these as static resources to the server / router.
330
+ // The publisher itself should not need to handle HTTP requests each time.
331
+ // Keep the option for that though, it may help with some systems, more dynamic, not static responses.
332
+
333
+ // Focus a lot on ease of use to set up servers with sensible and powerful defaults.
334
+ // Also not requiring a specific directory or project structure.
335
+ // Serving a simple app with a simple JS file.
336
+
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+ //console.log('html', html);
345
+
346
+ //console.trace();
347
+ //throw 'NYI';
348
+
349
+ return html;
350
+
351
+
352
+
353
+ } else {
354
+ console.trace();
355
+ throw 'NYI';
356
+ }
357
+
358
+ }
359
+
360
+ // Maybe a Webpage_Rendering_Preparer could do this even?
361
+
362
+ // Webpage_Renderer even
363
+ // And it could render jsx, (other react?),
364
+
365
+
366
+ const webpage_html = await render_webpage();
367
+
368
+ const o_webpage_html = {
369
+ type: 'HTML',
370
+ extension: 'html',
371
+ text: webpage_html
372
+ }
373
+
374
+ webpage_or_website_res_get_ready.push(o_webpage_html);
375
+
376
+ //console.log('webpage_or_website_res_get_ready._arr.length', webpage_or_website_res_get_ready._arr.length);
377
+
378
+
379
+ await static_routes_responses_webpage_bundle_preparer.prepare(webpage_or_website_res_get_ready);
380
+
381
+ // Then publish it to the router...?
382
+ // server.serve_prepared_static_routes_bundle ?????
383
+ return webpage_or_website_res_get_ready;
384
+
385
+
386
+
387
+ // But then the bundle with static routes should be given / provided to the server.
388
+ // Would be nice to end the responsibility of the Publisher once the final prepared bundle with static
389
+ // routes and static content (compressed in different ways, uncompressed buffer there too) and have the
390
+ // Server or Server Router do the rest.
391
+
392
+ // Improve handling of prepared to serve (HTTP response) bundles, making it easy to tell the server to use them.
393
+
394
+ // Maybe make a more advanced HTTP_Responder baked into the server.
395
+ // Or an interchagable class that does it, used within the server.
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+
404
+
405
+ // Then send it off to the final stage bundler / Final_Stage_Bundle_Preparer_That_Prepares_Static_Routes_Responses
406
+
407
+ // Some very long and explicit class names seem appropriate.
408
+
409
+ // Final_Stage_Webpage_Bundle_Preparer_Of_Static_Routes_Responses
410
+
411
+ // Static_Routes_Responses_Webpage_Bundle_Preparer
412
+ // That should be fine doing the very last part.
413
+
414
+ // But then another component to assign these static routes to the router?
415
+ // Or maybe that's easy enough to do with a function call (or a few).
416
+
417
+ // Prepared_Responses_Cache???
418
+
419
+ // Don't want to make big changes to the router and server itself right now.
420
+ // Though an extra function (or a few) could help within Server_Router.
421
+ // Or not the router, but do it here in the handle_http function call.
422
+ // With the router just routing those URLs here.
423
+
424
+ // Does seem better architecture for the publisher to hand the responsibility off to some (other) server component.
425
+
426
+
427
+
428
+
429
+
430
+
431
+
432
+
433
+ // then add that webpage html to the bundle.
434
+
435
+
436
+
437
+ // Then add a new static HTML item to the bundle.
438
+
439
+
440
+
441
+ //console.log('webpage_html', webpage_html);
442
+
443
+
444
+ // Add it to the bundle
445
+ // Prepare the bundle to serve with static routes
446
+ // Give the prepared bundle to the server (router).
447
+
448
+ // Then see it running small and increasingly large apps.
449
+
450
+
451
+
452
+
453
+
454
+ // Add the webpage HTML to the bundle.
455
+ // Then call the static routes assigner on the array in the bundle (._arr)
456
+
457
+ // Then get server_static_route_prepared_responses.
458
+
459
+ // Then maybe some other class assigns these prepared responses to the server or server router.
460
+
461
+ // When preparing static responses, should prepare them gzipped, brotlied, and uncompressed.
462
+ // Though will (always?) use UTF8, will make that explicit and allow for other encoding types.
463
+
464
+
465
+
466
+ // Preparer or Bundle_Perparer could be a final / further stage.
467
+ // And would itself use other classes internally with very specific functionality
468
+
469
+
470
+
471
+
472
+
473
+
474
+ // Then it will be about assembling the routing instructions.
475
+
476
+ // So then different conventions / systems could be used to assign static routes.
477
+ // And very clear in the code what is going on (through use of very explicit and specific class / classes that do this).
478
+
479
+
480
+ // Server_Static_Routes_Assigner perhaps.
481
+ // subclass:
482
+ // Single_Control_Webpage_Server_Static_Routes_Assigner
483
+
484
+ // Assigning the static routes with a class makes sense, could hard-code things here but want better options that can be interchanged
485
+ // and modified and improved separately.
486
+
487
+
488
+
489
+ // Bundle_To_Serve_Statically_Preparer
490
+ // .prepare(bundle)
491
+
492
+ // Really simple function calling syntax, really clear responsibilities, and if any wind up not being used then that will be
493
+ // fine.
494
+
495
+
496
+
497
+
498
+
499
+ // Server_Prepared_Static_Routes_Responses
500
+
501
+
502
+ // publishers/publishing-tools perhaps....?
503
+
504
+ // Or create a bundle that then includes the HTML document.
505
+ // Could add headers and compressed buffers (to write to responses) to the existing bundle items.
506
+
507
+
508
+ // The system as a whole here is not massively complex, but moderately.
509
+ // Changable minute details will be finite in this implementation but infinite when it comes to extending and
510
+ // making subcategories especially in terms of how things are done internally to that system.
511
+
512
+
513
+
514
+
515
+
516
+
517
+
518
+
519
+
520
+ //console.trace();
521
+ //throw 'NYI';
522
+
523
+
524
+
525
+
526
+ // Probably need to call a preparer???
527
+ // Need (something to) server the static things, but also if the rendered HTML itself is static, having that pre-rendered
528
+ // would be best.
529
+
530
+
531
+ // Should make the rendering more abstract (less specific code in Server itself) and be very clear indeed what the classes
532
+ // do by naming them well.
533
+
534
+ // But the publisher itself does handle the HTTP.
535
+ // That possibly should not always be the case.
536
+
537
+
538
+ // Website_Static_Responses_Preparer
539
+ // Webpage_Static_Responses_Preparer
540
+
541
+
542
+
543
+ // HTTP_Response_Preparer could be a useful class and one to subclass from.
544
+
545
+ // HTTP_Static_Response_Preparer
546
+
547
+
548
+
549
+
550
+
551
+
552
+
553
+
554
+ // Or maybe insert references to the bundled content appropriately into the HTML.
555
+
556
+ // At the end of the body may be best for the JS???
557
+ // Want nice options for this.
558
+
559
+ // Then here we need to create static HTML....
560
+
561
+
562
+
115
563
  }
564
+
565
+ // The publisher should not (always / usually) handle the HTTP calls.
566
+ // It may be worth having architecture that allows for it when publishing dynamic content.
567
+ // When publishing static content it's better to pass that static content onto the server. (specific static content for specific routes / urls)
568
+ // Maybe dict or map lookup is better for those static content URLs.
569
+
570
+
571
+
572
+
573
+
574
+
116
575
  handle_http(req, res) {
117
576
 
577
+
578
+ // Don't (automatically) connect this function.
579
+
580
+ console.log('HTTP_Webpage_Publisher handle_http');
581
+ console.log('req.url', req.url);
582
+
583
+ // Should not (need to?) handle the HTTP here.
584
+
585
+ // Ideally the Webpage Publisher will have already bundled all the static files.
586
+
587
+
588
+ // HTTP_Webpage_Request_Handler perhaps?
589
+
590
+
591
+
592
+
593
+
118
594
  // Is the webpage rendered?
119
595
  // Does the webpage require rendering?
120
596
  // Seems like the main question to ask here.
@@ -133,6 +609,10 @@ class HTTP_Webpage_Publisher extends HTTP_Publisher {
133
609
 
134
610
  // Could get info on what needs to be bundled from the webpage object itself.
135
611
  // A Webpage objects could have 'requirements', or 'build requirements'.
612
+ // If such things are needed, then make classes for them.
613
+
614
+
615
+
136
616
 
137
617
 
138
618