jsgui3-server 0.0.120 → 0.0.121

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 (38) hide show
  1. package/examples/boxes/square_boxes.js +3 -0
  2. package/examples/boxes/square_boxes_client.js +5 -1
  3. package/examples/controls/11) window, mirrored text fields/client.js +31 -273
  4. package/examples/controls/11b) window, shared Data_Object model mirrored text fields/client.js +84 -366
  5. package/examples/controls/11c) window, shared Data_Value model mirrored text fields/client.js +2 -2
  6. package/examples/controls/11d) window, shared model mirrored integer text fields/both.js +17 -0
  7. package/examples/controls/11d) window, shared model mirrored integer text fields/client.js +65 -396
  8. package/examples/controls/11d) window, shared model mirrored integer text fields/server.js +4 -116
  9. package/examples/controls/12) window, Select_Options control/client.js +17 -0
  10. package/examples/controls/13) window, shared model mirrored lat_long/client.js +933 -0
  11. package/examples/controls/13) window, shared model mirrored lat_long/server.js +50 -0
  12. package/examples/controls/14) window, control compositional model/client.js +328 -0
  13. package/examples/controls/14) window, control compositional model/server.js +118 -0
  14. package/examples/controls/14a) window, control spec has compositional model/client.js +440 -0
  15. package/examples/controls/14a) window, control spec has compositional model/server.js +118 -0
  16. package/examples/controls/15) window, text field/client.js +256 -0
  17. package/examples/controls/15) window, text field/server.js +39 -0
  18. package/examples/controls/16) Window([Text_Input])/client.js +266 -0
  19. package/examples/controls/16) Window([Text_Input])/server.js +109 -0
  20. package/examples/controls/16a) Window([Text_Input]) Integer data.model.data_type/client.js +494 -0
  21. package/examples/controls/16a) Window([Text_Input]) Integer data.model.data_type/isomorphic.js +24 -0
  22. package/examples/controls/16a) Window([Text_Input]) Integer data.model.data_type/server.js +73 -0
  23. package/examples/controls/2b) two window, context menus/client.js +193 -0
  24. package/examples/controls/2b) two window, context menus/server.js +114 -0
  25. package/examples/controls/3) five windows/server.js +0 -1
  26. package/examples/controls/4) window, tabbed panel/client.js +15 -2
  27. package/examples/controls/4a) window, tabbed panel with various controls inside/client.js +233 -0
  28. package/examples/controls/4a) window, tabbed panel with various controls inside/server.js +118 -0
  29. package/examples/controls/5) window, grid/client.js +289 -9
  30. package/examples/controls/5) window, grid/server.js +2 -0
  31. package/examples/controls/8) window, checkbox/client.js +63 -101
  32. package/package.json +11 -11
  33. package/publishers/http-webpage-publisher.js +4 -5
  34. package/resources/jsbuilder/babel/deep_iterate/deep_iterate_babel.js +5 -1
  35. package/resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild.js +9 -6
  36. package/resources/processors/bundlers/js/esbuild/Core_JS_Single_File_Minifying_Bundler_Using_ESBuild.js +2 -1
  37. package/resources/processors/extractors/Extractor.js +3 -1
  38. package/resources/processors/extractors/js/css_and_js/AST_Node/CSS_And_JS_From_JS_String_Using_AST_Node_Extractor.js +19 -4
@@ -0,0 +1,50 @@
1
+ const jsgui = require('./client');
2
+
3
+ const {Demo_UI} = jsgui.controls;
4
+ const Server = require('../../../server');
5
+
6
+
7
+ // A single lat long that shows the validation status would help.
8
+ // Could have a number of how many items in there have failed validating.
9
+ // Eg count of inner failed validations.
10
+ // Then each of the controls for the inner failed validations would display it with their own indicator.
11
+
12
+
13
+
14
+
15
+ if (require.main === module) {
16
+
17
+ const server = new Server({
18
+ Ctrl: Demo_UI,
19
+ //debug: true,
20
+ 'src_path_client_js': require.resolve('./client.js')
21
+ //js_client: require.resolve('./square_box.js')
22
+ });
23
+
24
+
25
+
26
+ // A callback or event for when the bundling has been completed
27
+ // a 'ready' event.
28
+
29
+ // then start the server....
30
+ // be able to choose the port / ports?
31
+ console.log('waiting for server ready event');
32
+ server.one('ready', () => {
33
+ console.log('server ready');
34
+
35
+ // server start will change to observable?
36
+
37
+ server.start(8080, function (err, cb_start) {
38
+ if (err) {
39
+ throw err;
40
+ } else {
41
+ // Should have build it by now...
42
+
43
+ console.log('server started');
44
+ }
45
+ });
46
+ })
47
+
48
+
49
+
50
+ }
@@ -0,0 +1,328 @@
1
+ const jsgui = require('jsgui3-client');
2
+ const {controls, Control, mixins} = jsgui;
3
+ const {dragable} = mixins;
4
+
5
+
6
+ const {Checkbox} = controls;
7
+
8
+ const Active_HTML_Document = require('../../../controls/Active_HTML_Document');
9
+
10
+ // Maybe better to include it within an Active_HTML_Document.
11
+
12
+ // Is currently a decent demo of a small active control running from the server, activated on the client.
13
+ // This square box is really simple, and it demonstrates the principle of the code for the draggable square box not being all that complex
14
+ // compared to a description of it.
15
+
16
+ // A container with reorderable internal draggable items could help.
17
+
18
+ // would be nice to be able to have all code in 1 file...???
19
+ // Though the sever code should be separate.
20
+
21
+
22
+ // Relies on extracting CSS from JS files.
23
+ // Usage of windows should be very easy on this level.
24
+
25
+ // Want more demos for some specific features, such as lists.
26
+ // Putting a bunch of different examples within a tabbed view would help.
27
+ // Want quite a lot to be possible without client-side js when it can be done that way.
28
+ // Progressive enhancement.
29
+
30
+
31
+
32
+
33
+ // Could change the checkbox so that it internally uses compositional models, and that this works the same.
34
+ // Though first let's directly work on compositional models.
35
+
36
+
37
+
38
+
39
+ class Demo_UI extends Active_HTML_Document {
40
+ constructor(spec = {}) {
41
+ spec.__type_name = spec.__type_name || 'demo_ui';
42
+ super(spec);
43
+ const {context} = this;
44
+
45
+ // Make sure it requires the correct CSS.
46
+ // Though making that 'effortless' on the server may help more.
47
+
48
+
49
+ // Maybe can't do this here???
50
+
51
+ // Does not have .body (yet) on the client.
52
+ // simple way to get the client to attach the body of the Active_HTML_Document?
53
+ // maybe with jsgui-data-controls?
54
+ // Though automatically having the .body property available on the client without sending extra HTTP
55
+ // plumbing will help.
56
+
57
+ // .body will not be available before activation.
58
+
59
+
60
+ // .body should not be a normal function....?
61
+ // a getter function would be better.
62
+
63
+
64
+ if (typeof this.body.add_class === 'function') {
65
+ this.body.add_class('demo-ui');
66
+ }
67
+
68
+ //console.log('this.body', this.body);
69
+ //console.log('this.body.add_class', this.body.add_class);
70
+
71
+ // And create a compositional model here???
72
+
73
+
74
+ // Want to be able to better specify the content of controls that are made here.
75
+
76
+ // Also define some kind of content model?
77
+ // have .content for the moment, want to keep this, but maybe move it (sometime)
78
+
79
+ // .ui.content.model even????
80
+
81
+ // Or in the spec, giving the compositional model(s).
82
+
83
+
84
+ // Need to get into representational models too.
85
+ // How data can be represented on controls.
86
+
87
+ // And then being able to have the most suitable, or the specified controls, chosen.
88
+
89
+ // And the window itself using the compositional model???
90
+ // Though we need to really use some kind of content.compositional.model??
91
+ // .compositional.content.model?????
92
+ // .view.ui.compositional.content.model???
93
+
94
+
95
+ // Specifying the inner content properly....
96
+ // Using compositional models that work with inner content....
97
+
98
+ // Do want to see about using compositional models for shorter code.
99
+ // Also more advanced compositional models, with things like repeats / loops.
100
+ // Be able to express the compositional model of a grid efficiently in the abstract way.
101
+ // Repeated rows, repeated cells in columns.
102
+
103
+ // See about making more concise controls using the new compositional model functionality.
104
+ // Maybe focus on a small number of simple ones for the moment.
105
+ // Like Text_Field, Text_Input.
106
+
107
+ // Def seems worth moving towards using the compositional model(s) system.
108
+ // Also the ctrl.data.model system.
109
+ // And a ctrl.view.ui.data.representation.model system.
110
+ // Being able to get the data in the data.model represented in the controls in the compositional model.
111
+
112
+ // Want it to have very concise syntax to use controls with appropriate data.
113
+ // This should make for a very convenient high level API for jsgui.
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+ // A version that uses the compositional model for the window would help!
137
+
138
+
139
+
140
+ const compose = () => {
141
+ // put 20 of them in place.
142
+
143
+ // Then how to arrange them...?
144
+
145
+
146
+ // Want to be able to include the content here easily, whether using a compositional model (on the surface) or not.
147
+ // Getting into finer implementation details on compositional models, and specifying them in the spec will help.
148
+
149
+ // Need to facilitate a variety of features to make the compositional model system really useful, and integrate it with
150
+ // the data model system.
151
+
152
+
153
+
154
+
155
+
156
+ const window = new controls.Window({
157
+ context: context,
158
+ title: 'jsgui3-html Checkbox Control',
159
+ pos: [10, 10]
160
+ });
161
+
162
+ // Let's just have a control here for the moment.
163
+ // Give it a compositional model too....
164
+
165
+ // Maybe shortcut to the 'composition' or 'comp' in the spec.
166
+ // However, want to try explicitly setting its compositional model for the moment.
167
+ const ctrl_using_compositional_model = new Control({context});
168
+ const setup_using_controls_with_specs = () => {
169
+ ctrl_using_compositional_model.view.ui.compositional.model = [[Control, {
170
+ size: [64, 128],
171
+ background: {
172
+ color: '#6655CC'
173
+ }
174
+ }], [Control, {
175
+ size: [64, 128],
176
+ background: {
177
+ color: '#DD55CC'
178
+ }
179
+ }]];
180
+
181
+ }
182
+
183
+ setup_using_controls_with_specs();
184
+
185
+
186
+ console.log('ctrl_using_compositional_model.view.ui.compositional.model', ctrl_using_compositional_model.view.ui.compositional.model);
187
+
188
+
189
+ window.inner.add(ctrl_using_compositional_model);
190
+
191
+
192
+ /*
193
+
194
+
195
+
196
+
197
+ const checkbox = new Checkbox({
198
+ context,
199
+ label: {
200
+ text: 'A checkbox'
201
+ }
202
+ })
203
+
204
+ window.inner.add(checkbox);
205
+ */
206
+
207
+ this.body.add(window);
208
+
209
+
210
+
211
+
212
+
213
+
214
+ }
215
+ if (!spec.el) {
216
+ compose();
217
+ }
218
+ }
219
+ activate() {
220
+ if (!this.__active) {
221
+ super.activate();
222
+ const {context} = this;
223
+
224
+ //console.log('activate Demo_UI');
225
+ // listen for the context events regarding frames, changes, resizing.
226
+
227
+ context.on('window-resize', e_resize => {
228
+ //console.log('window-resize', e_resize);
229
+
230
+ // Make all internal controls go absolute in terms of position
231
+ // Remove them from their containers too?
232
+ // Ie their containing divs?
233
+
234
+ // Would be nice to do this really simple with a fn call or very simple piece of code.
235
+ // Like get absolute position, set position to be absolute, move to that position.
236
+ // Maybe something within jsgui3-client helps with this, this is more about what needs to be done on the client.
237
+ // Though recognising perf implications, it's (more) OK to include client-side functionality in jsgui3-html.
238
+
239
+
240
+
241
+
242
+
243
+
244
+ });
245
+
246
+ }
247
+ }
248
+ }
249
+
250
+ // Include this in bundling.
251
+ // Want CSS bundling so that styles are read out from the JS document and compiled to a stylesheet.
252
+
253
+ //controls.Demo_UI = Demo_UI;
254
+
255
+ // A css file may be an easier way to get started...?
256
+ // Want to support but not require css in js.
257
+
258
+ // But need to set up the serving of the CSS both on the server, and on the client.
259
+ // Ofc setting it up on the server first is important - then can that stage set it up in the doc sent to the client?
260
+
261
+ // Including the CSS from the JS like before.
262
+ // Needs to extract the CSS and serve it as a separate CSS file.
263
+ // Should also have end-to-end regression tests so this does not break again in the future.
264
+ // The code was kind of clunky and got refactored away.
265
+ //
266
+
267
+ // Would need to parse the JS files to extract the CSS.
268
+ // Maybe could do it an easier way??? Now that it's easy, want a faster way.
269
+
270
+
271
+ Demo_UI.css = `
272
+
273
+ * {
274
+ margin: 0;
275
+ padding: 0;
276
+ }
277
+
278
+ body {
279
+ overflow-x: hidden;
280
+ overflow-y: hidden;
281
+ background-color: #E0E0E0;
282
+ }
283
+
284
+ .demo-ui {
285
+
286
+ /*
287
+
288
+ display: flex;
289
+ flex-wrap: wrap;
290
+
291
+ flex-direction: column;
292
+ justify-content: center;
293
+ align-items: center;
294
+ text-align: center;
295
+ min-height: 100vh;
296
+ */
297
+
298
+ }
299
+ `;
300
+
301
+ // But may want to remove them from that flex upon picking up / dropping them.
302
+ // Maybe best upon drop.
303
+
304
+ // Maybe want other examples that use absolute positioning to position the items at the start?
305
+ //
306
+
307
+
308
+
309
+ //controls.Square_Box = Square_Box;
310
+ // could export jsgui with the updated controls....
311
+ // so that they are in the correct Page Context.?
312
+
313
+
314
+ controls.Demo_UI = Demo_UI;
315
+
316
+ module.exports = jsgui;
317
+
318
+ /*
319
+ module.exports = {
320
+ Square_Box: Square_Box,
321
+ Demo_UI: Demo_UI
322
+ }
323
+ */
324
+
325
+ // Then if window...?
326
+
327
+ // Need to add the Square_Box control to the context or original map of controls...
328
+
@@ -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
+ }