jsgui3-server 0.0.103 → 0.0.106

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.
@@ -82,10 +82,10 @@ if (require.main === module) {
82
82
 
83
83
  const server = new Server({
84
84
  Ctrl: Demo_UI,
85
+ //debug: true,
85
86
  // Giving it the Ctrl and disk path client js should enable to server to get the JS-bundled CSS from the file(s).
86
87
  // Putting the JS files through proper parsing and into a syntax tree would be best.
87
88
 
88
-
89
89
  //'js_mode': 'debug',
90
90
  'src_path_client_js': require.resolve('./client.js'),
91
91
  //debug: true // should not minify the js, should include the symbols.
@@ -92,7 +92,10 @@ if (require.main === module) {
92
92
 
93
93
  // then start the server....
94
94
  // be able to choose the port / ports?
95
- console.log('waiting for server ready event');
95
+ //console.log('waiting for server ready event');
96
+
97
+ //
98
+
96
99
  server.on('ready', () => {
97
100
  console.log('server ready');
98
101
 
@@ -0,0 +1,208 @@
1
+ const jsgui = require('jsgui3-client');
2
+ const {controls, Control, mixins} = jsgui;
3
+ const {dragable} = mixins;
4
+
5
+ const Active_HTML_Document = require('../../../controls/Active_HTML_Document');
6
+
7
+ // Maybe better to include it within an Active_HTML_Document.
8
+
9
+ // Is currently a decent demo of a small active control running from the server, activated on the client.
10
+ // This square box is really simple, and it demonstrates the principle of the code for the draggable square box not being all that complex
11
+ // compared to a description of it.
12
+
13
+ // A container with reorderable internal draggable items could help.
14
+
15
+ // would be nice to be able to have all code in 1 file...???
16
+ // Though the sever code should be separate.
17
+
18
+
19
+ // Relies on extracting CSS from JS files.
20
+ // Usage of windows should be very easy on this level.
21
+
22
+
23
+ class Demo_UI extends Active_HTML_Document {
24
+ constructor(spec = {}) {
25
+ spec.__type_name = spec.__type_name || 'demo_ui';
26
+ super(spec);
27
+ const {context} = this;
28
+
29
+ // Make sure it requires the correct CSS.
30
+ // Though making that 'effortless' on the server may help more.
31
+
32
+
33
+ // Maybe can't do this here???
34
+
35
+ // Does not have .body (yet) on the client.
36
+ // simple way to get the client to attach the body of the Active_HTML_Document?
37
+ // maybe with jsgui-data-controls?
38
+ // Though automatically having the .body property available on the client without sending extra HTTP
39
+ // plumbing will help.
40
+
41
+ // .body will not be available before activation.
42
+
43
+
44
+ // .body should not be a normal function....?
45
+ // a getter function would be better.
46
+
47
+
48
+
49
+ if (typeof this.body.add_class === 'function') {
50
+ this.body.add_class('demo-ui');
51
+ }
52
+
53
+ //console.log('this.body', this.body);
54
+ //console.log('this.body.add_class', this.body.add_class);
55
+
56
+
57
+ const compose = () => {
58
+ // put 20 of them in place.
59
+
60
+ // Then how to arrange them...?
61
+
62
+ const window = new controls.Window({
63
+ context: context,
64
+ title: 'jsgui3-html Window Control',
65
+ pos: [10, 10]
66
+ });
67
+
68
+ // Have Tab_Page items inside???
69
+
70
+ // Maybe need some more code to do with setting up the radio button group of tabs....
71
+
72
+
73
+
74
+ const tabbed_panel = new controls.Tabbed_Panel({
75
+ context,
76
+
77
+ // Nice to be able to make it flexible in terms of taking string names for the tab specifications.
78
+
79
+
80
+
81
+ tabs: ['tab 1', 'tab 2']
82
+ });
83
+
84
+
85
+ window.inner.add(tabbed_panel);
86
+
87
+ this.body.add(window);
88
+
89
+
90
+
91
+
92
+
93
+
94
+ }
95
+ if (!spec.el) {
96
+ compose();
97
+ }
98
+ }
99
+ activate() {
100
+ if (!this.__active) {
101
+ super.activate();
102
+ const {context} = this;
103
+
104
+ //console.log('activate Demo_UI');
105
+ // listen for the context events regarding frames, changes, resizing.
106
+
107
+ context.on('window-resize', e_resize => {
108
+ //console.log('window-resize', e_resize);
109
+
110
+ // Make all internal controls go absolute in terms of position
111
+ // Remove them from their containers too?
112
+ // Ie their containing divs?
113
+
114
+ // Would be nice to do this really simple with a fn call or very simple piece of code.
115
+ // Like get absolute position, set position to be absolute, move to that position.
116
+ // Maybe something within jsgui3-client helps with this, this is more about what needs to be done on the client.
117
+ // Though recognising perf implications, it's (more) OK to include client-side functionality in jsgui3-html.
118
+
119
+
120
+
121
+
122
+
123
+
124
+ });
125
+
126
+ }
127
+ }
128
+ }
129
+
130
+ // Include this in bundling.
131
+ // Want CSS bundling so that styles are read out from the JS document and compiled to a stylesheet.
132
+
133
+ //controls.Demo_UI = Demo_UI;
134
+
135
+ // A css file may be an easier way to get started...?
136
+ // Want to support but not require css in js.
137
+
138
+ // But need to set up the serving of the CSS both on the server, and on the client.
139
+ // Ofc setting it up on the server first is important - then can that stage set it up in the doc sent to the client?
140
+
141
+ // Including the CSS from the JS like before.
142
+ // Needs to extract the CSS and serve it as a separate CSS file.
143
+ // Should also have end-to-end regression tests so this does not break again in the future.
144
+ // The code was kind of clunky and got refactored away.
145
+ //
146
+
147
+ // Would need to parse the JS files to extract the CSS.
148
+ // Maybe could do it an easier way??? Now that it's easy, want a faster way.
149
+
150
+
151
+ Demo_UI.css = `
152
+
153
+ * {
154
+ margin: 0;
155
+ padding: 0;
156
+ }
157
+
158
+ body {
159
+ overflow-x: hidden;
160
+ overflow-y: hidden;
161
+ background-color: #E0E0E0;
162
+ }
163
+
164
+ .demo-ui {
165
+
166
+ /*
167
+
168
+ display: flex;
169
+ flex-wrap: wrap;
170
+
171
+ flex-direction: column;
172
+ justify-content: center;
173
+ align-items: center;
174
+ text-align: center;
175
+ min-height: 100vh;
176
+ */
177
+
178
+ }
179
+ `;
180
+
181
+ // But may want to remove them from that flex upon picking up / dropping them.
182
+ // Maybe best upon drop.
183
+
184
+ // Maybe want other examples that use absolute positioning to position the items at the start?
185
+ //
186
+
187
+
188
+
189
+ //controls.Square_Box = Square_Box;
190
+ // could export jsgui with the updated controls....
191
+ // so that they are in the correct Page Context.?
192
+
193
+
194
+ controls.Demo_UI = Demo_UI;
195
+
196
+ module.exports = jsgui;
197
+
198
+ /*
199
+ module.exports = {
200
+ Square_Box: Square_Box,
201
+ Demo_UI: Demo_UI
202
+ }
203
+ */
204
+
205
+ // Then if window...?
206
+
207
+ // Need to add the Square_Box control to the context or original map of controls...
208
+
@@ -0,0 +1,118 @@
1
+ const jsgui = require('./client');
2
+
3
+ const {Demo_UI} = jsgui.controls;
4
+ const Server = require('../../../server');
5
+
6
+
7
+ // what would be the (best?) way to include the whole thing in one JS file?
8
+ // Maybe don't try that right now.
9
+ // maybe standardise on the dir, then client.js and server.js inside.
10
+
11
+
12
+
13
+ // Want to exclude this from the client bundle.
14
+ // Some kind of marking to say that it's server-side only?
15
+
16
+ // Need to include JSGUI3 js within the client document.
17
+ // Seems like an earlier code simplification removed this functionality?
18
+ // Just specifying a Ctrl for the server - and giving it the 'disk_path_client_js'.
19
+ // May as well fix that....
20
+
21
+
22
+ // The server code may be tiny, it seems best not to abstract it away totally though.
23
+ // At least not for the moment.
24
+
25
+
26
+
27
+
28
+
29
+ if (require.main === module) {
30
+
31
+ // By default should include the JS and the CSS.
32
+ // By reference, serving them from their respective paths.
33
+
34
+
35
+ // This API is not working right now.
36
+
37
+ // A very simple syntax for running a single control would be great.
38
+
39
+ // Need to in the default (server) configuration build and serve the client-side app.
40
+ // Want to be able to make interactive apps quickly with minimal server side code that needs to be written as boilerplate to
41
+ // get the app running.
42
+
43
+ // Though maybe defining a webpage, that serves the client js, and renders the control on the server, and activates it on the client,
44
+ // would be the right approach.
45
+
46
+ // Want to make the code really explicit, in a simple way.
47
+
48
+
49
+ // eg { '/': Demo_UI }
50
+ // eg { '*': Demo_UI }
51
+ // as at least it explicitly assigns it to the '/' route
52
+
53
+
54
+ // But worth keeping the '/' Ctrl property?
55
+ // Could change it to explicitly setting the route(s).
56
+
57
+ // Do want it to build the client js on start.
58
+
59
+ // Could extract the CSS from the file itself, or maybe better reading it from the classes and objects that are loaded / referenced.
60
+ // All kinds of complex server program structures exist already, so could use Publishers if needed for some things.
61
+ // But need to keep the surface-level API really simple.
62
+
63
+ // Maybe define a Webpage and maybe use / define an HTML_Webpage_Publisher for example too.
64
+ // The clearest code would be really explicit about what it does, but in terms of almost English idioms
65
+ // and on the surface-level not spelling out in great detail what it's doing, but referencing objects and
66
+ // instructions with clear purposes, though details could be obscure at the top level. Eg it's the publisher's responsibility
67
+ // to include the CSS and JS that's needed to get it to run. A publisher is referenced and used, and it does its thing.
68
+
69
+ // The Server could automatically involk the use of a Publisher.
70
+ // May be better to either require or recommend more explicit code, have them in the examples,
71
+ // but also to document some shortcuts, defaults, and abbreviations (though they may omit some essential info, so not recommended for beginners)
72
+
73
+ // Could have a tabbed view for examples for 'explicit' and 'short' notations when there are multiple.
74
+
75
+ // jsgui3-html-suite may be of use, for some more extended controls that are built on top of jsgui3-html, but not specifically
76
+ // client or server.
77
+
78
+
79
+
80
+
81
+
82
+
83
+ const server = new Server({
84
+ Ctrl: Demo_UI,
85
+ //debug: true,
86
+ // Giving it the Ctrl and disk path client js should enable to server to get the JS-bundled CSS from the file(s).
87
+ // Putting the JS files through proper parsing and into a syntax tree would be best.
88
+
89
+ //'js_mode': 'debug',
90
+ 'src_path_client_js': require.resolve('./client.js'),
91
+ //debug: true // should not minify the js, should include the symbols.
92
+ //js_client: require.resolve('./square_box.js')
93
+ });
94
+ // A callback or event for when the bundling has been completed
95
+ // a 'ready' event.
96
+
97
+ // then start the server....
98
+ // be able to choose the port / ports?
99
+ console.log('waiting for server ready event');
100
+ server.on('ready', () => {
101
+ console.log('server ready');
102
+
103
+ // server start will change to observable?
104
+
105
+ server.start(8080, function (err, cb_start) {
106
+ if (err) {
107
+ throw err;
108
+ } else {
109
+ // Should have build it by now...
110
+
111
+ console.log('server started');
112
+ }
113
+ });
114
+ })
115
+
116
+
117
+
118
+ }
package/package.json CHANGED
@@ -11,13 +11,13 @@
11
11
  "browserify": "17.0.0",
12
12
  "child-process": "^1.0.2",
13
13
  "cookies": "^0.8.0",
14
- "esbuild": "^0.19.4",
14
+ "esbuild": "^0.19.5",
15
15
  "fnl": "^0.0.29",
16
16
  "fnlfs": "^0.0.29",
17
- "jsgui3-client": "^0.0.88",
17
+ "jsgui3-client": "^0.0.92",
18
18
  "jsgui3-webpage": "^0.0.6",
19
19
  "jsgui3-website": "^0.0.6",
20
- "lang-tools": "^0.0.18",
20
+ "lang-tools": "^0.0.22",
21
21
 
22
22
  "multiparty": "^4.2.3",
23
23
  "ncp": "^2.0.0",
@@ -45,5 +45,5 @@
45
45
  "type": "git",
46
46
  "url": "https://github.com/metabench/jsgui3-server.git"
47
47
  },
48
- "version": "0.0.103"
48
+ "version": "0.0.106"
49
49
  }
@@ -599,6 +599,20 @@ const deep_iterate_babel_for_in_statement_node = (babel_node, depth, path, commo
599
599
 
600
600
  };
601
601
 
602
+ const deep_iterate_babel_for_of_statement_node = (babel_node, depth, path, common, callback) => {
603
+ // value.raw is basically it.
604
+
605
+ const {left, right, body} = babel_node;
606
+ let sibling_number = 0;
607
+
608
+ deep_iterate_babel_node_$INTERNAL(left, depth + 1, path + sibling_number++ + '/', common, callback);
609
+ deep_iterate_babel_node_$INTERNAL(right, depth + 1, path + sibling_number++ + '/', common, callback);
610
+ deep_iterate_babel_node_$INTERNAL(body, depth + 1, path + sibling_number++ + '/', common, callback);
611
+
612
+ };
613
+
614
+ // deep_iterate_babel_for_of_statement_node
615
+
602
616
  // deep_iterate_babel_sequence_expression_node
603
617
 
604
618
 
@@ -771,6 +785,8 @@ const deep_iterate_babel_node_$INTERNAL = (babel_node, depth, path, common, call
771
785
  return deep_iterate_babel_break_statement_node(babel_node, depth, path, common, callback);
772
786
  } else if (type === 'ForInStatement') {
773
787
  return deep_iterate_babel_for_in_statement_node(babel_node, depth, path, common, callback);
788
+ } else if (type === 'ForOfStatement') {
789
+ return deep_iterate_babel_for_of_statement_node(babel_node, depth, path, common, callback);
774
790
  } else if (type === 'SequenceExpression') {
775
791
  return deep_iterate_babel_sequence_expression_node(babel_node, depth, path, common, callback);
776
792
  } else if (type === 'ClassExpression') {
@@ -779,6 +795,9 @@ const deep_iterate_babel_node_$INTERNAL = (babel_node, depth, path, common, call
779
795
  return deep_iterate_babel_rest_element_node(babel_node, depth, path, common, callback);
780
796
  } else if (type === 'AwaitExpression') {
781
797
  return deep_iterate_babel_await_expression_node(babel_node, depth, path, common, callback);
798
+
799
+ // ForOfStatement
800
+
782
801
  } else {
783
802
 
784
803
  // FunctionDeclaration TemplateLiteral TemplateElement TryStatement CatchClause