jsgui3-server 0.0.97 → 0.0.99

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 (54) 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 +183 -0
  6. package/examples/controls/1) window/server.js +113 -0
  7. package/examples/controls/{scs-month-view.js → __old/scs-month-view.js} +0 -1
  8. package/http/responders/HTTP_Responder.js +16 -0
  9. package/http/responders/static/Static_Route_HTTP_Responder.js +106 -0
  10. package/package.json +9 -8
  11. package/page-context.js +15 -0
  12. package/publishers/helpers/assigners/Assigner.js +11 -0
  13. package/publishers/helpers/assigners/static-compressed-response-buffers/Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner.js +150 -0
  14. package/publishers/helpers/assigners/static-headers/Single_Control_Webpage_Server_Static_Headers_Assigner.js +110 -0
  15. package/publishers/helpers/assigners/static-routes/Single_Control_Webpage_Server_Static_Routes_Assigner.js +92 -0
  16. package/publishers/helpers/assigners/static-uncompressed-response-buffers/Single_Control_Webpage_Server_Static_Uncompressed_Response_Buffers_Assigner.js +104 -0
  17. package/publishers/helpers/preparers/static/bundle/Ready_To_Serve_Preparer.js +19 -0
  18. package/publishers/helpers/preparers/static/bundle/Static_Routes_Responses_Webpage_Bundle_Preparer.js +38 -0
  19. package/publishers/http-publisher.js +4 -2
  20. package/publishers/http-webpage-publisher.js +480 -3
  21. package/publishers/http-webpageorsite-publisher.js +336 -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 +329 -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 +174 -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 +176 -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 -28862
  42. /package/examples/controls/{_html-server-color-palette.js → __old/_html-server-color-palette.js} +0 -0
  43. /package/examples/controls/{html-server-combo-box.js → __old/html-server-combo-box.js} +0 -0
  44. /package/examples/controls/{html-server-list.js → __old/html-server-list.js} +0 -0
  45. /package/examples/controls/{html-server-popup-menu-button.js → __old/html-server-popup-menu-button.js} +0 -0
  46. /package/examples/controls/{html-server-start-stop-toggle-button.js → __old/html-server-start-stop-toggle-button.js} +0 -0
  47. /package/examples/controls/{scs-arrow-button.js → __old/scs-arrow-button.js} +0 -0
  48. /package/examples/controls/{scs-date-picker.js → __old/scs-date-picker.js} +0 -0
  49. /package/examples/controls/{scs-file-browser.js → __old/scs-file-browser.js} +0 -0
  50. /package/examples/controls/{scs-item.js → __old/scs-item.js} +0 -0
  51. /package/examples/controls/{scs-month-arrow-selector.js → __old/scs-month-arrow-selector.js} +0 -0
  52. /package/examples/controls/{scs-start-stop-toggle-button.js → __old/scs-start-stop-toggle-button.js} +0 -0
  53. /package/examples/controls/{scs-tree.js → __old/scs-tree.js} +0 -0
  54. /package/examples/controls/{scs-year-arrow-selector.js → __old/scs-year-arrow-selector.js} +0 -0
@@ -0,0 +1,240 @@
1
+
2
+
3
+ // Could split the CSS from JS here.
4
+ // Extractors are a different thing to bundlers.
5
+
6
+
7
+
8
+
9
+ // Probably better to remove this / use the specific extractor that's named / available / gets used.
10
+
11
+
12
+
13
+
14
+ const {bundle_css_from_js_str} = require('../../css-bundler');
15
+
16
+ const {obs} = require('fnl');
17
+
18
+ const Core_JS_Non_Minifying_Bundler_Using_ESBuild = require('./Core_JS_Non_Minifying_Bundler_Using_ESBuild');
19
+
20
+
21
+ // It is a Bundler though....
22
+
23
+ // Or not???
24
+
25
+ // And Extractor?
26
+ // Separator???
27
+
28
+ // An Extractor processor I think.
29
+
30
+ const Extractor = require('../../../extractors/Extractor');
31
+
32
+
33
+ class _Old_CSS_Extractor extends Extractor {
34
+
35
+ // Maybe should use a reference to the file itself?
36
+ // Maybe needs to use jsdom even?
37
+
38
+ // Will first try with existing code and then see about optimisations.
39
+
40
+
41
+
42
+
43
+ constructor(spec) {
44
+ super();
45
+
46
+ console.trace();
47
+ throw 'Deprecating this particular class, use other extractor classes in the extractors dir.'
48
+
49
+ this.core_js_non_minifying_bundler = new Core_JS_Non_Minifying_Bundler_Using_ESBuild();
50
+
51
+ }
52
+
53
+ separate_css_and_js(js_file_path) {
54
+
55
+ const {core_js_non_minifying_bundler} = this;
56
+
57
+
58
+ console.log('js_file_path', js_file_path);
59
+
60
+ const obs_res = obs(async(next, complete, error) => {
61
+
62
+ // Then we need to use the core js bundler....
63
+
64
+ const core_js_non_minifying_bundler_obs_res = core_js_non_minifying_bundler.bundle(js_file_path);
65
+
66
+ // Only one piece of data...?
67
+
68
+ const arr_no_minifying_bundler_data = [];
69
+
70
+ core_js_non_minifying_bundler_obs_res.on('next', data => {
71
+
72
+ //console.log('core js (non-minifying) bundler next event data:', data);
73
+
74
+ arr_no_minifying_bundler_data.push(data);
75
+
76
+
77
+
78
+
79
+ });
80
+
81
+ core_js_non_minifying_bundler_obs_res.on('complete', async() => {
82
+ // This overall function not yet complete though....
83
+
84
+ console.log('arr_no_minifying_bundler_data', arr_no_minifying_bundler_data);
85
+
86
+ // Then use that Bundle object....
87
+ // Should represent a single JS file I think.
88
+
89
+ // Have plenty of checks in these various classes, though keep the overall code simple, but the
90
+ // structure will be somewhat complex, like the inner working of the app which it represents.
91
+
92
+
93
+ if (arr_no_minifying_bundler_data.length === 1) {
94
+ const bundle_item = arr_no_minifying_bundler_data[0]._arr[0];
95
+
96
+ console.log('bundle_item', bundle_item);
97
+
98
+ if (bundle_item.type === 'JavaScript') {
99
+
100
+ const {text} = bundle_item;
101
+
102
+ // Then run it through the CSS extraction algorithm.
103
+ // Having that code in the relevant class would help.
104
+
105
+ console.log('pre extract css from bundled unminified js');
106
+
107
+ // Reimplementing it as an Extractor that uses ESBuild will / may help.
108
+
109
+
110
+ // Would be worth making an AST_Node version of this though, as that's what it uses.
111
+ // May well be possible / better to use other methods / regexes / parser and AST.
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+ const r1 = await bundle_css_from_js_str(text);
121
+ console.log('post extract css from bundled unminified js');
122
+
123
+ // That bundle algorithm is a little slow.
124
+ // It does work well though.
125
+
126
+ // Maybe using regexes on the JS would work better.
127
+
128
+
129
+ console.log('r1', r1);
130
+
131
+ console.trace();
132
+ throw 'NYI';
133
+
134
+
135
+
136
+ // Then run it through the CSS extractor function / class.
137
+
138
+ // Perhaps we should make and use an ESBuild specific CSS extractor???
139
+ // Should the current extractor function be too slow....
140
+
141
+ // Including the standard / default jsgui3 css as well....
142
+ // May be worth making more classes to do individual parts of it.
143
+ // And have overall bundling class(es) join them together with simple syntax using the relevant classes to do the job.
144
+
145
+
146
+ // Worth making the code somewhat longwinded / complex if it makes it easy to follow
147
+ // Since it's doing some complex things (at least complex considering all eventual options) the structure
148
+ // representing that and being able to accommodate it will help.
149
+
150
+ // The Publisher should (probably) do the reference insertion.
151
+ // Though a JS_And_CSS_References_Inserter may be useful structurally to see what's going on.
152
+ // Would insert the references within the HTML JSGUI3 Control within the right place(s).
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+ } else {
169
+ console.trace();
170
+ throw 'Unexpected bundle item type: ' + bundle_item.type;
171
+ }
172
+
173
+
174
+
175
+
176
+ } else {
177
+ console.trace();
178
+ throw 'NYI';
179
+ }
180
+
181
+
182
+
183
+
184
+
185
+ });
186
+
187
+ // Then when it is complete...???
188
+
189
+
190
+
191
+
192
+ });
193
+
194
+ return obs_res;
195
+
196
+ /*
197
+ obs_res.on('next', data => {
198
+ console.log('data', data);
199
+ })
200
+ */
201
+
202
+
203
+ ///const res_core_bundle =
204
+
205
+ // Maybe should compile / bundle the file with esbuild.
206
+ // Want it to look through all the CSS throughout JSGUI JS and include it in the CSS for the client.
207
+ // Should be very convenient for including CSS in the JS. Sensible defaults.
208
+
209
+ // ESBuild_Wrapper perhaps.
210
+
211
+ // Core_JS_Bundler_Using_ESBuild
212
+
213
+ // JS_Bundler_Using_ESBuild
214
+
215
+ // Make it async or observable....
216
+
217
+ // Observable may be the best thing to use, maybe will improve observable API, possibly specifying how it combines results.
218
+
219
+ // Looks like we first need to get the JS all as a bundle.
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+ }
235
+
236
+
237
+ }
238
+
239
+
240
+ module.exports = _Old_CSS_Extractor;