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.
- package/examples/box/{square_box_client.js → 1) square box/client.js } +40 -5
- package/examples/box/{square_box.js → 1) square box/server.js } +10 -3
- package/examples/box/2) twenty square boxes/css flex wrap/client.js +248 -0
- package/examples/box/2) twenty square boxes/css flex wrap/server.js +113 -0
- package/examples/controls/1) window/client.js +184 -0
- package/examples/controls/1) window/server.js +114 -0
- package/examples/controls/{_html-server-color-palette.js → __old/_html-server-color-palette.js} +2 -2
- package/examples/controls/{scs-month-view.js → __old/scs-month-view.js} +0 -1
- package/http/responders/HTTP_Responder.js +16 -0
- package/http/responders/static/Static_Route_HTTP_Responder.js +106 -0
- package/package.json +9 -8
- package/page-context.js +15 -0
- package/publishers/helpers/assigners/Assigner.js +11 -0
- package/publishers/helpers/assigners/static-compressed-response-buffers/Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner.js +150 -0
- package/publishers/helpers/assigners/static-headers/Single_Control_Webpage_Server_Static_Headers_Assigner.js +110 -0
- package/publishers/helpers/assigners/static-routes/Single_Control_Webpage_Server_Static_Routes_Assigner.js +92 -0
- package/publishers/helpers/assigners/static-uncompressed-response-buffers/Single_Control_Webpage_Server_Static_Uncompressed_Response_Buffers_Assigner.js +104 -0
- package/publishers/helpers/preparers/static/bundle/Ready_To_Serve_Preparer.js +19 -0
- package/publishers/helpers/preparers/static/bundle/Static_Routes_Responses_Webpage_Bundle_Preparer.js +45 -0
- package/publishers/http-webpage-publisher.js +483 -3
- package/publishers/http-webpageorsite-publisher.js +343 -0
- package/publishers/http-website-publisher.js +51 -2
- package/resources/compile/server-resource-compilation.js +2 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_0-Core.js +26 -0
- package/resources/processors/bundlers/css-bundler.js +24 -1
- package/resources/processors/bundlers/js/JS_Bundler.js +52 -0
- package/resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild.js +389 -0
- package/resources/processors/bundlers/js/esbuild/Bundler_Using_ESBuild.js +9 -0
- package/resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild.js +186 -0
- package/resources/processors/bundlers/js/esbuild/Core_JS_Single_File_Minifying_Bundler_Using_ESBuild.js +191 -0
- package/resources/processors/bundlers/js/esbuild/_Old_CSS_Extractor.js +240 -0
- package/resources/processors/bundlers/js-bundler.js +201 -193
- package/resources/processors/bundlers/webpage-bundler.js +15 -0
- package/resources/processors/extractors/Extractor.js +10 -0
- package/resources/processors/extractors/js/css_and_js/AST_Node/CSS_And_JS_From_JS_String_Using_AST_Node_Extractor.js +239 -0
- package/resources/processors/extractors/js/css_and_js/CSS_And_JS_From_JS_String_Extractor.js +4 -0
- package/resources/processors/extractors/string/Pos_Span_String_Extractor.js +94 -0
- package/server.js +188 -5
- package/static-page-context.js +14 -0
- package/examples/box/box.css +0 -8
- package/examples/box/out_square_box_client.js +0 -48
- /package/examples/controls/{html-server-combo-box.js → __old/html-server-combo-box.js} +0 -0
- /package/examples/controls/{html-server-list.js → __old/html-server-list.js} +0 -0
- /package/examples/controls/{html-server-popup-menu-button.js → __old/html-server-popup-menu-button.js} +0 -0
- /package/examples/controls/{html-server-start-stop-toggle-button.js → __old/html-server-start-stop-toggle-button.js} +0 -0
- /package/examples/controls/{scs-arrow-button.js → __old/scs-arrow-button.js} +0 -0
- /package/examples/controls/{scs-date-picker.js → __old/scs-date-picker.js} +0 -0
- /package/examples/controls/{scs-file-browser.js → __old/scs-file-browser.js} +0 -0
- /package/examples/controls/{scs-item.js → __old/scs-item.js} +0 -0
- /package/examples/controls/{scs-month-arrow-selector.js → __old/scs-month-arrow-selector.js} +0 -0
- /package/examples/controls/{scs-start-stop-toggle-button.js → __old/scs-start-stop-toggle-button.js} +0 -0
- /package/examples/controls/{scs-tree.js → __old/scs-tree.js} +0 -0
- /package/examples/controls/{scs-year-arrow-selector.js → __old/scs-year-arrow-selector.js} +0 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const {each, Router, tof} = require('jsgui3-html');
|
|
5
|
+
const HTTP_Publisher = require('./http-publisher');
|
|
6
|
+
const {obs} = require('fnl');
|
|
7
|
+
|
|
8
|
+
// The Webpage bundler should be able to come up with the compiled JS and CSS, maybe even a favicon.
|
|
9
|
+
|
|
10
|
+
// HTTP_Webpageorsite_Publisher
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
const Website = require('jsgui3-website');
|
|
15
|
+
|
|
16
|
+
const Webpage_Bundler = require('../resources/processors/bundlers/webpage-bundler');
|
|
17
|
+
|
|
18
|
+
// The webpage bundler - probably will be quite simple to the website bundler.
|
|
19
|
+
// Think the webpage bundler should bundle static HTML content from the server into the bundle.
|
|
20
|
+
|
|
21
|
+
// Better in general not to regenerate all HTML for each page request.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const JS_Bundler = require('../resources/processors/bundlers/js-bundler');
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const Bundle = require('../resources/processors/bundlers/bundle');
|
|
28
|
+
|
|
29
|
+
// Now it's the very basics of a website publisher. Quite flexible but could do with more.
|
|
30
|
+
// Better integration with bundler
|
|
31
|
+
// Rendering webpages that are dynamic and therefore not bundled (eg user specific content).
|
|
32
|
+
// Though the js could be bundled. Maybe some of the controls could be bundled? Or semi-bundled?
|
|
33
|
+
|
|
34
|
+
// HTTP_Webpage_Publisher could be interesting.
|
|
35
|
+
// The Website Publisher could make use of some of its functionality.
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// Handling HTTP / bundling for a specific page could be cool.
|
|
39
|
+
|
|
40
|
+
// A Webpage Publisher may be simpler and better to work on in the short term.
|
|
41
|
+
// Maybe would not need to be (as) concerned with routing.
|
|
42
|
+
// Could be useful for publishing a SPA of course, kind of a website but as a single page.
|
|
43
|
+
|
|
44
|
+
// This seems more like the server router these days
|
|
45
|
+
// The main server router seems to pass everything to this - maybe that will change.
|
|
46
|
+
|
|
47
|
+
// Maybe give it some kind of Website_Server????
|
|
48
|
+
|
|
49
|
+
// Have the Website_Server use the Website_Publisher????
|
|
50
|
+
|
|
51
|
+
// Need to somewhat separate concerns.
|
|
52
|
+
|
|
53
|
+
// Publisher here could be simple in terms of bundling, and then giving the paths to the router.
|
|
54
|
+
// And could have really simple code implementation of doing just that.
|
|
55
|
+
|
|
56
|
+
// This basically can be simple....
|
|
57
|
+
// But make the classes' structures more complicated where necessary to accommodate.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
// Could be just a few lines of logic probably, at least the simplest core implementation.
|
|
61
|
+
|
|
62
|
+
// Think the server or the website already has a router, so have the website resource's router do the routing.
|
|
63
|
+
// Maybe upgrade the routers to handle premade (compressed) responses.
|
|
64
|
+
|
|
65
|
+
// Maybe better to bundle and publish resources.
|
|
66
|
+
// resource-processors in its own dir?
|
|
67
|
+
// as in it's not actually part of resources?
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
// Need to basically make this do very little.
|
|
73
|
+
|
|
74
|
+
// Publish (website, server_router)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
// Or publish it only under some URLs / domains....?
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
// Probably is worth by default having it use the HTTP_Website_Publisher with really simple server setups.
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
// Extend HTTP_Web_Item_Publisher HTTP_Web_Page_Or_Site_Publisher (synonym) ????
|
|
88
|
+
|
|
89
|
+
// Share functionality between webpage and website where useful.
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class HTTP_Webpageorsite_Publisher extends HTTP_Publisher {
|
|
96
|
+
|
|
97
|
+
constructor(spec) {
|
|
98
|
+
super(spec);
|
|
99
|
+
|
|
100
|
+
if (spec.debug !== undefined) this.debug = spec.debug;
|
|
101
|
+
|
|
102
|
+
// But then some properties to do with the js client(s?) file path.
|
|
103
|
+
|
|
104
|
+
// This should be fairly simple in terms of making use of the bundler, then providing the server (maybe the router component)
|
|
105
|
+
// with the content to serve.
|
|
106
|
+
|
|
107
|
+
// js_client_file_path ??? client_js_file_path???
|
|
108
|
+
|
|
109
|
+
let src_path_client_js;
|
|
110
|
+
if (spec.disk_path_client_js) {
|
|
111
|
+
src_path_client_js = spec.disk_path_client_js;
|
|
112
|
+
} else if (spec.src_path_client_js) {
|
|
113
|
+
src_path_client_js = spec.src_path_client_js;
|
|
114
|
+
} else if (spec.source_path_client_js) {
|
|
115
|
+
src_path_client_js = spec.source_path_client_js;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// or src_path_client_js as well...
|
|
119
|
+
|
|
120
|
+
Object.defineProperty(this, 'disk_path_client_js', {get: () => src_path_client_js, set: (value) => src_path_client_js = value});
|
|
121
|
+
Object.defineProperty(this, 'src_path_client_js', {get: () => src_path_client_js, set: (value) => src_path_client_js = value});
|
|
122
|
+
Object.defineProperty(this, 'source_path_client_js', {get: () => src_path_client_js, set: (value) => src_path_client_js = value});
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
// But then need to have some things that get it ready on this level...
|
|
126
|
+
|
|
127
|
+
// Maybe need a get_ready (async or obs) function....
|
|
128
|
+
|
|
129
|
+
this.js_bundler = new JS_Bundler({
|
|
130
|
+
'debug': this.debug || false
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async get_ready() {
|
|
137
|
+
|
|
138
|
+
const {js_bundler} = this;
|
|
139
|
+
//await super.get_ready(); // Does not have one
|
|
140
|
+
|
|
141
|
+
// Then bundle (extract (process) everything in and referenced by the JS file (s) into a bundle object)
|
|
142
|
+
// Maybe that bundle object will contain some (static) routing instructions.
|
|
143
|
+
|
|
144
|
+
// The publisher could provide the server with a set of static routing instructions.
|
|
145
|
+
// A (simple) Static_Routing_Instructions class could be helpful, and then could be extended, swapped, optimised etc.
|
|
146
|
+
|
|
147
|
+
// HTTP_Static_Routing_Instructions even.
|
|
148
|
+
// Want simple code, but have it neatly wrap existing class / standard JS object. Eg facade around array even.
|
|
149
|
+
// A type of server input or server instruction or server(router) setting.
|
|
150
|
+
|
|
151
|
+
console.log('web page or site async get_ready called');
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
// Single js client for whole website??? Could work, not so sure.
|
|
155
|
+
// Appropriate defalt setting (using v explicit classes) will help it to work.
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
const {src_path_client_js} = this;
|
|
160
|
+
|
|
161
|
+
//console.log('src_path_client_js', src_path_client_js);
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
// The js_bundler may need to operate in 'debug' mode.
|
|
165
|
+
|
|
166
|
+
const js_bundler_res = await js_bundler.bundle(src_path_client_js);
|
|
167
|
+
// Should also get the CSS from it....
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
//console.log('js_bundler_res', js_bundler_res);
|
|
172
|
+
|
|
173
|
+
// Res of length 2 - with a css item and a js item.
|
|
174
|
+
// js item (probably?) first.
|
|
175
|
+
|
|
176
|
+
if (js_bundler_res.length === 1) {
|
|
177
|
+
const bundle = js_bundler_res[0];
|
|
178
|
+
|
|
179
|
+
const css_item = bundle._arr.find((item) => item.type === 'CSS');
|
|
180
|
+
const js_item = bundle._arr.find((item) => item.type === 'JavaScript');
|
|
181
|
+
|
|
182
|
+
if (css_item && js_item) {
|
|
183
|
+
|
|
184
|
+
return bundle;
|
|
185
|
+
|
|
186
|
+
// Let's but the HTML into the bundle too...
|
|
187
|
+
// But could mark the bundle or the HTML saying it needs further preparation (reference or code inserts)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
// Should first include references to the CSS and JS in the HTML (Control(s))
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
// generate (render) the HTML.
|
|
195
|
+
|
|
196
|
+
// Though possibly the webpage publisher could take over....
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
//console.trace();
|
|
205
|
+
//throw 'stop';
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
// Setting up a static '/' or main page....?
|
|
209
|
+
// May want to make an object that describes / provides the code or controls to insert into every page
|
|
210
|
+
// and to say where to do so.
|
|
211
|
+
|
|
212
|
+
// May want further '/' single page or control server code, could have some classes named very specifically
|
|
213
|
+
// for the cases we are dealing with.
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
// Then get the publisher to use another bundler?
|
|
224
|
+
// a Ready_To_Serve_Static_Items_Bundler perhaps?
|
|
225
|
+
|
|
226
|
+
// Is best to do this a round-about way in terms of the classes, what they do, and having them interchangable, and
|
|
227
|
+
// very explicit.
|
|
228
|
+
|
|
229
|
+
// Maybe it could even make 'Server_Instructions'.
|
|
230
|
+
// Being very explicit about the stages.
|
|
231
|
+
|
|
232
|
+
// Maybe rename classes if they are too long and something shorter occurs.
|
|
233
|
+
|
|
234
|
+
// System_That_Prepares_Bundles_Of_Just_A_Single_JS_File_And_A_Single_CSS_File_To_Be_Served_Statically
|
|
235
|
+
// And_References_To_Them_Inserted_In_HTML_Control
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
// Being mega-explicit about what gets done here will help integration of classes that do what other people would consider
|
|
239
|
+
// better / ideal.
|
|
240
|
+
|
|
241
|
+
// JS_And_CSS_Perpare_For_Service_Class
|
|
242
|
+
|
|
243
|
+
// For the moment, make extremely specific classes for what the code is doing here.
|
|
244
|
+
|
|
245
|
+
// Single_JS_And_Single_CSS_Bundle_To_Serve_Statically_Preparer.
|
|
246
|
+
// And possibly a version that also creates instructions??? for what to do to the JSGUI control that would otherwise
|
|
247
|
+
// be ready.
|
|
248
|
+
|
|
249
|
+
// Want to move away from having somewhat complex things in the classes themselves that operate in assumed way.
|
|
250
|
+
// Have some relatively complex things that only need to be done on the server really explicit.
|
|
251
|
+
// However, also want classes to represent these things so the logic could run on the client.
|
|
252
|
+
|
|
253
|
+
// Prepare the static service of the pages for the router.
|
|
254
|
+
|
|
255
|
+
// Probably worth finding ways to best include them in the HTML first....
|
|
256
|
+
|
|
257
|
+
// This part here is just getting ready to publish.
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
// Preparers seem like they should be part of the Publishers dir structure / system.
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
// or a Bundle_Preparer_Prepare_For_Static_Routes_Assignment ?????
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
} else {
|
|
295
|
+
console.trace();
|
|
296
|
+
throw 'stop';
|
|
297
|
+
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
//console.trace();
|
|
303
|
+
//throw 'stop';
|
|
304
|
+
|
|
305
|
+
} else if (js_bundler_res._arr.length === 2) {
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
console.trace();
|
|
309
|
+
throw 'stop';
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
} else {
|
|
314
|
+
console.log('js_bundler_res', js_bundler_res);
|
|
315
|
+
console.trace();
|
|
316
|
+
throw 'stop';
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
console.trace();
|
|
324
|
+
throw 'stop nyi';
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
module.exports = HTTP_Webpageorsite_Publisher;
|
|
343
|
+
|
|
@@ -9,6 +9,9 @@ const {obs} = require('fnl');
|
|
|
9
9
|
|
|
10
10
|
// The Webpage bundler should be able to come up with the compiled JS and CSS, maybe even a favicon.
|
|
11
11
|
|
|
12
|
+
// HTTP_Webpageorsite_Publisher
|
|
13
|
+
|
|
14
|
+
|
|
12
15
|
|
|
13
16
|
const Website = require('jsgui3-website');
|
|
14
17
|
|
|
@@ -70,12 +73,19 @@ const Bundle = require('../resources/processors/bundlers/bundle');
|
|
|
70
73
|
|
|
71
74
|
|
|
72
75
|
|
|
76
|
+
// Probably is worth by default having it use the HTTP_Website_Publisher with really simple server setups.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
// Extend HTTP_Web_Item_Publisher HTTP_Web_Page_Or_Site_Publisher (synonym) ????
|
|
73
80
|
|
|
81
|
+
// Share functionality between webpage and website where useful.
|
|
74
82
|
|
|
75
83
|
|
|
84
|
+
const HTTP_Webpageorsite_Publisher = require('./http-webpageorsite-publisher');
|
|
76
85
|
|
|
77
86
|
|
|
78
|
-
|
|
87
|
+
|
|
88
|
+
class HTTP_Website_Publisher extends HTTP_Webpageorsite_Publisher {
|
|
79
89
|
// Website generally serves JS from a single address.
|
|
80
90
|
// Webpage could have its specific JS.
|
|
81
91
|
|
|
@@ -97,6 +107,11 @@ class HTTP_Website_Publisher extends HTTP_Publisher {
|
|
|
97
107
|
super(spec)
|
|
98
108
|
// A website property.
|
|
99
109
|
|
|
110
|
+
//console.trace();
|
|
111
|
+
//throw 'stop';
|
|
112
|
+
|
|
113
|
+
// spec webpage????
|
|
114
|
+
|
|
100
115
|
let website;
|
|
101
116
|
if (spec.website) {
|
|
102
117
|
if (spec.website instanceof Website) {
|
|
@@ -112,6 +127,13 @@ class HTTP_Website_Publisher extends HTTP_Publisher {
|
|
|
112
127
|
}
|
|
113
128
|
});
|
|
114
129
|
|
|
130
|
+
|
|
131
|
+
// A get_ready function for every level of the class for web publishing may help.
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
115
137
|
// The publisher should not have a router (for the moment???)
|
|
116
138
|
// It should however determine routes, and provide them to the router.
|
|
117
139
|
|
|
@@ -131,9 +153,13 @@ class HTTP_Website_Publisher extends HTTP_Publisher {
|
|
|
131
153
|
|
|
132
154
|
|
|
133
155
|
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
134
159
|
// Disk path client js being a property of the website itself?
|
|
135
160
|
// Critical overall functionality, dont want to remove it from here for the moment. See if not critical here.
|
|
136
161
|
|
|
162
|
+
/*
|
|
137
163
|
|
|
138
164
|
let disk_path_client_js;
|
|
139
165
|
if (spec.disk_path_client_js) disk_path_client_js = spec.disk_path_client_js;
|
|
@@ -143,6 +169,8 @@ class HTTP_Website_Publisher extends HTTP_Publisher {
|
|
|
143
169
|
}
|
|
144
170
|
});
|
|
145
171
|
|
|
172
|
+
*/
|
|
173
|
+
|
|
146
174
|
|
|
147
175
|
|
|
148
176
|
// And this could be an observable too.
|
|
@@ -177,6 +205,11 @@ class HTTP_Website_Publisher extends HTTP_Publisher {
|
|
|
177
205
|
|
|
178
206
|
|
|
179
207
|
|
|
208
|
+
// Will probably insert new bundling code here - but refer to advanced classes that handle the details.
|
|
209
|
+
|
|
210
|
+
console.log('\n\nskipping __old__setup_website_publishing');
|
|
211
|
+
console.trace();
|
|
212
|
+
console.log('\n\n');
|
|
180
213
|
|
|
181
214
|
|
|
182
215
|
const __old__setup_website_publishing = (website) => {
|
|
@@ -511,7 +544,18 @@ class HTTP_Website_Publisher extends HTTP_Publisher {
|
|
|
511
544
|
|
|
512
545
|
*/
|
|
513
546
|
} else {
|
|
514
|
-
|
|
547
|
+
|
|
548
|
+
// Do the async get_ready function....
|
|
549
|
+
|
|
550
|
+
(async() => {
|
|
551
|
+
|
|
552
|
+
await this.get_ready();
|
|
553
|
+
this.raise('ready');
|
|
554
|
+
|
|
555
|
+
})();
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
//
|
|
515
559
|
}
|
|
516
560
|
|
|
517
561
|
// Create a router for the website if it does not already have one.
|
|
@@ -532,6 +576,11 @@ class HTTP_Website_Publisher extends HTTP_Publisher {
|
|
|
532
576
|
|
|
533
577
|
}
|
|
534
578
|
|
|
579
|
+
async get_ready() {
|
|
580
|
+
await super.get_ready();
|
|
581
|
+
|
|
582
|
+
}
|
|
583
|
+
|
|
535
584
|
|
|
536
585
|
handle_http(req, res) {
|
|
537
586
|
// Because it's already been set up in the router! It should have been.
|
|
@@ -125,6 +125,32 @@ class JS_AST_Node_Core {
|
|
|
125
125
|
configurable: false
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
+
|
|
129
|
+
this.remove = () => {
|
|
130
|
+
const {parent_node} = this;
|
|
131
|
+
if (parent_node) {
|
|
132
|
+
const i = parent_node.child_nodes.indexOf(this);
|
|
133
|
+
if (typeof i === 'number') {
|
|
134
|
+
parent_node.child_nodes.splice(i, 1);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
/*
|
|
141
|
+
// Remove node - tell the parent to remove that node from its childnodes.
|
|
142
|
+
|
|
143
|
+
function removeItemOnce(arr, value) {
|
|
144
|
+
var index = arr.indexOf(value);
|
|
145
|
+
if (index > -1) {
|
|
146
|
+
arr.splice(index, 1);
|
|
147
|
+
}
|
|
148
|
+
return arr;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
|
|
128
154
|
Object.defineProperty(this, 'root_node', {
|
|
129
155
|
get() {
|
|
130
156
|
return root_node;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const Bundler = require('./bundler');
|
|
2
|
-
const Bundle = require('./bundle');
|
|
2
|
+
//const Bundle = require('./bundle');
|
|
3
3
|
const {obs, prom_or_cb} = require('fnl');
|
|
4
4
|
const {tof, each} = require('jsgui3-html');
|
|
5
5
|
const fnlfs = require('fnlfs');
|
|
@@ -59,6 +59,12 @@ const bundle_css_from_js_str = (js_str, options = {}) => {
|
|
|
59
59
|
// Moving towards using observables as a matter of course for longer-running functions.
|
|
60
60
|
|
|
61
61
|
// Seems like this makes a settimeout as well???
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
// OK, but see about also getting the JS without the CSS parts.
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
62
68
|
return obs((next, complete, error) => {
|
|
63
69
|
|
|
64
70
|
//console.log('js_str.length', js_str.length);
|
|
@@ -69,7 +75,17 @@ const bundle_css_from_js_str = (js_str, options = {}) => {
|
|
|
69
75
|
source: js_str
|
|
70
76
|
};
|
|
71
77
|
|
|
78
|
+
// This part is kind-of slow.
|
|
79
|
+
|
|
80
|
+
console.log('pre create js ast node');
|
|
72
81
|
const js_ast_node = JS_AST_Node.from_spec(spec);
|
|
82
|
+
console.log('post create js ast node');
|
|
83
|
+
|
|
84
|
+
// Maybe a faster / different JS parser.
|
|
85
|
+
// Or do it using regex / specialised algorithm of some sort.
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
73
89
|
|
|
74
90
|
//console.log('!!js_ast_node', !!js_ast_node);
|
|
75
91
|
|
|
@@ -91,7 +107,14 @@ const bundle_css_from_js_str = (js_str, options = {}) => {
|
|
|
91
107
|
// Just assigning a template literal to .css?
|
|
92
108
|
const css_ae_nodes = [];
|
|
93
109
|
|
|
110
|
+
// How about removing those parts from the JS AST?
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
94
114
|
js_ast_node.deep_iterate(node => {
|
|
115
|
+
|
|
116
|
+
// Maybe this part is slow? Don't think so though.
|
|
117
|
+
|
|
95
118
|
//console.log('node', node);
|
|
96
119
|
//console.log('Object.keys(node)', Object.keys(node));
|
|
97
120
|
//console.log('node.type_signature', node.type_signature);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const {Evented_Class} = require('lang-tools');
|
|
5
|
+
const {obs} = require('fnl');
|
|
6
|
+
|
|
7
|
+
// Or just use the advanced ESBuild version for the moment.
|
|
8
|
+
|
|
9
|
+
const maybe_unneeded_class = () => {
|
|
10
|
+
class JS_Bundler extends Evented_Class {
|
|
11
|
+
constructor(spec) {
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
bundle(js_file_path) {
|
|
17
|
+
// Is it a string path...?
|
|
18
|
+
// If it's a string it should be a path.
|
|
19
|
+
|
|
20
|
+
if (typeof js_file_path === 'string') {
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// Possibly first parse analysis...
|
|
27
|
+
|
|
28
|
+
// Extract the CSS from it
|
|
29
|
+
// Extract the JS from it.
|
|
30
|
+
|
|
31
|
+
} else {
|
|
32
|
+
console.trace();
|
|
33
|
+
|
|
34
|
+
console.log('\njs_file_path', js_file_path, '\n');
|
|
35
|
+
throw 'Expected string js_file_path';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
const JS_Bundler = require('./esbuild/Advanced_JS_Bundler_Using_ESBuild');
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
module.exports = JS_Bundler;
|