jsgui3-server 0.0.81 → 0.0.84
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/README.md +8 -1
- package/bundler/bundle.js +11 -0
- package/bundler/bundler.js +9 -0
- package/bundler/css-bundler.js +48 -0
- package/bundler/js-bundler.js +205 -0
- package/bundler/test_ast.js +74 -0
- package/bundler/webpage-bundler.js +284 -0
- package/bundler/website-bundler.js +23 -0
- package/controls/README.md +8 -0
- package/controls/page/admin.js +75 -0
- package/controls/panel/admin.js +11 -0
- package/examples/controls/html-server-combo-box.js +5 -5
- package/examples/html-server.js +3 -0
- package/examples/square_box.js +35 -0
- package/examples/square_box_client.js +91 -0
- package/module.js +8 -0
- package/{single-control-server.js → old/_single-control-server.js} +157 -96
- package/old/single-control-server.js +108 -158
- package/{single-page-app.js → old/single-page-app.js} +2 -0
- package/{examples/demos → old}/square_box.js +1 -1
- package/package.json +9 -9
- package/page-context.js +1 -1
- package/publishing/http-css-publisher.js +0 -0
- package/publishing/{function-publisher.js → http-function-publisher.js} +12 -2
- package/publishing/http-html-page-publisher.js +5 -0
- package/publishing/http-html-publisher.js +25 -0
- package/publishing/http-jpeg-publisher.js +0 -0
- package/publishing/http-js-publisher.js +25 -0
- package/publishing/{observable-publisher.js → http-observable-publisher.js} +12 -6
- package/publishing/http-png-publisher.js +0 -0
- package/publishing/http-publisher.js +52 -0
- package/publishing/{resource-publisher.js → http-resource-publisher.js} +20 -1
- package/publishing/http-svg-publisher.js +0 -0
- package/publishing/http-webpage-publisher.js +112 -0
- package/publishing/http-website-publisher.js +254 -0
- package/publishing/notes.md +1 -0
- package/resources/README.md +16 -0
- package/resources/_old_website-resource.js +507 -0
- package/resources/compile/server-resource-compilation.js +41 -0
- package/resources/data-resource.js +14 -0
- package/resources/fs-resource.js +2 -4
- package/resources/jsbuilder/babel/deep_iterate/deep_iterate_babel.js +3 -0
- package/resources/jsbuilder/test/test_ast_node.js +1 -1
- package/resources/jsbuilder/test/test_js_file.js +2 -2
- package/resources/jsbuilder/test/test_project.js +1 -0
- package/resources/notes.txt +11 -0
- package/resources/server-installed-tools.js +29 -0
- package/resources/server-resource-pool.js +1 -44
- package/resources/website-css-resource.js +1 -1
- package/resources/website-javascript-resource.js +165 -34
- package/resources/website-resource.js +62 -294
- package/resources/website-static-html-resource.js +8 -16
- package/resources/website-template-html-resource.js +231 -0
- package/roadmap.md +64 -0
- package/server.js +721 -18
- package/website/webpage.js +169 -0
- package/website/website-group.js +16 -0
- package/website/website.js +227 -0
|
@@ -16,29 +16,10 @@ var Collection = jsgui.Collection;
|
|
|
16
16
|
|
|
17
17
|
var exec = require('child_process').exec;
|
|
18
18
|
|
|
19
|
-
// Perhaps this will have HTTP endpoints as well?
|
|
20
|
-
// Maybe we can access it through url/resources/
|
|
21
|
-
|
|
22
|
-
// Perhaps a resource publisher, or a few of them could be useful.
|
|
23
|
-
// HTTP_Resource_Publisher?
|
|
24
|
-
// Generally publishes a resource over HTTP.
|
|
25
|
-
// Will have some authorization and authentication properties, hooked up with the proper providers.
|
|
26
|
-
|
|
27
|
-
// This may be the place in which remote access to the resources is given.
|
|
28
|
-
// It would make sense.
|
|
29
|
-
// Perhaps it is worth using a resource publisher? Then is that a resource?
|
|
30
|
-
// I think the resource pool may be the sensible point of access.
|
|
31
|
-
|
|
32
|
-
|
|
33
19
|
class Server_Resource_Pool extends Resource_Pool {
|
|
34
20
|
constructor(spec) {
|
|
35
21
|
super(spec);
|
|
36
|
-
|
|
37
|
-
// will add the Resource_Local_Server_Information
|
|
38
|
-
// Will be nice to set them with an object.
|
|
39
|
-
// Not just the normal spec.
|
|
40
|
-
// Maybe can see if the spec matches fields?
|
|
41
|
-
// Or copy fields from the spec?
|
|
22
|
+
|
|
42
23
|
var lsi = new Local_Server_Info({
|
|
43
24
|
'name': 'Local Server Info',
|
|
44
25
|
'startup_type': 'auto',
|
|
@@ -47,31 +28,7 @@ class Server_Resource_Pool extends Resource_Pool {
|
|
|
47
28
|
},
|
|
48
29
|
'pool': this
|
|
49
30
|
});
|
|
50
|
-
|
|
51
31
|
this.add(lsi);
|
|
52
|
-
|
|
53
|
-
//this.js = new
|
|
54
|
-
|
|
55
|
-
// And a resource publisher resource.
|
|
56
|
-
// It goes in the pool, and it publishes other resources (over HTTP)
|
|
57
|
-
// The resource pool contains its own publisher.
|
|
58
|
-
|
|
59
|
-
// Likely to want multiple publisher resources - one for each published resource.
|
|
60
|
-
// This used to publish the resource pool. Will use a resource pool publisher for this in the future.
|
|
61
|
-
|
|
62
|
-
/*
|
|
63
|
-
var publisher = new Resource_Publisher_HTTP({
|
|
64
|
-
'meta': {
|
|
65
|
-
'name': 'HTTP Resource Publisher'
|
|
66
|
-
},
|
|
67
|
-
'startup_type': 'auto',
|
|
68
|
-
'access': {
|
|
69
|
-
'full': ['server_admin']
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
this.add(publisher);
|
|
74
|
-
*/
|
|
75
32
|
}
|
|
76
33
|
|
|
77
34
|
}
|
|
@@ -101,7 +101,7 @@ var serve_css_file_from_disk = function (filePath, response) {
|
|
|
101
101
|
let attempt_load = (path, callback) => {
|
|
102
102
|
fs2.load_file_as_string(path, function (err, data) {
|
|
103
103
|
if (err) {
|
|
104
|
-
console.log('could not open file path', path);
|
|
104
|
+
//console.log('could not open file path', path);
|
|
105
105
|
//jsgui_css_file_path = '../../' + filePath;
|
|
106
106
|
//console.log('jsgui_css_file_path', jsgui_css_file_path);
|
|
107
107
|
callback(null, false);
|
|
@@ -22,13 +22,23 @@
|
|
|
22
22
|
// JS_File_
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
// Much of this could be better expressed as a Compiler_Resource.
|
|
25
26
|
|
|
26
27
|
|
|
28
|
+
// Plan: Do more of this through lower level compilation features.
|
|
29
|
+
// Accessing a compilation resource makes sense structurally.
|
|
27
30
|
|
|
31
|
+
// May want a server to create and test compilation resources / compilers.
|
|
28
32
|
|
|
33
|
+
// Compilers, Bundlers, HTTP Request Handlers - Somewhat lower level, ie tools to get things done.
|
|
34
|
+
// Then also: resources which make use of upgraded and new lower level components.
|
|
29
35
|
|
|
36
|
+
// Server_Resource could help?
|
|
30
37
|
|
|
31
|
-
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const path = require('path'),
|
|
32
42
|
fs = require('fs'),
|
|
33
43
|
url = require('url'),
|
|
34
44
|
jsgui = require('jsgui3-html'),
|
|
@@ -47,24 +57,25 @@ const fnl = require('fnl');
|
|
|
47
57
|
const prom_or_cb = fnl.prom_or_cb;
|
|
48
58
|
const fnlfs = require('fnlfs');
|
|
49
59
|
|
|
50
|
-
|
|
60
|
+
const stringify = jsgui.stringify,
|
|
51
61
|
each = jsgui.each,
|
|
52
62
|
arrayify = jsgui.arrayify,
|
|
53
63
|
tof = jsgui.tof;
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
const filter_map_by_regex = jsgui.filter_map_by_regex;
|
|
65
|
+
const Class = jsgui.Class,
|
|
56
66
|
Data_Object = jsgui.Data_Object,
|
|
57
67
|
Enhanced_Data_Object = jsgui.Enhanced_Data_Object;
|
|
58
|
-
|
|
68
|
+
const fp = jsgui.fp,
|
|
59
69
|
is_defined = jsgui.is_defined;
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
const Collection = jsgui.Collection;
|
|
71
|
+
const call_multi = jsgui.call_multi,
|
|
62
72
|
get_truth_map_from_arr = jsgui.get_truth_map_from_arr;
|
|
63
73
|
|
|
64
|
-
|
|
74
|
+
|
|
65
75
|
//var zlib = require('zlib');
|
|
66
|
-
|
|
76
|
+
const util = require('util');
|
|
67
77
|
|
|
78
|
+
const browserify = require('browserify');
|
|
68
79
|
const babel = require('@babel/core');
|
|
69
80
|
|
|
70
81
|
// Extends AutoStart_Resource?
|
|
@@ -74,6 +85,7 @@ const stream_to_array = require('stream-to-array');
|
|
|
74
85
|
const process_js = require('./process-js');
|
|
75
86
|
const {analyse_js_doc_formatting, extract_client_js} = process_js;
|
|
76
87
|
|
|
88
|
+
|
|
77
89
|
var serve_js_file_from_disk_updated_refs = function (filePath, response, callback) {
|
|
78
90
|
fs2.load_file_as_string(filePath, function (err, data) {
|
|
79
91
|
if (err) {
|
|
@@ -155,18 +167,20 @@ class Site_JavaScript extends Resource {
|
|
|
155
167
|
constructor(spec) {
|
|
156
168
|
super(spec);
|
|
157
169
|
//this.meta.set('custom_paths', new Data_Object({}));
|
|
158
|
-
this.custom_paths = new Data_Object({});
|
|
170
|
+
//this.custom_paths = new Data_Object({});
|
|
159
171
|
// Those are custom file paths.
|
|
160
172
|
// could have a collection of directories, indexed by name, that get served.
|
|
161
173
|
// Index the collection by string value?
|
|
162
174
|
//this.meta.set('served_directories', new Collection({'index_by': 'name'}));
|
|
175
|
+
|
|
176
|
+
// But this could be held (only) in the router.
|
|
163
177
|
this.served_directories = new Collection({
|
|
164
178
|
'index_by': 'name'
|
|
165
179
|
});
|
|
166
180
|
}
|
|
167
181
|
'start'(callback) {
|
|
168
182
|
//console.log('Site_JavaScript start');
|
|
169
|
-
|
|
183
|
+
const build_on_start = this.build_on_start;
|
|
170
184
|
if (build_on_start) {
|
|
171
185
|
this.build_client(function (err, res_build) {
|
|
172
186
|
if (err) {
|
|
@@ -190,8 +204,34 @@ class Site_JavaScript extends Resource {
|
|
|
190
204
|
// There will be a variety of jsgui packages.
|
|
191
205
|
|
|
192
206
|
'build_client'(callback) {
|
|
207
|
+
|
|
208
|
+
// Configurable building mechanisms....
|
|
209
|
+
// Want to provide jsgui events / logs on the build process.
|
|
210
|
+
|
|
211
|
+
// jsgui.notify could be used for some kinds of internal event logging.
|
|
212
|
+
// a specific type of event system.
|
|
213
|
+
|
|
214
|
+
// jsgui.raise('notification', )
|
|
215
|
+
|
|
216
|
+
// .note may be faster.
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
// jsgui.notify('start', 'build_client');
|
|
222
|
+
|
|
223
|
+
|
|
193
224
|
// Need the reference relative to the application directory.
|
|
194
225
|
//var path = __dirname + '/js/app.js';
|
|
226
|
+
|
|
227
|
+
// Can we stream it to a buffer in memory instead?
|
|
228
|
+
|
|
229
|
+
// Using a compilation resource may be better long-term.
|
|
230
|
+
// Creating and using a relevant abstraction.
|
|
231
|
+
|
|
232
|
+
// The server should have already loaded (a few) compilers.
|
|
233
|
+
|
|
234
|
+
|
|
195
235
|
var appDir = path.dirname(require.main.filename);
|
|
196
236
|
//console.log('appDir', appDir);
|
|
197
237
|
var app_path = appDir + '/js/app.js';
|
|
@@ -220,8 +260,15 @@ class Site_JavaScript extends Resource {
|
|
|
220
260
|
// May be better not to allow server-side code to be read on the client.
|
|
221
261
|
// Could have specific directories within jsgui that get served to the client.
|
|
222
262
|
|
|
263
|
+
|
|
264
|
+
// May be best thinking of bundling up one or more objects / files ready for the server to serve.
|
|
265
|
+
|
|
266
|
+
|
|
223
267
|
'serve_directory'(path) {
|
|
224
268
|
// Serves that directory, as any files given in that directory can be served from /js
|
|
269
|
+
|
|
270
|
+
// Perhaps just using the router would be better.
|
|
271
|
+
|
|
225
272
|
var served_directories = this.served_directories;
|
|
226
273
|
//console.log('served_directories ' + stringify(served_directories));
|
|
227
274
|
//served_directories.push(path);
|
|
@@ -233,13 +280,17 @@ class Site_JavaScript extends Resource {
|
|
|
233
280
|
//throw 'stop';
|
|
234
281
|
}
|
|
235
282
|
'serve_package'(url, js_package, options = {}, callback) {
|
|
236
|
-
console.log('serve_package', url, js_package);
|
|
237
|
-
console.log('js_package', js_package);
|
|
238
|
-
console.log('typeof js_package', typeof js_package);
|
|
239
|
-
let tjp = typeof js_package;
|
|
283
|
+
//console.log('serve_package', url, js_package);
|
|
284
|
+
//console.log('js_package', js_package);
|
|
285
|
+
//console.log('typeof js_package', typeof js_package);
|
|
286
|
+
//let tjp = typeof js_package;
|
|
240
287
|
return this.serve_package_from_path(url, require.resolve(js_package), options, callback);
|
|
241
288
|
}
|
|
242
289
|
|
|
290
|
+
// Possibly some functionality would be better within the js bundler.
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
243
294
|
'package'(js_file_path, options = {}, callback) {
|
|
244
295
|
|
|
245
296
|
let a = arguments;
|
|
@@ -315,7 +366,7 @@ class Site_JavaScript extends Resource {
|
|
|
315
366
|
//console.log('babel_option', babel_option);
|
|
316
367
|
if (babel_option === 'es5') {
|
|
317
368
|
|
|
318
|
-
let
|
|
369
|
+
let o_transform = {
|
|
319
370
|
"presets": [
|
|
320
371
|
"es2015",
|
|
321
372
|
"es2017"
|
|
@@ -326,8 +377,8 @@ class Site_JavaScript extends Resource {
|
|
|
326
377
|
//'sourceMaps': 'inline'
|
|
327
378
|
};
|
|
328
379
|
|
|
329
|
-
if (options.include_sourcemaps)
|
|
330
|
-
let res_transform = babel.transform(str_js,
|
|
380
|
+
if (options.include_sourcemaps) o_transform.sourceMaps = 'inline';
|
|
381
|
+
let res_transform = babel.transform(str_js, o_transform);
|
|
331
382
|
//console.log('res_transform', res_transform);
|
|
332
383
|
//console.log('Object.keys(res_transform)', Object.keys(res_transform));
|
|
333
384
|
let jst_es5 = res_transform.code;
|
|
@@ -397,8 +448,9 @@ class Site_JavaScript extends Resource {
|
|
|
397
448
|
// Can we call browserify on the code string?
|
|
398
449
|
// Creating a modified copy of the file would do.
|
|
399
450
|
// Load the file, modify it, save it under a different name
|
|
451
|
+
const Stream = require('stream');
|
|
400
452
|
|
|
401
|
-
let s = new
|
|
453
|
+
let s = new Stream.Readable(),
|
|
402
454
|
path = require('path').parse(js_file_path);
|
|
403
455
|
|
|
404
456
|
let fileContents = await fnlfs.load(js_file_path);
|
|
@@ -421,7 +473,7 @@ class Site_JavaScript extends Resource {
|
|
|
421
473
|
each(options.replace, (text, key) => {
|
|
422
474
|
//console.log('key', key);
|
|
423
475
|
//console.log('text', text);
|
|
424
|
-
|
|
476
|
+
const running_fn = '(' + text + ')();'
|
|
425
477
|
//console.log('running_fn', running_fn);
|
|
426
478
|
s_file_contents = s_file_contents.split(key).join(running_fn);
|
|
427
479
|
})
|
|
@@ -434,8 +486,10 @@ class Site_JavaScript extends Resource {
|
|
|
434
486
|
// want a raw option with no browserify.
|
|
435
487
|
//console.log('serve_raw', serve_raw);
|
|
436
488
|
if (serve_raw) {
|
|
437
|
-
|
|
438
|
-
this.custom_paths.set(escaped_url, fileContents);
|
|
489
|
+
const escaped_url = url.replace(/\./g, '☺');
|
|
490
|
+
//this.custom_paths.set(escaped_url, fileContents);
|
|
491
|
+
|
|
492
|
+
throw 'NYI';
|
|
439
493
|
} else {
|
|
440
494
|
const formatting_info = analyse_js_doc_formatting(fileContents.toString());
|
|
441
495
|
//console.log('formatting_info', formatting_info);
|
|
@@ -443,7 +497,10 @@ class Site_JavaScript extends Resource {
|
|
|
443
497
|
const {arr_lines, line_break, indentation_analysis} = formatting_info;
|
|
444
498
|
const {parsed_lines, str_indentation} = indentation_analysis;
|
|
445
499
|
const client_root_js = extract_client_js(formatting_info);
|
|
446
|
-
|
|
500
|
+
|
|
501
|
+
//fnlfs.save('d:\\saved.js', client_root_js);
|
|
502
|
+
|
|
503
|
+
|
|
447
504
|
s.push(client_root_js);
|
|
448
505
|
s.push(null);
|
|
449
506
|
const lines_file_content = [];
|
|
@@ -451,14 +508,14 @@ class Site_JavaScript extends Resource {
|
|
|
451
508
|
// Don't always include sourcemap?
|
|
452
509
|
// Separate out the sourcemap?
|
|
453
510
|
|
|
454
|
-
|
|
511
|
+
const b = browserify(s, {
|
|
455
512
|
basedir: path.dir,
|
|
456
513
|
//builtins: false,
|
|
457
514
|
builtins: ['buffer'],
|
|
458
515
|
'debug': options.include_sourcemaps
|
|
459
516
|
});
|
|
460
517
|
// Prefer the idea of sending a stream to browserify.
|
|
461
|
-
|
|
518
|
+
const parts = await stream_to_array(b.bundle());
|
|
462
519
|
/*
|
|
463
520
|
var b = browserify([js_file_path], {
|
|
464
521
|
'debug': true
|
|
@@ -468,8 +525,8 @@ class Site_JavaScript extends Resource {
|
|
|
468
525
|
const buffers = parts
|
|
469
526
|
.map(part => util.isBuffer(part) ? part : Buffer.from(part));
|
|
470
527
|
let buf_js = Buffer.concat(buffers);
|
|
471
|
-
|
|
472
|
-
|
|
528
|
+
const str_js = buf_js.toString();
|
|
529
|
+
const str_js_code = str_js;
|
|
473
530
|
let str_sourcemap;
|
|
474
531
|
|
|
475
532
|
let pos_prior_sourcemap = str_js.indexOf('//# sourceMappingURL');
|
|
@@ -479,17 +536,20 @@ class Site_JavaScript extends Resource {
|
|
|
479
536
|
}
|
|
480
537
|
// filter_extract_css
|
|
481
538
|
|
|
539
|
+
|
|
540
|
+
/*
|
|
482
541
|
const js_remove_comments = (str_js_code) => {
|
|
483
542
|
// comments will be OK within a string.
|
|
484
543
|
|
|
485
544
|
// Be able to work out what type of code we are in at all points...?
|
|
486
545
|
// Non-tokenising scanner...?
|
|
487
546
|
|
|
488
|
-
// Knowing whether or not
|
|
547
|
+
// Knowing whether or not * / // / * is within a string is important - because if it's in a string its not a comment.
|
|
489
548
|
// seems like making the scanning parser is a bit of a large task. It would constantly need to know what symbol type / string encapsulator to use.
|
|
490
549
|
|
|
491
550
|
// Could split it into lines, spot whenever a line starts a comment...?
|
|
492
551
|
}
|
|
552
|
+
*/
|
|
493
553
|
|
|
494
554
|
const filter_js_extract_control_css = (str_js_code) => {
|
|
495
555
|
// res = [css, js_no_css]
|
|
@@ -554,7 +614,7 @@ class Site_JavaScript extends Resource {
|
|
|
554
614
|
this.raise('extracted-controls-css', str_css);
|
|
555
615
|
let babel_option = options.babel;
|
|
556
616
|
|
|
557
|
-
console.log('babel_option', babel_option);
|
|
617
|
+
//console.log('babel_option', babel_option);
|
|
558
618
|
//throw 'stop';
|
|
559
619
|
//babel_option = 'es5';
|
|
560
620
|
//console.log('babel_option', babel_option);
|
|
@@ -633,20 +693,58 @@ class Site_JavaScript extends Resource {
|
|
|
633
693
|
}
|
|
634
694
|
var escaped_url = url.replace(/\./g, '☺');
|
|
635
695
|
|
|
636
|
-
|
|
696
|
+
console.log('pre compress buf_js.length', buf_js.length);
|
|
637
697
|
zlib.gzip(buf_js, {level: 9}, (err, buffer) => {
|
|
638
|
-
|
|
698
|
+
console.log('deflated buf_js buffer.length', buffer.length);
|
|
639
699
|
|
|
640
700
|
if (err) {
|
|
641
701
|
reject(err);
|
|
642
702
|
} else {
|
|
643
703
|
//
|
|
644
704
|
//buffer.encoding = 'deflate';
|
|
705
|
+
console.log('');
|
|
706
|
+
console.log('escaped_url', escaped_url);
|
|
707
|
+
console.log('url', url);
|
|
708
|
+
console.log('');
|
|
709
|
+
|
|
710
|
+
const rp = this.pool;
|
|
711
|
+
console.log('rp', rp);
|
|
712
|
+
console.log('rp.resource_names', rp.resource_names);
|
|
713
|
+
|
|
714
|
+
const router = rp.get_resource('Site Router');
|
|
715
|
+
console.log('router', router);
|
|
716
|
+
|
|
717
|
+
router.set_route(url, this, (req, res) => {
|
|
718
|
+
console.log('router', [!!req, !!res]);
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
/*
|
|
722
|
+
'set_route'(str_route, context, fn_handler) {
|
|
723
|
+
*/
|
|
724
|
+
|
|
725
|
+
// Setting up routing here?
|
|
726
|
+
// Or returning it to the server?
|
|
727
|
+
|
|
728
|
+
// hack_setup_routing - as in it hacks into another part of the system (which is available)
|
|
729
|
+
// to set up the routing. A more top-down approach would be for the Server module to set the
|
|
730
|
+
// routing up itself.
|
|
731
|
+
// May be nice if components / resources could set up their own routing, with access to the
|
|
732
|
+
// Resource_Pool.
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
/*
|
|
645
737
|
|
|
738
|
+
// Would need to check operation of custom paths.
|
|
739
|
+
// Maybe its use was removed...?
|
|
646
740
|
this.custom_paths.set(escaped_url, {
|
|
647
741
|
raw: buf_js,
|
|
648
742
|
gzip: buffer
|
|
649
743
|
});
|
|
744
|
+
|
|
745
|
+
*/
|
|
746
|
+
|
|
747
|
+
|
|
650
748
|
|
|
651
749
|
resolve(true);
|
|
652
750
|
}
|
|
@@ -656,15 +754,48 @@ class Site_JavaScript extends Resource {
|
|
|
656
754
|
}, callback);
|
|
657
755
|
}
|
|
658
756
|
|
|
757
|
+
/*
|
|
659
758
|
'set_custom_path'(url, file_path) {
|
|
660
759
|
var escaped_url = url.replace(/\./g, '☺');
|
|
661
760
|
this.custom_paths.set(escaped_url, file_path);
|
|
662
761
|
}
|
|
762
|
+
*/
|
|
763
|
+
//
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
// Not so sure that it should process the request.
|
|
767
|
+
// A more general purpose request handler...?
|
|
768
|
+
// Have more request handling code within one js file, a cenralised portion of the app.
|
|
769
|
+
// And then within those request handlers call on useful abstractions.
|
|
770
|
+
|
|
771
|
+
// Setting up one or more Compilers seems like it would solve some of what this is doing.
|
|
772
|
+
// Even a Compilation_Process object that provides data for monitoring.
|
|
773
|
+
// Published with a Resource_Publisher possibly.
|
|
774
|
+
|
|
775
|
+
// Website_HTTP_Publisher maybe
|
|
776
|
+
|
|
777
|
+
// or just HTTP_Publisher, a Publisher rather than a Resource.
|
|
778
|
+
// HTTP_Publisher, which is focused on publishing HTTP, may be the best option here.
|
|
779
|
+
// Seems best to fix what we have already first though. Could then work on HTTP_Publisher.
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
// Website_HTTP_Publisher_Resource possibly?
|
|
663
784
|
|
|
664
785
|
//
|
|
665
786
|
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
// Site_JavaScript seems more about bundling / compiling rather than serving.
|
|
790
|
+
// Resources could present their data ahead of time / be asked for them and provide it, and the server
|
|
791
|
+
// keeps track of info more centrally.
|
|
792
|
+
//
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
|
|
666
797
|
'process'(req, res) {
|
|
667
|
-
|
|
798
|
+
console.log('Site_JavaScript processing req.url', req.url);
|
|
668
799
|
var remoteAddress = req.connection.remoteAddress;
|
|
669
800
|
var custom_paths = this.custom_paths;
|
|
670
801
|
var rurl = req.url.replace(/\./g, '☺');
|
|
@@ -685,8 +816,8 @@ class Site_JavaScript extends Resource {
|
|
|
685
816
|
res.writeHead(200, o_head);
|
|
686
817
|
res.end(data_to_serve);
|
|
687
818
|
} else {
|
|
688
|
-
var served_directories = this.served_directories;
|
|
689
|
-
console.log('served_directories', served_directories);
|
|
819
|
+
//var served_directories = this.served_directories;
|
|
820
|
+
//console.log('served_directories', served_directories);
|
|
690
821
|
var url_parts = url.parse(req.url, true);
|
|
691
822
|
//console.log('url_parts ' + stringify(url_parts));
|
|
692
823
|
var splitPath = url_parts.path.substr(1).split('/');
|