jsgui3-server 0.0.101 → 0.0.103
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/examples/controls/1) window/client.js +3 -2
- package/examples/controls/1) window/server.js +6 -2
- package/examples/controls/2) two windows/client.js +193 -0
- package/examples/controls/2) two windows/server.js +114 -0
- package/examples/controls/3) five windows/client.js +217 -0
- package/examples/controls/3) five windows/server.js +114 -0
- package/package.json +3 -3
- package/resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild.js +3 -0
- package/resources/processors/bundlers/js/esbuild/Core_JS_Single_File_Minifying_Bundler_Using_ESBuild.js +1 -0
|
@@ -61,7 +61,8 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
61
61
|
|
|
62
62
|
const window = new controls.Window({
|
|
63
63
|
context: context,
|
|
64
|
-
title: 'jsgui3-html Window Control'
|
|
64
|
+
title: 'jsgui3-html Window Control',
|
|
65
|
+
pos: [10, 10]
|
|
65
66
|
})
|
|
66
67
|
this.body.add(window);
|
|
67
68
|
|
|
@@ -122,7 +123,7 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
122
123
|
//
|
|
123
124
|
|
|
124
125
|
// Would need to parse the JS files to extract the CSS.
|
|
125
|
-
// Maybe could do it an easier way???
|
|
126
|
+
// Maybe could do it an easier way??? Now that it's easy, want a faster way.
|
|
126
127
|
|
|
127
128
|
|
|
128
129
|
Demo_UI.css = `
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const jsgui = require('./client');
|
|
2
2
|
|
|
3
|
-
const {Demo_UI
|
|
3
|
+
const {Demo_UI} = jsgui.controls;
|
|
4
4
|
const Server = require('../../../server');
|
|
5
5
|
|
|
6
6
|
|
|
@@ -19,6 +19,10 @@ const Server = require('../../../server');
|
|
|
19
19
|
// May as well fix that....
|
|
20
20
|
|
|
21
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
|
+
|
|
22
26
|
|
|
23
27
|
|
|
24
28
|
|
|
@@ -84,7 +88,7 @@ if (require.main === module) {
|
|
|
84
88
|
|
|
85
89
|
//'js_mode': 'debug',
|
|
86
90
|
'src_path_client_js': require.resolve('./client.js'),
|
|
87
|
-
debug: true // should not minify the js, should include the symbols.
|
|
91
|
+
//debug: true // should not minify the js, should include the symbols.
|
|
88
92
|
//js_client: require.resolve('./square_box.js')
|
|
89
93
|
});
|
|
90
94
|
// A callback or event for when the bundling has been completed
|
|
@@ -0,0 +1,193 @@
|
|
|
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
|
+
// This will require some automatic 'bring to front' z-index assignments.
|
|
23
|
+
// Maybe do this with a mixin later on....
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Demo_UI extends Active_HTML_Document {
|
|
28
|
+
constructor(spec = {}) {
|
|
29
|
+
spec.__type_name = spec.__type_name || 'demo_ui';
|
|
30
|
+
super(spec);
|
|
31
|
+
const {context} = this;
|
|
32
|
+
|
|
33
|
+
// Make sure it requires the correct CSS.
|
|
34
|
+
// Though making that 'effortless' on the server may help more.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// Maybe can't do this here???
|
|
38
|
+
|
|
39
|
+
// Does not have .body (yet) on the client.
|
|
40
|
+
// simple way to get the client to attach the body of the Active_HTML_Document?
|
|
41
|
+
// maybe with jsgui-data-controls?
|
|
42
|
+
// Though automatically having the .body property available on the client without sending extra HTTP
|
|
43
|
+
// plumbing will help.
|
|
44
|
+
|
|
45
|
+
// .body will not be available before activation.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
// .body should not be a normal function....?
|
|
49
|
+
// a getter function would be better.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
if (typeof this.body.add_class === 'function') {
|
|
54
|
+
this.body.add_class('demo-ui');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//console.log('this.body', this.body);
|
|
58
|
+
//console.log('this.body.add_class', this.body.add_class);
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
const compose = () => {
|
|
62
|
+
// put 20 of them in place.
|
|
63
|
+
|
|
64
|
+
// Then how to arrange them...?
|
|
65
|
+
|
|
66
|
+
const window_1 = new controls.Window({
|
|
67
|
+
context: context,
|
|
68
|
+
title: '1) jsgui3-html Window Control'
|
|
69
|
+
})
|
|
70
|
+
this.body.add(window_1);
|
|
71
|
+
|
|
72
|
+
const window_2 = new controls.Window({
|
|
73
|
+
context: context,
|
|
74
|
+
title: '2) jsgui3-html Window Control'
|
|
75
|
+
})
|
|
76
|
+
this.body.add(window_2);
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
if (!spec.el) {
|
|
81
|
+
compose();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
activate() {
|
|
85
|
+
if (!this.__active) {
|
|
86
|
+
super.activate();
|
|
87
|
+
const {context} = this;
|
|
88
|
+
|
|
89
|
+
//console.log('activate Demo_UI');
|
|
90
|
+
// listen for the context events regarding frames, changes, resizing.
|
|
91
|
+
|
|
92
|
+
context.on('window-resize', e_resize => {
|
|
93
|
+
//console.log('window-resize', e_resize);
|
|
94
|
+
|
|
95
|
+
// Make all internal controls go absolute in terms of position
|
|
96
|
+
// Remove them from their containers too?
|
|
97
|
+
// Ie their containing divs?
|
|
98
|
+
|
|
99
|
+
// Would be nice to do this really simple with a fn call or very simple piece of code.
|
|
100
|
+
// Like get absolute position, set position to be absolute, move to that position.
|
|
101
|
+
// Maybe something within jsgui3-client helps with this, this is more about what needs to be done on the client.
|
|
102
|
+
// Though recognising perf implications, it's (more) OK to include client-side functionality in jsgui3-html.
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Include this in bundling.
|
|
116
|
+
// Want CSS bundling so that styles are read out from the JS document and compiled to a stylesheet.
|
|
117
|
+
|
|
118
|
+
//controls.Demo_UI = Demo_UI;
|
|
119
|
+
|
|
120
|
+
// A css file may be an easier way to get started...?
|
|
121
|
+
// Want to support but not require css in js.
|
|
122
|
+
|
|
123
|
+
// But need to set up the serving of the CSS both on the server, and on the client.
|
|
124
|
+
// Ofc setting it up on the server first is important - then can that stage set it up in the doc sent to the client?
|
|
125
|
+
|
|
126
|
+
// Including the CSS from the JS like before.
|
|
127
|
+
// Needs to extract the CSS and serve it as a separate CSS file.
|
|
128
|
+
// Should also have end-to-end regression tests so this does not break again in the future.
|
|
129
|
+
// The code was kind of clunky and got refactored away.
|
|
130
|
+
//
|
|
131
|
+
|
|
132
|
+
// Would need to parse the JS files to extract the CSS.
|
|
133
|
+
// Maybe could do it an easier way???
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
Demo_UI.css = `
|
|
137
|
+
|
|
138
|
+
* {
|
|
139
|
+
margin: 0;
|
|
140
|
+
padding: 0;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
body {
|
|
144
|
+
overflow-x: hidden;
|
|
145
|
+
overflow-y: hidden;
|
|
146
|
+
background-color: #E0E0E0;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.demo-ui {
|
|
150
|
+
|
|
151
|
+
/*
|
|
152
|
+
|
|
153
|
+
display: flex;
|
|
154
|
+
flex-wrap: wrap;
|
|
155
|
+
|
|
156
|
+
flex-direction: column;
|
|
157
|
+
justify-content: center;
|
|
158
|
+
align-items: center;
|
|
159
|
+
text-align: center;
|
|
160
|
+
min-height: 100vh;
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
`;
|
|
165
|
+
|
|
166
|
+
// But may want to remove them from that flex upon picking up / dropping them.
|
|
167
|
+
// Maybe best upon drop.
|
|
168
|
+
|
|
169
|
+
// Maybe want other examples that use absolute positioning to position the items at the start?
|
|
170
|
+
//
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
//controls.Square_Box = Square_Box;
|
|
175
|
+
// could export jsgui with the updated controls....
|
|
176
|
+
// so that they are in the correct Page Context.?
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
controls.Demo_UI = Demo_UI;
|
|
180
|
+
|
|
181
|
+
module.exports = jsgui;
|
|
182
|
+
|
|
183
|
+
/*
|
|
184
|
+
module.exports = {
|
|
185
|
+
Square_Box: Square_Box,
|
|
186
|
+
Demo_UI: Demo_UI
|
|
187
|
+
}
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
// Then if window...?
|
|
191
|
+
|
|
192
|
+
// Need to add the Square_Box control to the context or original map of controls...
|
|
193
|
+
|
|
@@ -0,0 +1,114 @@
|
|
|
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
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
if (require.main === module) {
|
|
26
|
+
|
|
27
|
+
// By default should include the JS and the CSS.
|
|
28
|
+
// By reference, serving them from their respective paths.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// This API is not working right now.
|
|
32
|
+
|
|
33
|
+
// A very simple syntax for running a single control would be great.
|
|
34
|
+
|
|
35
|
+
// Need to in the default (server) configuration build and serve the client-side app.
|
|
36
|
+
// Want to be able to make interactive apps quickly with minimal server side code that needs to be written as boilerplate to
|
|
37
|
+
// get the app running.
|
|
38
|
+
|
|
39
|
+
// Though maybe defining a webpage, that serves the client js, and renders the control on the server, and activates it on the client,
|
|
40
|
+
// would be the right approach.
|
|
41
|
+
|
|
42
|
+
// Want to make the code really explicit, in a simple way.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
// eg { '/': Demo_UI }
|
|
46
|
+
// eg { '*': Demo_UI }
|
|
47
|
+
// as at least it explicitly assigns it to the '/' route
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
// But worth keeping the '/' Ctrl property?
|
|
51
|
+
// Could change it to explicitly setting the route(s).
|
|
52
|
+
|
|
53
|
+
// Do want it to build the client js on start.
|
|
54
|
+
|
|
55
|
+
// Could extract the CSS from the file itself, or maybe better reading it from the classes and objects that are loaded / referenced.
|
|
56
|
+
// All kinds of complex server program structures exist already, so could use Publishers if needed for some things.
|
|
57
|
+
// But need to keep the surface-level API really simple.
|
|
58
|
+
|
|
59
|
+
// Maybe define a Webpage and maybe use / define an HTML_Webpage_Publisher for example too.
|
|
60
|
+
// The clearest code would be really explicit about what it does, but in terms of almost English idioms
|
|
61
|
+
// and on the surface-level not spelling out in great detail what it's doing, but referencing objects and
|
|
62
|
+
// instructions with clear purposes, though details could be obscure at the top level. Eg it's the publisher's responsibility
|
|
63
|
+
// 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.
|
|
64
|
+
|
|
65
|
+
// The Server could automatically involk the use of a Publisher.
|
|
66
|
+
// May be better to either require or recommend more explicit code, have them in the examples,
|
|
67
|
+
// but also to document some shortcuts, defaults, and abbreviations (though they may omit some essential info, so not recommended for beginners)
|
|
68
|
+
|
|
69
|
+
// Could have a tabbed view for examples for 'explicit' and 'short' notations when there are multiple.
|
|
70
|
+
|
|
71
|
+
// jsgui3-html-suite may be of use, for some more extended controls that are built on top of jsgui3-html, but not specifically
|
|
72
|
+
// client or server.
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
const server = new Server({
|
|
80
|
+
Ctrl: Demo_UI,
|
|
81
|
+
// Giving it the Ctrl and disk path client js should enable to server to get the JS-bundled CSS from the file(s).
|
|
82
|
+
// Putting the JS files through proper parsing and into a syntax tree would be best.
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
//'js_mode': 'debug',
|
|
86
|
+
'src_path_client_js': require.resolve('./client.js'),
|
|
87
|
+
//debug: true // should not minify the js, should include the symbols.
|
|
88
|
+
//js_client: require.resolve('./square_box.js')
|
|
89
|
+
});
|
|
90
|
+
// A callback or event for when the bundling has been completed
|
|
91
|
+
// a 'ready' event.
|
|
92
|
+
|
|
93
|
+
// then start the server....
|
|
94
|
+
// be able to choose the port / ports?
|
|
95
|
+
console.log('waiting for server ready event');
|
|
96
|
+
server.on('ready', () => {
|
|
97
|
+
console.log('server ready');
|
|
98
|
+
|
|
99
|
+
// server start will change to observable?
|
|
100
|
+
|
|
101
|
+
server.start(8080, function (err, cb_start) {
|
|
102
|
+
if (err) {
|
|
103
|
+
throw err;
|
|
104
|
+
} else {
|
|
105
|
+
// Should have build it by now...
|
|
106
|
+
|
|
107
|
+
console.log('server started');
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
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
|
+
// This will require some automatic 'bring to front' z-index assignments.
|
|
23
|
+
// Maybe do this with a mixin later on....
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Demo_UI extends Active_HTML_Document {
|
|
28
|
+
constructor(spec = {}) {
|
|
29
|
+
spec.__type_name = spec.__type_name || 'demo_ui';
|
|
30
|
+
super(spec);
|
|
31
|
+
const {context} = this;
|
|
32
|
+
|
|
33
|
+
// Make sure it requires the correct CSS.
|
|
34
|
+
// Though making that 'effortless' on the server may help more.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// Maybe can't do this here???
|
|
38
|
+
|
|
39
|
+
// Does not have .body (yet) on the client.
|
|
40
|
+
// simple way to get the client to attach the body of the Active_HTML_Document?
|
|
41
|
+
// maybe with jsgui-data-controls?
|
|
42
|
+
// Though automatically having the .body property available on the client without sending extra HTTP
|
|
43
|
+
// plumbing will help.
|
|
44
|
+
|
|
45
|
+
// .body will not be available before activation.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
// .body should not be a normal function....?
|
|
49
|
+
// a getter function would be better.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
if (typeof this.body.add_class === 'function') {
|
|
54
|
+
this.body.add_class('demo-ui');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//console.log('this.body', this.body);
|
|
58
|
+
//console.log('this.body.add_class', this.body.add_class);
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
const compose = () => {
|
|
62
|
+
// put 20 of them in place.
|
|
63
|
+
|
|
64
|
+
// Then how to arrange them...?
|
|
65
|
+
|
|
66
|
+
const num_windows = 5;
|
|
67
|
+
|
|
68
|
+
let [x, y] = [0, 0];
|
|
69
|
+
|
|
70
|
+
// pos property?
|
|
71
|
+
//. consider a pos_info or pos_details property, or use another class to help with it.
|
|
72
|
+
|
|
73
|
+
// the .pos property would be a nice shortcut.
|
|
74
|
+
//. seems more like it's for enhanced controls? Not sure.
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
for (let c = 1; c <= num_windows; c++) {
|
|
78
|
+
const window = new controls.Window({
|
|
79
|
+
context: context,
|
|
80
|
+
title: c + ') jsgui3-html Window Control',
|
|
81
|
+
pos: [x, y]
|
|
82
|
+
})
|
|
83
|
+
this.body.add(window);
|
|
84
|
+
|
|
85
|
+
x += 32; y += 64;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/*
|
|
89
|
+
const window_1 = new controls.Window({
|
|
90
|
+
context: context,
|
|
91
|
+
title: '1) jsgui3-html Window Control'
|
|
92
|
+
})
|
|
93
|
+
this.body.add(window_1);
|
|
94
|
+
|
|
95
|
+
const window_2 = new controls.Window({
|
|
96
|
+
context: context,
|
|
97
|
+
title: '2) jsgui3-html Window Control'
|
|
98
|
+
})
|
|
99
|
+
this.body.add(window_2);
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
if (!spec.el) {
|
|
105
|
+
compose();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
activate() {
|
|
109
|
+
if (!this.__active) {
|
|
110
|
+
super.activate();
|
|
111
|
+
const {context} = this;
|
|
112
|
+
|
|
113
|
+
//console.log('activate Demo_UI');
|
|
114
|
+
// listen for the context events regarding frames, changes, resizing.
|
|
115
|
+
|
|
116
|
+
context.on('window-resize', e_resize => {
|
|
117
|
+
//console.log('window-resize', e_resize);
|
|
118
|
+
|
|
119
|
+
// Make all internal controls go absolute in terms of position
|
|
120
|
+
// Remove them from their containers too?
|
|
121
|
+
// Ie their containing divs?
|
|
122
|
+
|
|
123
|
+
// Would be nice to do this really simple with a fn call or very simple piece of code.
|
|
124
|
+
// Like get absolute position, set position to be absolute, move to that position.
|
|
125
|
+
// Maybe something within jsgui3-client helps with this, this is more about what needs to be done on the client.
|
|
126
|
+
// Though recognising perf implications, it's (more) OK to include client-side functionality in jsgui3-html.
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Include this in bundling.
|
|
140
|
+
// Want CSS bundling so that styles are read out from the JS document and compiled to a stylesheet.
|
|
141
|
+
|
|
142
|
+
//controls.Demo_UI = Demo_UI;
|
|
143
|
+
|
|
144
|
+
// A css file may be an easier way to get started...?
|
|
145
|
+
// Want to support but not require css in js.
|
|
146
|
+
|
|
147
|
+
// But need to set up the serving of the CSS both on the server, and on the client.
|
|
148
|
+
// Ofc setting it up on the server first is important - then can that stage set it up in the doc sent to the client?
|
|
149
|
+
|
|
150
|
+
// Including the CSS from the JS like before.
|
|
151
|
+
// Needs to extract the CSS and serve it as a separate CSS file.
|
|
152
|
+
// Should also have end-to-end regression tests so this does not break again in the future.
|
|
153
|
+
// The code was kind of clunky and got refactored away.
|
|
154
|
+
//
|
|
155
|
+
|
|
156
|
+
// Would need to parse the JS files to extract the CSS.
|
|
157
|
+
// Maybe could do it an easier way???
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
Demo_UI.css = `
|
|
161
|
+
|
|
162
|
+
* {
|
|
163
|
+
margin: 0;
|
|
164
|
+
padding: 0;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
body {
|
|
168
|
+
overflow-x: hidden;
|
|
169
|
+
overflow-y: hidden;
|
|
170
|
+
background-color: #E0E0E0;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.demo-ui {
|
|
174
|
+
|
|
175
|
+
/*
|
|
176
|
+
|
|
177
|
+
display: flex;
|
|
178
|
+
flex-wrap: wrap;
|
|
179
|
+
|
|
180
|
+
flex-direction: column;
|
|
181
|
+
justify-content: center;
|
|
182
|
+
align-items: center;
|
|
183
|
+
text-align: center;
|
|
184
|
+
min-height: 100vh;
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
}
|
|
188
|
+
`;
|
|
189
|
+
|
|
190
|
+
// But may want to remove them from that flex upon picking up / dropping them.
|
|
191
|
+
// Maybe best upon drop.
|
|
192
|
+
|
|
193
|
+
// Maybe want other examples that use absolute positioning to position the items at the start?
|
|
194
|
+
//
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
//controls.Square_Box = Square_Box;
|
|
199
|
+
// could export jsgui with the updated controls....
|
|
200
|
+
// so that they are in the correct Page Context.?
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
controls.Demo_UI = Demo_UI;
|
|
204
|
+
|
|
205
|
+
module.exports = jsgui;
|
|
206
|
+
|
|
207
|
+
/*
|
|
208
|
+
module.exports = {
|
|
209
|
+
Square_Box: Square_Box,
|
|
210
|
+
Demo_UI: Demo_UI
|
|
211
|
+
}
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
// Then if window...?
|
|
215
|
+
|
|
216
|
+
// Need to add the Square_Box control to the context or original map of controls...
|
|
217
|
+
|
|
@@ -0,0 +1,114 @@
|
|
|
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
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
if (require.main === module) {
|
|
26
|
+
|
|
27
|
+
// By default should include the JS and the CSS.
|
|
28
|
+
// By reference, serving them from their respective paths.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// This API is not working right now.
|
|
32
|
+
|
|
33
|
+
// A very simple syntax for running a single control would be great.
|
|
34
|
+
|
|
35
|
+
// Need to in the default (server) configuration build and serve the client-side app.
|
|
36
|
+
// Want to be able to make interactive apps quickly with minimal server side code that needs to be written as boilerplate to
|
|
37
|
+
// get the app running.
|
|
38
|
+
|
|
39
|
+
// Though maybe defining a webpage, that serves the client js, and renders the control on the server, and activates it on the client,
|
|
40
|
+
// would be the right approach.
|
|
41
|
+
|
|
42
|
+
// Want to make the code really explicit, in a simple way.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
// eg { '/': Demo_UI }
|
|
46
|
+
// eg { '*': Demo_UI }
|
|
47
|
+
// as at least it explicitly assigns it to the '/' route
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
// But worth keeping the '/' Ctrl property?
|
|
51
|
+
// Could change it to explicitly setting the route(s).
|
|
52
|
+
|
|
53
|
+
// Do want it to build the client js on start.
|
|
54
|
+
|
|
55
|
+
// Could extract the CSS from the file itself, or maybe better reading it from the classes and objects that are loaded / referenced.
|
|
56
|
+
// All kinds of complex server program structures exist already, so could use Publishers if needed for some things.
|
|
57
|
+
// But need to keep the surface-level API really simple.
|
|
58
|
+
|
|
59
|
+
// Maybe define a Webpage and maybe use / define an HTML_Webpage_Publisher for example too.
|
|
60
|
+
// The clearest code would be really explicit about what it does, but in terms of almost English idioms
|
|
61
|
+
// and on the surface-level not spelling out in great detail what it's doing, but referencing objects and
|
|
62
|
+
// instructions with clear purposes, though details could be obscure at the top level. Eg it's the publisher's responsibility
|
|
63
|
+
// 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.
|
|
64
|
+
|
|
65
|
+
// The Server could automatically involk the use of a Publisher.
|
|
66
|
+
// May be better to either require or recommend more explicit code, have them in the examples,
|
|
67
|
+
// but also to document some shortcuts, defaults, and abbreviations (though they may omit some essential info, so not recommended for beginners)
|
|
68
|
+
|
|
69
|
+
// Could have a tabbed view for examples for 'explicit' and 'short' notations when there are multiple.
|
|
70
|
+
|
|
71
|
+
// jsgui3-html-suite may be of use, for some more extended controls that are built on top of jsgui3-html, but not specifically
|
|
72
|
+
// client or server.
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
const server = new Server({
|
|
80
|
+
Ctrl: Demo_UI,
|
|
81
|
+
// Giving it the Ctrl and disk path client js should enable to server to get the JS-bundled CSS from the file(s).
|
|
82
|
+
// Putting the JS files through proper parsing and into a syntax tree would be best.
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
//'js_mode': 'debug',
|
|
86
|
+
'src_path_client_js': require.resolve('./client.js'),
|
|
87
|
+
//debug: true // should not minify the js, should include the symbols.
|
|
88
|
+
//js_client: require.resolve('./square_box.js')
|
|
89
|
+
});
|
|
90
|
+
// A callback or event for when the bundling has been completed
|
|
91
|
+
// a 'ready' event.
|
|
92
|
+
|
|
93
|
+
// then start the server....
|
|
94
|
+
// be able to choose the port / ports?
|
|
95
|
+
console.log('waiting for server ready event');
|
|
96
|
+
server.on('ready', () => {
|
|
97
|
+
console.log('server ready');
|
|
98
|
+
|
|
99
|
+
// server start will change to observable?
|
|
100
|
+
|
|
101
|
+
server.start(8080, function (err, cb_start) {
|
|
102
|
+
if (err) {
|
|
103
|
+
throw err;
|
|
104
|
+
} else {
|
|
105
|
+
// Should have build it by now...
|
|
106
|
+
|
|
107
|
+
console.log('server started');
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
}
|
package/package.json
CHANGED
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"esbuild": "^0.19.4",
|
|
15
15
|
"fnl": "^0.0.29",
|
|
16
16
|
"fnlfs": "^0.0.29",
|
|
17
|
-
"jsgui3-client": "^0.0.
|
|
17
|
+
"jsgui3-client": "^0.0.88",
|
|
18
18
|
"jsgui3-webpage": "^0.0.6",
|
|
19
19
|
"jsgui3-website": "^0.0.6",
|
|
20
|
-
"lang-tools": "^0.0.
|
|
20
|
+
"lang-tools": "^0.0.18",
|
|
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.
|
|
48
|
+
"version": "0.0.103"
|
|
49
49
|
}
|