jsgui3-server 0.0.82 → 0.0.85

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 (57) hide show
  1. package/README.md +8 -1
  2. package/bundler/bundle.js +11 -0
  3. package/bundler/bundler.js +9 -0
  4. package/bundler/css-bundler.js +56 -0
  5. package/bundler/js-bundler.js +214 -0
  6. package/bundler/test_ast.js +74 -0
  7. package/bundler/webpage-bundler.js +286 -0
  8. package/bundler/website-bundler.js +23 -0
  9. package/controls/README.md +8 -0
  10. package/controls/page/admin.js +75 -0
  11. package/controls/panel/admin.js +11 -0
  12. package/examples/controls/html-server-combo-box.js +5 -5
  13. package/examples/html-server.js +3 -0
  14. package/examples/square_box.js +41 -0
  15. package/examples/square_box_client.js +91 -0
  16. package/module.js +6 -0
  17. package/{single-control-server.js → old/_single-control-server.js} +157 -96
  18. package/old/single-control-server.js +108 -158
  19. package/{single-page-app.js → old/single-page-app.js} +2 -0
  20. package/{examples/demos → old}/square_box.js +1 -1
  21. package/package.json +9 -9
  22. package/page-context.js +1 -1
  23. package/publishing/http-css-publisher.js +0 -0
  24. package/publishing/{function-publisher.js → http-function-publisher.js} +11 -1
  25. package/publishing/http-html-page-publisher.js +5 -0
  26. package/publishing/http-html-publisher.js +25 -0
  27. package/publishing/http-jpeg-publisher.js +0 -0
  28. package/publishing/http-js-publisher.js +25 -0
  29. package/publishing/{observable-publisher.js → http-observable-publisher.js} +12 -6
  30. package/publishing/http-png-publisher.js +0 -0
  31. package/publishing/http-publisher.js +52 -0
  32. package/publishing/{resource-publisher.js → http-resource-publisher.js} +20 -1
  33. package/publishing/http-svg-publisher.js +0 -0
  34. package/publishing/http-webpage-publisher.js +112 -0
  35. package/publishing/http-website-publisher.js +271 -0
  36. package/publishing/notes.md +1 -0
  37. package/resources/README.md +16 -0
  38. package/resources/_old_website-resource.js +507 -0
  39. package/resources/compile/server-resource-compilation.js +41 -0
  40. package/resources/data-resource.js +8 -0
  41. package/resources/fs-resource.js +2 -4
  42. package/resources/jsbuilder/babel/deep_iterate/deep_iterate_babel.js +3 -0
  43. package/resources/jsbuilder/test/test_ast_node.js +1 -1
  44. package/resources/jsbuilder/test/test_js_file.js +2 -2
  45. package/resources/notes.txt +11 -0
  46. package/resources/server-installed-tools.js +29 -0
  47. package/resources/server-resource-pool.js +1 -55
  48. package/resources/website-css-resource.js +1 -1
  49. package/resources/website-javascript-resource.js +165 -34
  50. package/resources/website-resource.js +52 -296
  51. package/resources/website-static-html-resource.js +0 -1
  52. package/resources/website-template-html-resource.js +231 -0
  53. package/roadmap.md +68 -0
  54. package/server.js +722 -17
  55. package/website/webpage.js +169 -0
  56. package/website/website-group.js +16 -0
  57. package/website/website.js +253 -0
package/README.md CHANGED
@@ -1,3 +1,10 @@
1
1
  # Jsgui3 Server
2
2
 
3
- This module covers functionality that enables the application to be served to clients.
3
+ This module covers functionality that enables the application to be served to clients.
4
+
5
+ 2022: Seems as though the server could be bundled with a few useful / essential compilers.
6
+
7
+ // Just running the Server without a website set up could be a way to test the compilers and data transformers.
8
+ // Would then be able to publish access to the compilers using the server mechanisms.
9
+
10
+
@@ -0,0 +1,11 @@
1
+ // Could make this a Collection?
2
+
3
+ const {Collection} = require('jsgui3-html');
4
+
5
+ class Bundle extends Collection {
6
+ constructor(spec = {}) {
7
+ super(spec);
8
+ }
9
+ }
10
+
11
+ module.exports = Bundle;
@@ -0,0 +1,9 @@
1
+ const {Evented_Class} = require('jsgui3-html');
2
+
3
+ class Bundler extends Evented_Class {
4
+ constructor(spec = {}) {
5
+ super(spec);
6
+ }
7
+ }
8
+
9
+ module.exports = Bundler;
@@ -0,0 +1,56 @@
1
+ const Bundler = require('./bundler');
2
+ const Bundle = require('./bundle');
3
+ const {obs, prom_or_cb} = require('fnl');
4
+ const {tof} = require('jsgui3-html');
5
+ const fnlfs = require('fnlfs');
6
+ const browserify = require('browserify');
7
+ const babel = require('@babel/core');
8
+ const stream_to_array = require('stream-to-array');
9
+ const util = require('util');
10
+ const Stream = require('stream');
11
+ // Will put the JS together. Maybe images?
12
+
13
+ // Will put the JS together. Maybe images?
14
+ // Get everything ready to serve.
15
+
16
+ // Would need a JS file that contains refs to all of the components used.
17
+ // Examine what is in the website and what JS it needs.
18
+
19
+ // Should be customisable which system gets used to make the bundle.
20
+ // eg babel or esbuild. Browserify still seems to work on code here at least, but esbuild seems better.
21
+
22
+ // JS bundling will become a bit more advanced in this server. Similar principles.
23
+
24
+ // JS_Bundler reporting css that gets found while bundling JS would make sense.
25
+
26
+ // jsgui3-jsbuilder could be a separate project too.
27
+ // or jsgui3-js-builder even.
28
+
29
+
30
+ // bundle_css_from_js_file?
31
+ // scan_js_file_for_css perhaps.
32
+ // scan_js_for_css
33
+ // maybe scan an AST or AST stream as it's coming in.
34
+
35
+
36
+
37
+ const bundle_css_from_js = (js_file_path, options = {}) => {
38
+
39
+ return obs(async (next, complete, error) => {
40
+
41
+ // Go through each file? Just the first?
42
+
43
+ });
44
+
45
+ }
46
+
47
+
48
+
49
+ class CSS_Bundler extends Bundler {
50
+ constructor(spec = {}) {
51
+ super(spec);
52
+ }
53
+ }
54
+
55
+ CSS_Bundler.bundle_css_from_js = bundle_css_from_js;
56
+ module.exports = CSS_Bundler;
@@ -0,0 +1,214 @@
1
+ const Bundler = require('./bundler');
2
+ const Bundle = require('./bundle');
3
+ const {obs, prom_or_cb} = require('fnl');
4
+ const {tof} = require('jsgui3-html');
5
+ const fnlfs = require('fnlfs');
6
+ const browserify = require('browserify');
7
+ const babel = require('@babel/core');
8
+ const stream_to_array = require('stream-to-array');
9
+ const util = require('util');
10
+ const Stream = require('stream');
11
+ // Will put the JS together. Maybe images?
12
+
13
+ // Will put the JS together. Maybe images?
14
+ // Get everything ready to serve.
15
+
16
+ // Would need a JS file that contains refs to all of the components used.
17
+ // Examine what is in the website and what JS it needs.
18
+
19
+ // Should be customisable which system gets used to make the bundle.
20
+ // eg babel or esbuild. Browserify still seems to work on code here at least, but esbuild seems better.
21
+
22
+ // JS bundling will become a bit more advanced in this server. Similar principles.
23
+
24
+ // JS_Bundler reporting css that gets found while bundling JS would make sense.
25
+
26
+ // jsgui3-jsbuilder could be a separate project too.
27
+ // or jsgui3-js-builder even.
28
+
29
+
30
+
31
+
32
+
33
+
34
+ const bundle_js = (js_file_path, options = {}, callback) => {
35
+
36
+ // Could even split a file into its server and client components.
37
+ // Maybe providing found css would work well here.
38
+
39
+
40
+
41
+ // Returning an observable and not using a callback would work best.
42
+
43
+ const res = obs((next, complete, error) => {
44
+
45
+
46
+
47
+ let a = arguments;
48
+ if (typeof a[2] === 'function') {
49
+ callback = a[2];
50
+
51
+ options.include_sourcemaps = true;
52
+ }
53
+
54
+ (async () => {
55
+ // options
56
+ // may want a replacement within the client-side code.
57
+ // Can we call browserify on the code string?
58
+ // Creating a modified copy of the file would do.
59
+ // Load the file, modify it, save it under a different name
60
+
61
+ let s = new Stream.Readable(),
62
+ path = require('path').parse(js_file_path);
63
+
64
+ let fileContents = await fnlfs.load(js_file_path);
65
+
66
+
67
+ // Maybe do that post browserify - can read through whole thing to find the css template literals.
68
+
69
+ // Could use the CSS bundler to scan_js_for_css
70
+ // Seems as though it would be best as an observable.
71
+
72
+
73
+ // Could first get own system AST of the JS file.
74
+
75
+ // Modify the original file contents so that only client-side parts appear?
76
+ // Could be done by programatically removing a whole code block, what to do if it is run on the server.
77
+
78
+
79
+ //console.log('1) fileContents.length', fileContents.length);
80
+ // are there any replacements to do?
81
+ // options.replacements
82
+
83
+ if (options.js_mode === 'debug') {
84
+ options.include_sourcemaps = true;
85
+ }
86
+ if (options.js_mode === 'compress' || options.js_mode === 'mini') {
87
+ options.include_sourcemaps = false;
88
+ options.babel = 'mini';
89
+ }
90
+
91
+ //console.log('options.babel', options.babel);
92
+
93
+ if (options.replace) {
94
+ let s_file_contents = fileContents.toString();
95
+ //console.log('s_file_contents', s_file_contents);
96
+ each(options.replace, (text, key) => {
97
+ //console.log('key', key);
98
+ //console.log('text', text);
99
+ let running_fn = '(' + text + ')();'
100
+ //console.log('running_fn', running_fn);
101
+ s_file_contents = s_file_contents.split(key).join(running_fn);
102
+ })
103
+ fileContents = Buffer.from(s_file_contents);
104
+ //console.log('2) fileContents.length', fileContents.length);
105
+ }
106
+ // Then we can replace some of the file contents with specific content given when we tall it to serve that file.
107
+ // We have a space for client-side activation.
108
+ s.push(fileContents);
109
+ s.push(null);
110
+
111
+ //let include_sourcemaps = true;
112
+
113
+ let b = browserify(s, {
114
+ basedir: path.dir,
115
+ //builtins: false,
116
+ builtins: ['buffer', 'process'],
117
+ 'debug': options.include_sourcemaps
118
+ });
119
+
120
+ // May be able to better put the bundle stream info into the observable results.
121
+ // Browserify gets given the stream.
122
+
123
+ // Nice if this function could output a stream as well.
124
+
125
+
126
+ let parts = await stream_to_array(b.bundle());
127
+
128
+ const buffers = parts
129
+ .map(part => util.isBuffer(part) ? part : Buffer.from(part));
130
+ let buf_js = Buffer.concat(buffers);
131
+ let str_js = buf_js.toString();
132
+
133
+ // full browserified (client) js app.
134
+
135
+ let babel_option = options.babel
136
+ //console.log('babel_option', babel_option);
137
+ if (babel_option === 'es5') {
138
+
139
+ let o_transform = {
140
+ "presets": [
141
+ "es2015",
142
+ "es2017"
143
+ ],
144
+ "plugins": [
145
+ "transform-runtime"
146
+ ] //,
147
+ //'sourceMaps': 'inline'
148
+ };
149
+
150
+ if (options.include_sourcemaps) o_transform.sourceMaps = 'inline';
151
+ let res_transform = babel.transform(str_js, o_transform);
152
+ //console.log('res_transform', res_transform);
153
+ //console.log('Object.keys(res_transform)', Object.keys(res_transform));
154
+ let jst_es5 = res_transform.code;
155
+ //let {jst_es5, map, ast} = babel.transform(str_js);
156
+ //console.log('jst_es5.length', jst_es5.length);
157
+ buf_js = Buffer.from(jst_es5);
158
+ } else if (babel_option === 'mini') {
159
+ /*
160
+ let o_transform = {
161
+ presets: ["minify"]//,
162
+ //'sourceMaps': 'inline'
163
+ };
164
+ */
165
+ let o_transform = {
166
+ "presets": [
167
+ ["minify", {
168
+ //"mangle": {
169
+ //"exclude": ["MyCustomError"]
170
+ //},
171
+ //"unsafe": {
172
+ // "typeConstructors": false
173
+ //},
174
+ //"keepFnName": true
175
+ }]
176
+ ],
177
+ //plugins: ["minify-dead-code-elimination"]
178
+ };
179
+ if (options.include_sourcemaps) o_transform.sourceMaps = 'inline';
180
+
181
+ let res_transform = babel.transform(str_js, o_transform);
182
+ buf_js = Buffer.from(res_transform.code);
183
+ } else {
184
+ buf_js = Buffer.from(str_js);
185
+ }
186
+ complete(buf_js);
187
+ })();
188
+
189
+ })
190
+ if (callback) {
191
+ res.on('complete', (value) => {
192
+ callback(null, value);
193
+ });
194
+ res.on('error', err => {
195
+ callback(err);
196
+ })
197
+ } else {
198
+ return res;
199
+ }
200
+ // An observable would be better as result could include status messages (with their timings).
201
+
202
+ //return prom_or_cb((resolve, reject) => {
203
+
204
+ //}, callback);
205
+ }
206
+
207
+ class JS_Bundler extends Bundler {
208
+ constructor(spec = {}) {
209
+ super(spec);
210
+ }
211
+ }
212
+
213
+ JS_Bundler.bundle_js = bundle_js;
214
+ module.exports = JS_Bundler;
@@ -0,0 +1,74 @@
1
+
2
+ // Load in a JS file, such as square box client.
3
+ // Look for the CSS.
4
+
5
+
6
+ // Load a JS file into an OO structure
7
+ // Short term goals:
8
+
9
+ // Answering questions on the level of the file.
10
+ // Questions that are useful for finding out how to link the js files together.
11
+ // Don't want each file to be given it's own scope - want them to share local variable references to the the necessary things.
12
+ // Then those variable names won't be reused in inner scopes unless their replacement there is fine (ie they are otherwise unused).
13
+
14
+ // This will assemble somewhat detailed information about what happens inside a JavaScript file.
15
+ // The aim is to carry out and represent different kinds of analysis, but at the moment focusing of finding features.
16
+
17
+ // Root features
18
+
19
+ // Declaration features
20
+ // Object features
21
+
22
+ // Let's make it so that any node can be tagged as having / representing / being part of a feature of some kind.
23
+ // To begin with focus on what variables are being declared and used.
24
+
25
+ // Will be great to load in a whole load of JSGUI projects in such a way that the system / platform understands the ordering and
26
+ // recomposes them into a flat system where many / all declarations are local rather than using any import
27
+
28
+ // jsgui-lang
29
+ // ----------
30
+
31
+ // Recognise the basic / general signature of the full document.
32
+ // Recognise that the declarations are all within the root
33
+ // Recognise the exports object at the end exports an object that is composed from same-name references to items declared within lang-mini
34
+ // and only items declared within jsgui
35
+ // that it has no external references
36
+
37
+ // JSGUI_JS_File?
38
+
39
+
40
+
41
+ const JS_File = require('../resources/jsbuilder/JS_File/JS_File');
42
+ //const JS_File_Comprehension = require('../JS_File_Comprehension');
43
+ const path = require('path');
44
+ const fs = require('fs');
45
+ const {each} = require('lang-mini');
46
+
47
+ const JS_AST_Node = require('../resources/jsbuilder/JS_AST_Node_Extended/JS_AST_Node_Extended');
48
+
49
+ const test_js_file = () => {
50
+ const fnl_path = require.resolve('./../examples/square_box_client.js');
51
+ const file_path = fnl_path;
52
+ // path of lang mini...
53
+
54
+ // Write and test a simple and convenient way for analysing JS files and recompiling them.
55
+ // To start with, find the ways to arrange parts of the JS into 'platforms'.
56
+ // How to then build platforms into JS files.
57
+ // Will be about closures and sequences.
58
+ // A lot about unique naming, closures, and getting the sequence of definitions correct.
59
+ // ObjectPattern
60
+ const resolved_path = path.resolve(file_path);
61
+ //console.log('resolved_path', resolved_path);
62
+
63
+ const fstream = fs.createReadStream(resolved_path);
64
+
65
+ const jsf = JS_File.load_from_stream(fstream, file_path);
66
+ jsf.on('ready', () => {
67
+ const {js_ast_node_file} = jsf;
68
+ //const body_child_node_identifier_names = [];
69
+ //const map_bcnidns = {};
70
+ });
71
+
72
+ }
73
+
74
+ test_js_file();
@@ -0,0 +1,286 @@
1
+ const Bundler = require('./bundler');
2
+
3
+ const JS_Bundler = require('./js-bundler');
4
+
5
+ const Bundle = require('./bundle');
6
+ const {obs, prom_or_cb} = require('fnl');
7
+ const fnlfs = require('fnlfs');
8
+ const {tof, HTML_Document, Client_HTML_Document, Control} = require('jsgui3-html');
9
+ const util = require('util');
10
+ const Server_Page_Context = require('./../page-context');
11
+ // Will put the JS together. Maybe images?
12
+ // Get everything ready to serve.
13
+ const browserify = require('browserify');
14
+ const babel = require('@babel/core');
15
+ const stream_to_array = require('stream-to-array');
16
+
17
+ // Maybe some web pages should be unbundlable? Or we note that they are dynamic (somehow).
18
+ // Perhaps another fn should do that check. Don't assume all pages will bundle OK. Could raise obs error if needed.
19
+
20
+ // Bundling CSS from a JS page.
21
+
22
+ // const bundle_js_to_css
23
+
24
+
25
+ // Maybe best to move to a JS Bundler.
26
+
27
+ // CSS bundler too
28
+ // Could consult JS source files. Could use the JS bundler to get css from JS.
29
+
30
+ // Creating working bundles from JS (and other) source files seems like an important task.
31
+
32
+ const {bundle_js} = JS_Bundler;
33
+
34
+
35
+ const bundle_web_page = (webpage, options = {}) => {
36
+ const {content} = webpage;
37
+
38
+ let {disk_path_client_js} = options;
39
+
40
+
41
+ // Could use the CSS bundler to extract the css from the JS.
42
+
43
+
44
+
45
+ // Could look for the css within disk_path_client_js.
46
+
47
+
48
+ //if (options.js_client) js_client_disk_path =
49
+
50
+ // Then depending on the content type
51
+
52
+
53
+ const t_content = tof(content);
54
+
55
+ //console.log('content', content);
56
+ //console.log('t_content', t_content);
57
+
58
+ return obs((next, complete, error) => {
59
+ const res = new Bundle();
60
+
61
+ // The observable could / should return updates along the way, things that contribute to the full result.
62
+
63
+ if (t_content === 'string') {
64
+ // Hardly anything to bundle. No JS required, so it seems.
65
+ // Maybe put it inside a basic JSGUI page control...?
66
+
67
+ // Page may still have a title.
68
+ const html = `<html><head><title>${webpage.title}</title></head><body>${content}</body></html>`;
69
+ const buff = Buffer.from(html, "utf-8");
70
+
71
+ // and value with different types of compression....
72
+ // worth having them ready.
73
+ res.push({
74
+ 'path': webpage.path,
75
+ 'value': buff,
76
+ 'content-type': 'text/html'
77
+ });
78
+ complete(res);
79
+
80
+ } else if (t_content === 'control') {
81
+ //console.log ('content.context', content.context);
82
+ //console.log('content', content);
83
+
84
+ // May need to clone this control, putting it into new contexts.
85
+ // Or render it with a temporary context?
86
+
87
+ // Controls with temportary contexts could be useful.
88
+ if (content instanceof Control) {
89
+ //console.log('content is control');
90
+ //console.log('content.constructor.name', content.constructor.name);
91
+ if (content instanceof HTML_Document) {
92
+ console.log('content is an html document');
93
+
94
+ throw 'NYI';
95
+ } else {
96
+
97
+ // create an HTML document
98
+ // then put this control (or a clone of it) inside that HTML document.
99
+
100
+ // We may be changing the construction / rendering order here.
101
+ // Seem to be doing more construction of controls without a Page_Context.
102
+ // That page_context may only be important at a later stage.
103
+
104
+ // Some pages will render differently depending on when they are rendered.
105
+ // That may be why a server would need to individually build each page.
106
+ // Eg if there is SSR of latest news items.
107
+
108
+ // Question of pre-rendering or rendering on each page request.
109
+ // Maybe we don't bundle it if it includes dynamic content.
110
+ // Though we would need to bundle the JS.
111
+
112
+ // Could create a new page context.
113
+
114
+ //const cloned_content = content.clone();
115
+
116
+ // Should be able to clone a control?
117
+
118
+ //console.log('cloned_content', cloned_content);
119
+
120
+ // The page context may not have a request and response.
121
+ // For bundling, won't have one (unless one were made).
122
+
123
+ // Creating the JS bundle...
124
+
125
+ // Make it require jsgui-html for the moment.
126
+ // Requiring specific JS of the client control may make more sense....
127
+
128
+ // First let's bundle the JS.
129
+ // Or get the JS bundle for 'jsgui3-html'.
130
+
131
+ // js.serve_package('/js/app.js', js_client, o_serve_package, (err, served) => {
132
+ // maybe should make a JS_Bundler class.
133
+
134
+ // May need to be told earlier what file path we are using for the client js bundle.
135
+
136
+ const diskpath_js_client = disk_path_client_js || require.resolve('jsgui3-html');
137
+ //const diskpath_js_client = require.resolve('./../controls/page/admin.js');
138
+
139
+ // Bundle js could be an observable
140
+ // So when it finds CSS, it can output that.
141
+ // A Control's CSS property, within the JS definition.
142
+ // That can be output to a CSS file, copied or removed from the JS file.
143
+ bundle_js(diskpath_js_client, {
144
+ 'js_mode': 'mini',
145
+ 'babel': 'mini'
146
+ }, (err, res_bundle_js) => {
147
+ if (err) {
148
+ console.trace();
149
+ throw err;
150
+ } else {
151
+ //console.log('res_bundle_js', res_bundle_js);
152
+
153
+ // Could search at this point for class.css properties.
154
+ res.push({
155
+ 'path': webpage.path + 'js/app.js',
156
+ 'value': res_bundle_js,
157
+ 'content-type': 'text/javascript'
158
+ });
159
+
160
+ const spc = new Server_Page_Context({
161
+ //request:
162
+ });
163
+
164
+
165
+ const doc = new Client_HTML_Document({
166
+ context: spc
167
+ });
168
+ doc.include_js('/js/app.js');
169
+ doc.body.add(content);
170
+
171
+ // Getting it to load the JS would be nice...
172
+ // But maybe only do it automatically if it's an active document.
173
+ // If it's just generated JS then best not to bundle JS to load.
174
+
175
+ // Could also make smaller bundles for some specific parts of the app. Could improve speed.
176
+ //console.log('doc.html', doc.html);
177
+ const buff_html = Buffer.from(doc.html, "utf-8");
178
+ // But add the client-side stuff to that doc.
179
+
180
+ // Remember, this part is about bundling rather than serving.
181
+
182
+ res.push({
183
+ 'path': webpage.path,
184
+ 'value': buff_html,
185
+ 'content-type': 'text/html'
186
+ });
187
+ //console.log('pre complete bundlejs');
188
+ //console.log('res.length()', res.length());
189
+ complete(res);
190
+ }
191
+ });
192
+
193
+ // Need to create a new control
194
+
195
+ //throw 'NYI';
196
+ }
197
+ } else {
198
+ throw 'NYI';
199
+ }
200
+ } else {
201
+
202
+ //console.log('t_content', t_content);
203
+
204
+ if (t_content === 'function') {
205
+
206
+ const spc = new Server_Page_Context({
207
+ //request:
208
+ });
209
+
210
+ const Ctrl = content;
211
+ const ctrl = new Ctrl({
212
+ 'context': spc
213
+ });
214
+
215
+ if (ctrl instanceof HTML_Document) {
216
+ console.trace();
217
+ throw 'NYI';
218
+ } else {
219
+
220
+
221
+ const diskpath_js_client = disk_path_client_js || require.resolve('jsgui3-html');
222
+ //const diskpath_js_client = require.resolve('./../controls/page/admin.js');
223
+
224
+ bundle_js(diskpath_js_client, {
225
+ 'js_mode': 'mini',
226
+ 'babel': 'mini'
227
+ }, (err, res_bundle_js) => {
228
+ if (err) {
229
+ console.trace();
230
+ throw err;
231
+ } else {
232
+ //console.log('res_bundle_js', res_bundle_js);
233
+
234
+ res.push({
235
+ 'path': webpage.path + 'js/app.js',
236
+ 'value': res_bundle_js,
237
+ 'content-type': 'text/javascript'
238
+ });
239
+
240
+ const doc = new Client_HTML_Document({
241
+ context: spc
242
+ });
243
+ doc.include_js('/js/app.js');
244
+ doc.body.add(ctrl);
245
+
246
+ // Getting it to load the JS would be nice...
247
+ // But maybe only do it automatically if it's an active document.
248
+ // If it's just generated JS then best not to bundle JS to load.
249
+
250
+ // Could also make smaller bundles for some specific parts of the app. Could improve speed.
251
+ //console.log('doc.html', doc.html);
252
+ const buff_html = Buffer.from(doc.html, "utf-8");
253
+
254
+ res.push({
255
+ 'path': webpage.path,
256
+ 'value': buff_html,
257
+ 'content-type': 'text/html'
258
+ });
259
+ //console.log('pre complete bundlejs');
260
+ //console.log('res.length()', res.length());
261
+ complete(res);
262
+ }
263
+ });
264
+ }
265
+
266
+ } else if (false) {
267
+ console.trace();
268
+ throw 'NYI';
269
+ } else {
270
+ console.trace();
271
+ throw 'NYI';
272
+ }
273
+ }
274
+ });
275
+ //throw 'NYI';
276
+ }
277
+
278
+ class Webpage_Bundler extends Bundler {
279
+ constructor(spec = {}) {
280
+ super(spec);
281
+ }
282
+ }
283
+
284
+ Webpage_Bundler.bundle_web_page = bundle_web_page;
285
+
286
+ module.exports = Webpage_Bundler;
@@ -0,0 +1,23 @@
1
+ const Bundler = require('./bundler');
2
+ const Bundle = require('./bundle');
3
+ const {obs} = require('fnl');
4
+ const {tof} = require('jsgui3-html');
5
+
6
+ // Get everything ready to serve.
7
+
8
+ // Would need a JS file that contains refs to all of the components used.
9
+ // Examine what is in the website and what JS it needs.
10
+
11
+ // Bundling up the contents of a small/medium website so that contents are compressed and ready to serve.
12
+ // Could be useful for deploying to Android / iOS devices, maybe as apps.
13
+
14
+
15
+
16
+ class Website_Bundler extends Bundler {
17
+ constructor(spec = {}) {
18
+ super(spec);
19
+ }
20
+ }
21
+
22
+
23
+ module.exports = Website_Bundler;