jsgui3-server 0.0.83 → 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.
@@ -0,0 +1,48 @@
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
+
38
+
39
+
40
+
41
+ class CSS_Bundler extends Bundler {
42
+ constructor(spec = {}) {
43
+ super(spec);
44
+ }
45
+ }
46
+
47
+ //CSS_Bundler.bundle_css = bundle_css;
48
+ module.exports = CSS_Bundler;
@@ -23,6 +23,10 @@ const Stream = require('stream');
23
23
 
24
24
  // JS_Bundler reporting css that gets found while bundling JS would make sense.
25
25
 
26
+ // jsgui3-jsbuilder could be a separate project too.
27
+ // or jsgui3-js-builder even.
28
+
29
+
26
30
 
27
31
 
28
32
 
@@ -33,6 +37,8 @@ const bundle_js = (js_file_path, options = {}, callback) => {
33
37
 
34
38
  const res = obs((next, complete, error) => {
35
39
 
40
+
41
+
36
42
  let a = arguments;
37
43
  if (typeof a[2] === 'function') {
38
44
  callback = a[2];
@@ -52,6 +58,12 @@ const bundle_js = (js_file_path, options = {}, callback) => {
52
58
 
53
59
  let fileContents = await fnlfs.load(js_file_path);
54
60
 
61
+ // Could use the CSS bundler to scan_js_for_css
62
+ // Seems as though it would be best as an observable.
63
+
64
+
65
+ // Could first get own system AST of the JS file.
66
+
55
67
  // Modify the original file contents so that only client-side parts appear?
56
68
  // Could be done by programatically removing a whole code block, what to do if it is run on the server.
57
69
 
@@ -98,6 +110,10 @@ const bundle_js = (js_file_path, options = {}, callback) => {
98
110
  });
99
111
 
100
112
  // May be able to better put the bundle stream info into the observable results.
113
+ // Browserify gets given the stream.
114
+
115
+ // Nice if this function could output a stream as well.
116
+
101
117
 
102
118
  let parts = await stream_to_array(b.bundle());
103
119
 
@@ -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();
@@ -68,7 +68,7 @@ const bundle_web_page = (webpage, options = {}) => {
68
68
  });
69
69
  complete(res);
70
70
 
71
- } if (t_content === 'control') {
71
+ } else if (t_content === 'control') {
72
72
  //console.log ('content.context', content.context);
73
73
  //console.log('content', content);
74
74
 
package/package.json CHANGED
@@ -4,8 +4,8 @@
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
6
  "@babel/core": "^7.17.9",
7
- "@babel/parser": "7.17.9",
8
7
  "@babel/generator": "^7.17.9",
8
+ "@babel/parser": "7.17.9",
9
9
  "babel-plugin-transform-runtime": "^6.23.0",
10
10
  "babel-preset-minify": "^0.5.1",
11
11
  "browserify": "17.0.0",
@@ -15,7 +15,6 @@
15
15
  "fnlfs": "^0.0.24",
16
16
  "jsgui3-client": "^0.0.67",
17
17
  "jsgui3-html": "0.0.95",
18
-
19
18
  "multiparty": "^4.2.3",
20
19
  "ncp": "^2.0.0",
21
20
  "obext": "0.0.23",
@@ -41,5 +40,5 @@
41
40
  "type": "git",
42
41
  "url": "https://github.com/metabench/jsgui3-server.git"
43
42
  },
44
- "version": "0.0.83"
43
+ "version": "0.0.84"
45
44
  }
@@ -99,14 +99,14 @@ class HTTP_Website_Publisher extends HTTP_Publisher {
99
99
  obs_bundling.on('complete', res => {
100
100
  //console.log('obs_bundling res', res);
101
101
  const bundle = res;
102
- console.log('bundle._arr.length', bundle._arr.length);
103
- console.log('Object.keys(bundle)', Object.keys(bundle));
102
+ //console.log('bundle._arr.length', bundle._arr.length);
103
+ //console.log('Object.keys(bundle)', Object.keys(bundle));
104
104
 
105
105
  if (bundle._arr.length === 1) {
106
106
  // And check it's HTML inside...?
107
107
 
108
108
  const bundled_item = bundle._arr[0];
109
- console.log('bundled_item', bundled_item);
109
+ //console.log('bundled_item', bundled_item);
110
110
 
111
111
  if (bundled_item['content-type']) {
112
112
  const ct = bundled_item['content-type'];
@@ -145,7 +145,7 @@ class HTTP_Website_Publisher extends HTTP_Publisher {
145
145
 
146
146
  each(bundle, item => {
147
147
  //console.log('item', item);
148
- console.log('item.path', item.path, item['content-type']);
148
+ //console.log('item.path', item.path, item['content-type']);
149
149
 
150
150
  if (item['content-type']) {
151
151
  const ct = item['content-type'];
@@ -185,13 +185,10 @@ class HTTP_Website_Publisher extends HTTP_Publisher {
185
185
  })
186
186
 
187
187
  }));
188
-
189
188
  //throw 'NYI';
190
189
  }
191
-
192
190
  if (website) {
193
191
  setup_website_publishing(website);
194
-
195
192
  }
196
193
 
197
194
  // Create a router for the website if it does not already have one.
@@ -200,7 +197,6 @@ class HTTP_Website_Publisher extends HTTP_Publisher {
200
197
  // Do we already know all of the pages in the website?
201
198
  // Maybe there are dynamic pages.
202
199
 
203
-
204
200
  // Probably best to come up with a bundle here, or at an early stage.
205
201
 
206
202
  // .prepare_bundle?
@@ -247,10 +243,6 @@ class HTTP_Website_Publisher extends HTTP_Publisher {
247
243
 
248
244
  // Possibly the publisher has the router for the website.
249
245
 
250
-
251
-
252
-
253
-
254
246
  // May have bundle already prepared anyway.
255
247
  // Possibly the Website or the Website_Resource could do the bundling / building.
256
248
  // Could even bundle into a ZIP file :)
@@ -533,6 +533,9 @@ const deep_iterate_babel_node_$INTERNAL = (babel_node, depth, path, common, call
533
533
  } else if (type === 'Super') {
534
534
  return deep_iterate_babel_super_node(babel_node, depth, path, common, callback);
535
535
  } else {
536
+
537
+ // Need to make this handle a template literal too.
538
+
536
539
  console.log('');
537
540
  console.log('type', type);
538
541
  console.log('');
@@ -9,7 +9,7 @@
9
9
 
10
10
  // Load a JS file into an OO structure
11
11
 
12
- const JS_File = require('..//JS_File/JS_File');
12
+ const JS_File = require('../JS_File/JS_File');
13
13
  //const JS_File_Comprehension = require('../JS_File_Comprehension');
14
14
  const path = require('path');
15
15
  const fs = require('fs');
@@ -33,7 +33,7 @@
33
33
 
34
34
 
35
35
 
36
- const JS_File = require('..//JS_File/JS_File');
36
+ const JS_File = require('../JS_File/JS_File');
37
37
  //const JS_File_Comprehension = require('../JS_File_Comprehension');
38
38
  const path = require('path');
39
39
  const fs = require('fs');
@@ -48,7 +48,7 @@ const test_js_file = () => {
48
48
  // stream the file in.
49
49
  const lm_path = '../../../../../tools/lang-mini/lang-mini.js'
50
50
  const lt_path = '../../../../../tools/lang-tools/lang.js'
51
- const fnl_path = '../../../../../tools/fnl/fnl.js'
51
+ const fnl_path = require.resolve('fnl');
52
52
  const filecomp_path = '../JS_File_Comprehension.js';
53
53
  const jsfile_path = '../JS_File/JS_File.js';
54
54
  const jsbuilder_path = '../JS_Builder.js';
package/roadmap.md CHANGED
@@ -38,6 +38,24 @@ A file manager interface would be cool.
38
38
  Maybe would need to use file system resource
39
39
  Could work on remote file system too.
40
40
 
41
+ Or make clear this is the core of the server?
42
+ jsgui3-server-core perhaps?
43
+
44
+ A Default server? Could also include file management.
45
+
46
+
47
+ jsgui3-website could be helpful
48
+ a .deploy function
49
+ possibly the website could be hosted over multiple different servers, deployment could work for that.
50
+ The website would not only be within the server.
51
+
52
+ Could have a deployment wizard.
53
+
54
+
55
+
56
+
57
+
58
+
41
59
 
42
60
 
43
61
 
package/server.js CHANGED
@@ -433,6 +433,16 @@ JSGUI_Server.Page_Context = Server_Page_Context;
433
433
  JSGUI_Server.Server_Page_Context = Server_Page_Context;
434
434
  JSGUI_Server.Website_Resource = Website_Resource;
435
435
 
436
+ // Maybe jsgui3-website should be its own module.
437
+ // Would (completely?) abstract away from the server.
438
+
439
+ // And maybe jsgui3-webpage
440
+ // Could be integrated within jsgui3-server.
441
+
442
+
443
+
444
+
445
+
436
446
  module.exports = JSGUI_Server;
437
447
 
438
448
  if (require.main === module) {