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.
- package/README.md +8 -1
- package/bundler/bundle.js +11 -0
- package/bundler/bundler.js +9 -0
- package/bundler/css-bundler.js +56 -0
- package/bundler/js-bundler.js +214 -0
- package/bundler/test_ast.js +74 -0
- package/bundler/webpage-bundler.js +286 -0
- package/bundler/website-bundler.js +23 -0
- package/controls/README.md +8 -0
- package/controls/page/admin.js +75 -0
- package/controls/panel/admin.js +11 -0
- package/examples/controls/html-server-combo-box.js +5 -5
- package/examples/html-server.js +3 -0
- package/examples/square_box.js +41 -0
- package/examples/square_box_client.js +91 -0
- package/module.js +6 -0
- package/{single-control-server.js → old/_single-control-server.js} +157 -96
- package/old/single-control-server.js +108 -158
- package/{single-page-app.js → old/single-page-app.js} +2 -0
- package/{examples/demos → old}/square_box.js +1 -1
- package/package.json +9 -9
- package/page-context.js +1 -1
- package/publishing/http-css-publisher.js +0 -0
- package/publishing/{function-publisher.js → http-function-publisher.js} +11 -1
- package/publishing/http-html-page-publisher.js +5 -0
- package/publishing/http-html-publisher.js +25 -0
- package/publishing/http-jpeg-publisher.js +0 -0
- package/publishing/http-js-publisher.js +25 -0
- package/publishing/{observable-publisher.js → http-observable-publisher.js} +12 -6
- package/publishing/http-png-publisher.js +0 -0
- package/publishing/http-publisher.js +52 -0
- package/publishing/{resource-publisher.js → http-resource-publisher.js} +20 -1
- package/publishing/http-svg-publisher.js +0 -0
- package/publishing/http-webpage-publisher.js +112 -0
- package/publishing/http-website-publisher.js +271 -0
- package/publishing/notes.md +1 -0
- package/resources/README.md +16 -0
- package/resources/_old_website-resource.js +507 -0
- package/resources/compile/server-resource-compilation.js +41 -0
- package/resources/data-resource.js +8 -0
- package/resources/fs-resource.js +2 -4
- package/resources/jsbuilder/babel/deep_iterate/deep_iterate_babel.js +3 -0
- package/resources/jsbuilder/test/test_ast_node.js +1 -1
- package/resources/jsbuilder/test/test_js_file.js +2 -2
- package/resources/notes.txt +11 -0
- package/resources/server-installed-tools.js +29 -0
- package/resources/server-resource-pool.js +1 -55
- package/resources/website-css-resource.js +1 -1
- package/resources/website-javascript-resource.js +165 -34
- package/resources/website-resource.js +52 -296
- package/resources/website-static-html-resource.js +0 -1
- package/resources/website-template-html-resource.js +231 -0
- package/roadmap.md +68 -0
- package/server.js +722 -17
- package/website/webpage.js +169 -0
- package/website/website-group.js +16 -0
- package/website/website.js +253 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const jsgui = require('jsgui3-html');
|
|
2
|
+
|
|
3
|
+
const Standard_Web_Page = jsgui.controls.Standard_Web_Page;
|
|
4
|
+
|
|
5
|
+
const Panel = jsgui.controls.Panel;
|
|
6
|
+
|
|
7
|
+
class Admin_Web_Page extends Standard_Web_Page {
|
|
8
|
+
constructor(spec) {
|
|
9
|
+
super(spec);
|
|
10
|
+
|
|
11
|
+
// a .text property of h1 etc would help.
|
|
12
|
+
|
|
13
|
+
const h1 = new jsgui.h1({
|
|
14
|
+
context: this.context//,
|
|
15
|
+
//text: 'jsgui3 Server Admin'
|
|
16
|
+
})
|
|
17
|
+
h1.add('jsgui3 Server Admin');
|
|
18
|
+
this.body.add(h1);
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
const main_panel = new Panel({
|
|
22
|
+
context: this.context,
|
|
23
|
+
class: 'main panel'
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
this.body.add(main_panel);
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// Add a panel where the work takes place.
|
|
30
|
+
// Perhaps do more work on Panel as some kind of example?
|
|
31
|
+
|
|
32
|
+
// Want panels inside a panel, with them movable and resizable.
|
|
33
|
+
// A kind of snapping too, fitting some standard sizes.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
// Have some kinds of admin controls.
|
|
42
|
+
// Admin basic info panel.
|
|
43
|
+
// Expandable windows would be nice
|
|
44
|
+
// status <> detiled info and control
|
|
45
|
+
// Resources
|
|
46
|
+
|
|
47
|
+
// Admin_Resources_Panel
|
|
48
|
+
|
|
49
|
+
// Admin_Panel
|
|
50
|
+
|
|
51
|
+
// Admin_Web_Panel ???
|
|
52
|
+
|
|
53
|
+
// Want a flexible kind of web panel,
|
|
54
|
+
// Does not have to be server specific.
|
|
55
|
+
// Just have the things really only for the server here.
|
|
56
|
+
|
|
57
|
+
// Add Flexi_Panel
|
|
58
|
+
// or Multi_Grid_Panel
|
|
59
|
+
// Whatever advanced panel system it is (for now).
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
// Divide the screen / window into grid of 10 * 6 squares?
|
|
66
|
+
// Then could snap various components to those sizes.
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = Admin_Web_Page;
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
// Some of the wiring could be done automatically.
|
|
12
12
|
//
|
|
13
13
|
|
|
14
|
-
var
|
|
15
|
-
var Combo_Box =
|
|
14
|
+
var Server = require('../../server');
|
|
15
|
+
var Combo_Box = Server.HTML.Combo_Box;
|
|
16
16
|
|
|
17
|
-
var Server = jsgui.Server;
|
|
17
|
+
//var Server = jsgui.Server;
|
|
18
18
|
var port = 80;
|
|
19
|
-
var Server_Page_Context = Server.
|
|
19
|
+
var Server_Page_Context = Server.Server_Page_Context;
|
|
20
20
|
|
|
21
21
|
var server = new Server({
|
|
22
22
|
routes: {
|
|
@@ -65,7 +65,7 @@ routing_tree.set('/', function(req, res) {
|
|
|
65
65
|
'resource_pool': resource_pool
|
|
66
66
|
});
|
|
67
67
|
// Page_Bounds_Specifier
|
|
68
|
-
var hd = new
|
|
68
|
+
var hd = new Server.HTML.Client_HTML_Document({
|
|
69
69
|
'context': server_page_context
|
|
70
70
|
});
|
|
71
71
|
hd.include_client_css();
|
package/examples/html-server.js
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
const {Demo_UI, Square_Box} = require('./square_box_client');
|
|
3
|
+
const Server = require('../server');
|
|
4
|
+
|
|
5
|
+
// Want to exclude this from the client bundle.
|
|
6
|
+
// Some kind of marking to say that it's server-side only?
|
|
7
|
+
|
|
8
|
+
if (require.main === module) {
|
|
9
|
+
|
|
10
|
+
const server = new Server({
|
|
11
|
+
Ctrl: Demo_UI,
|
|
12
|
+
// Giving it the Ctrl and disk path client js should enable to server to get the JS-bundled CSS from the file(s).
|
|
13
|
+
// Putting the JS files through proper parsing and into a syntax tree would be best.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
//'js_mode': 'debug',
|
|
17
|
+
'disk_path_client_js': require.resolve('./square_box_client.js')
|
|
18
|
+
//js_client: require.resolve('./square_box.js')
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// A callback or event for when the bundling has been completed
|
|
22
|
+
// a 'ready' event.
|
|
23
|
+
|
|
24
|
+
// then start the server....
|
|
25
|
+
// be able to choose the port / ports?
|
|
26
|
+
console.log('waiting for server ready event');
|
|
27
|
+
server.on('ready', () => {
|
|
28
|
+
server.start(8080, function (err, cb_start) {
|
|
29
|
+
if (err) {
|
|
30
|
+
throw err;
|
|
31
|
+
} else {
|
|
32
|
+
// Should have build it by now...
|
|
33
|
+
|
|
34
|
+
console.log('server started');
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const jsgui = require('jsgui3-html'); // and will replace this with jsgui-client, I presume.
|
|
2
|
+
const {controls, Control, mixins} = jsgui;
|
|
3
|
+
const {dragable} = mixins;
|
|
4
|
+
|
|
5
|
+
class Demo_UI extends Control {
|
|
6
|
+
constructor(spec) {
|
|
7
|
+
spec.__type_name = spec.__type_name || 'demo_ui';
|
|
8
|
+
super(spec);
|
|
9
|
+
const {context} = this;
|
|
10
|
+
this.add_class('demo-ui');
|
|
11
|
+
|
|
12
|
+
const compose = () => {
|
|
13
|
+
const box = new Square_Box({
|
|
14
|
+
context: context
|
|
15
|
+
})
|
|
16
|
+
this.add(box);
|
|
17
|
+
}
|
|
18
|
+
if (!spec.el) {
|
|
19
|
+
compose();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
activate() {
|
|
23
|
+
if (!this.__active) {
|
|
24
|
+
super.activate();
|
|
25
|
+
const {context} = this;
|
|
26
|
+
|
|
27
|
+
console.log('activate Demo_UI');
|
|
28
|
+
// listen for the context events regarding frames, changes, resizing.
|
|
29
|
+
|
|
30
|
+
context.on('window-resize', e_resize => {
|
|
31
|
+
console.log('window-resize', e_resize);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Include this in bundling.
|
|
39
|
+
// Want CSS bundling so that styles are read out from the JS document and compiled to a stylesheet.
|
|
40
|
+
|
|
41
|
+
//controls.Demo_UI = Demo_UI;
|
|
42
|
+
Demo_UI.css = `
|
|
43
|
+
.demo-ui {
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
align-items: center;
|
|
48
|
+
text-align: center;
|
|
49
|
+
min-height: 100vh;
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
|
|
53
|
+
class Square_Box extends Control {
|
|
54
|
+
constructor(spec) {
|
|
55
|
+
spec.__type_name = spec.__type_name || 'square_box';
|
|
56
|
+
super(spec);
|
|
57
|
+
this.add_class('square-box');
|
|
58
|
+
}
|
|
59
|
+
activate() {
|
|
60
|
+
if (!this.__active) {
|
|
61
|
+
super.activate();
|
|
62
|
+
console.log('Activate square box');
|
|
63
|
+
|
|
64
|
+
dragable(this, {
|
|
65
|
+
drag_mode: 'translate'
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
console.log('dragable mixin applied to square');
|
|
69
|
+
this.dragable = true;
|
|
70
|
+
console.log('this.dragable = true;');
|
|
71
|
+
|
|
72
|
+
this.on('dragend', e => {
|
|
73
|
+
console.log('square box dragend e', e);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
Square_Box.css = `
|
|
80
|
+
.square-box {
|
|
81
|
+
background-color: #BB3333;
|
|
82
|
+
width: 220px;
|
|
83
|
+
height: 220px;
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
//controls.Square_Box = Square_Box;
|
|
87
|
+
|
|
88
|
+
module.exports = {
|
|
89
|
+
Square_Box: Square_Box,
|
|
90
|
+
Demo_UI: Demo_UI
|
|
91
|
+
}
|
package/module.js
CHANGED
|
@@ -33,8 +33,43 @@ var Server_Page_Context = require('./page-context');
|
|
|
33
33
|
// debug
|
|
34
34
|
// (standard)
|
|
35
35
|
|
|
36
|
-
//
|
|
37
|
-
|
|
36
|
+
// Want to get the library compressed sizes down. Particulatly client. Can do much more with oext.
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/*
|
|
41
|
+
var server = new Server({
|
|
42
|
+
'*': {
|
|
43
|
+
'name': 'html-server'
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
*/
|
|
48
|
+
/*
|
|
49
|
+
var resource_pool = root_server.resource_pool;
|
|
50
|
+
// link these getters with the resource pool resource getters?
|
|
51
|
+
let app_server = resource_pool['HTML Server'];
|
|
52
|
+
//console.log('app_server', app_server);
|
|
53
|
+
//
|
|
54
|
+
|
|
55
|
+
//console.log('app_server.resource_names', app_server.resource_names);
|
|
56
|
+
//console.log('!!app_server.resource_pool', !!app_server.resource_pool);
|
|
57
|
+
let js = app_server.resource_pool['Site JavaScript'];
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
//console.log('Server', Server);
|
|
61
|
+
|
|
62
|
+
// And choose the CSS file / files to send it.
|
|
63
|
+
// Could send basic jsgui css by default
|
|
64
|
+
// Then there would be app css on top of that.
|
|
65
|
+
|
|
66
|
+
// Authenticated_Server?
|
|
67
|
+
// Has got authentication mechanisms as a wrapper for the controls inside.
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
// Want to be able to set up icons as well.
|
|
71
|
+
|
|
72
|
+
|
|
38
73
|
|
|
39
74
|
class Single_Control_Server extends Server {
|
|
40
75
|
constructor(spec) {
|
|
@@ -60,16 +95,12 @@ class Single_Control_Server extends Server {
|
|
|
60
95
|
throw 'Single_Control_Server needs a Ctrl property'
|
|
61
96
|
}
|
|
62
97
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
98
|
if (spec.js_mode) this.js_mode = spec.js_mode;
|
|
66
99
|
if (spec.js_client) this.js_client = spec.js_client;
|
|
67
|
-
|
|
100
|
+
// deliver app specific css
|
|
101
|
+
// an obj
|
|
68
102
|
if (spec.css) this.css = spec.css;
|
|
69
|
-
|
|
70
|
-
// Not handling icons in the spec(yet). Now using load_icon_set.
|
|
71
|
-
//if (spec.icons) this.icons = spec.icons;
|
|
72
|
-
|
|
103
|
+
if (spec.icons) this.icons = spec.icons;
|
|
73
104
|
if (spec.include_server_ref_in_page_context) {
|
|
74
105
|
this.include_server_ref_in_page_context = spec.include_server_ref_in_page_context;
|
|
75
106
|
}
|
|
@@ -87,11 +118,13 @@ class Single_Control_Server extends Server {
|
|
|
87
118
|
var app = new Website_Resource({
|
|
88
119
|
'name': 'html-server'
|
|
89
120
|
});
|
|
121
|
+
|
|
90
122
|
// will need to keep access to the server?
|
|
91
123
|
// server_page_context keeping access to the server?
|
|
92
124
|
|
|
93
125
|
// some place to keep variables on the server.
|
|
94
126
|
// Especially when we are not coding any / much server-side logic.
|
|
127
|
+
|
|
95
128
|
// server.shared
|
|
96
129
|
// want an object that is shared between all server instances.
|
|
97
130
|
|
|
@@ -99,6 +132,7 @@ class Single_Control_Server extends Server {
|
|
|
99
132
|
|
|
100
133
|
// Maybe make something like Resource_Pool but simpler?
|
|
101
134
|
// Less prescriptive, but allowing a more complex api...?
|
|
135
|
+
|
|
102
136
|
// page_context.shared
|
|
103
137
|
// shared with the server
|
|
104
138
|
// shared with all page contexts.
|
|
@@ -112,16 +146,11 @@ class Single_Control_Server extends Server {
|
|
|
112
146
|
}
|
|
113
147
|
|
|
114
148
|
// Could start it up with a client_js reference
|
|
115
|
-
// be able to chose the port(s) as well?
|
|
116
|
-
|
|
117
|
-
// HTTPS and other protocols?
|
|
118
149
|
|
|
119
150
|
'start' (callback) {
|
|
120
|
-
|
|
121
|
-
const {context_data} = this;
|
|
122
|
-
|
|
123
151
|
//throw 'stop';
|
|
124
152
|
//var resource_pool = this.resource_pool;
|
|
153
|
+
|
|
125
154
|
var resource_pool = this.app_server.resource_pool;
|
|
126
155
|
var server_router = this.resource_pool.get_resource('Server Router');
|
|
127
156
|
// Build the client js and include that.
|
|
@@ -133,48 +162,80 @@ class Single_Control_Server extends Server {
|
|
|
133
162
|
let js = this.app_server.resource_pool['Site JavaScript'];
|
|
134
163
|
let css = this.app_server.resource_pool['Site CSS'];
|
|
135
164
|
let imgs = this.app_server.resource_pool['Site Images'];
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
// will look into the resource publisher to see what is published.
|
|
169
|
+
|
|
170
|
+
// serve package with replacement options.
|
|
171
|
+
// // the activate app function.
|
|
172
|
+
// Can be put into place in the served JS.
|
|
173
|
+
|
|
174
|
+
// with replacement option within serve_package
|
|
175
|
+
|
|
136
176
|
let o_serve_package = {
|
|
137
177
|
//'babel': 'mini'
|
|
138
178
|
}
|
|
139
179
|
|
|
140
|
-
//
|
|
180
|
+
// babel option.
|
|
181
|
+
// Activation should be defined
|
|
182
|
+
// Or there is some default activation in the client.js
|
|
183
|
+
// It has the maps of controls and Controls
|
|
184
|
+
// Then can activate these controls.
|
|
185
|
+
// There should maybe be some more data services in the client.
|
|
186
|
+
// Could make the client more miniature and modular once it works, and then incorporate react.
|
|
187
|
+
// Data-Resource would be general enough to work on both.
|
|
188
|
+
// The client data resources could then direct their requests to the server ones.
|
|
189
|
+
// Could make a resource-pool for both client and server
|
|
190
|
+
|
|
191
|
+
//console.log('this.activate_app', this.activate_app);
|
|
192
|
+
//throw 'stop';
|
|
193
|
+
|
|
194
|
+
// Should do this before the babel compilation. Think that's the sequence anyway.
|
|
195
|
+
// Not sure why it's not working.
|
|
141
196
|
if (this.activate_app) {
|
|
142
197
|
o_serve_package.replace = {
|
|
143
198
|
'/* -- ACTIVATE-APP -- */': this.activate_app.toString()
|
|
144
199
|
}
|
|
145
200
|
//
|
|
146
201
|
}
|
|
202
|
+
// want it to serve with debug code map
|
|
203
|
+
// for the moment
|
|
204
|
+
// want that to be easier to do with a --debug option.
|
|
205
|
+
// should read command line options.
|
|
147
206
|
o_serve_package.js_mode = 'mini';
|
|
148
207
|
if (this.js_mode) {
|
|
149
208
|
o_serve_package.js_mode = this.js_mode;
|
|
150
209
|
} else {
|
|
151
210
|
//o_serve_package.babel = 'mini';
|
|
152
211
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
})
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
// css.serve_package_css
|
|
161
|
-
// will get the css from that package?
|
|
162
|
-
// or extract the css from the classes in the package directly?
|
|
212
|
+
// need to minify the js.
|
|
213
|
+
// Also, gzip compression as standard.
|
|
214
|
+
// Need HTTPS for Brotli - but want to get HTTPS working more, tested online and running.
|
|
163
215
|
|
|
216
|
+
// Need to minify js, reduce file size.
|
|
164
217
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
// The removal of server code / recompilation shouldnt make a difference in cases where we give it client-side js to start with.
|
|
168
|
-
// Have the case of the actual client-side js being given with no transformation needed.
|
|
169
|
-
// Can detect whether there is any server-side code and transformation(s) needed...?
|
|
218
|
+
// Minifying currently breaks it.
|
|
170
219
|
|
|
220
|
+
//o_serve_package.js_mode = 'debug';
|
|
171
221
|
|
|
222
|
+
// Extra functionality for loading / serving icon files?
|
|
223
|
+
// Easily available / usable named icons will be very useful within the app.
|
|
224
|
+
// Could be in sprites / pre-loaded.
|
|
172
225
|
|
|
173
226
|
|
|
174
227
|
|
|
175
|
-
//console.log('js_client', js_client);
|
|
176
|
-
//throw 'stop';
|
|
177
228
|
|
|
229
|
+
// Not sure how to do the replace when loading from disk.
|
|
230
|
+
// Give a reference to the package to serve itself.
|
|
231
|
+
// example servers -
|
|
232
|
+
// serve the css as well.
|
|
233
|
+
if (this.css) {
|
|
234
|
+
each(this.css, (path, serve_as) => {
|
|
235
|
+
css.serve(serve_as, path);
|
|
236
|
+
})
|
|
237
|
+
}
|
|
238
|
+
let js_client = this.client_package || this.js_client || 'jsgui3-client';
|
|
178
239
|
js.serve_package('/js/app.js', js_client, o_serve_package, (err, served) => {
|
|
179
240
|
//var resource_pool = this.resource_pool;
|
|
180
241
|
//console.log('server_router', server_router);
|
|
@@ -185,6 +246,7 @@ class Single_Control_Server extends Server {
|
|
|
185
246
|
var routing_tree = server_router.routing_tree;
|
|
186
247
|
routing_tree.set('/', (req, res) => {
|
|
187
248
|
//console.log('root path / request');
|
|
249
|
+
|
|
188
250
|
const o_spc = {
|
|
189
251
|
'req': req,
|
|
190
252
|
'res': res,
|
|
@@ -192,11 +254,10 @@ class Single_Control_Server extends Server {
|
|
|
192
254
|
}
|
|
193
255
|
|
|
194
256
|
if (this.include_server_ref_in_page_context) o_spc.server = this;
|
|
257
|
+
|
|
258
|
+
|
|
195
259
|
var server_page_context = new Server_Page_Context(o_spc);
|
|
196
|
-
|
|
197
|
-
if (this.context_data) {
|
|
198
|
-
Object.assign(server_page_context, this.context_data);
|
|
199
|
-
}
|
|
260
|
+
|
|
200
261
|
// and .server property?
|
|
201
262
|
// a different way to get the server info to the components is needed.
|
|
202
263
|
|
|
@@ -205,19 +266,46 @@ class Single_Control_Server extends Server {
|
|
|
205
266
|
'context': server_page_context
|
|
206
267
|
});
|
|
207
268
|
hd.include_client_css();
|
|
208
|
-
hd.include_css('/css/basic.css')
|
|
209
|
-
|
|
210
|
-
// include compiled css too.
|
|
211
|
-
// not much of it yet.
|
|
269
|
+
hd.include_css('/css/basic.css')
|
|
212
270
|
|
|
213
|
-
// Will be a separate CSS file, generated upon app start.
|
|
214
271
|
if (this.css) {
|
|
215
272
|
each(this.css, (path, serve_as) => {
|
|
216
273
|
//css.serve(serve_as, path);
|
|
217
274
|
hd.include_css('/css/' + serve_as);
|
|
218
275
|
});
|
|
219
276
|
}
|
|
220
|
-
|
|
277
|
+
|
|
278
|
+
// include a js script block, having it set up the
|
|
279
|
+
// not include_client_js
|
|
280
|
+
|
|
281
|
+
// .include_client_config_js()
|
|
282
|
+
// will get the resource config from the resource publisher.
|
|
283
|
+
|
|
284
|
+
// including data on published resources in the initial html download would be very useful.
|
|
285
|
+
// auto event wiring, so that controls that rely on having this data will have it available.
|
|
286
|
+
|
|
287
|
+
// Want to get this to work, then greatly slim down the codebase, or at least delete comments, use some more syntactic sugar.
|
|
288
|
+
|
|
289
|
+
// Calling 'publish' would be a good method.
|
|
290
|
+
//console.log('this.app_server.map_resource_publishers', this.app_server.map_resource_publishers);
|
|
291
|
+
//console.log('this.app_server.def_resource_publishers', this.app_server.def_resource_publishers);
|
|
292
|
+
|
|
293
|
+
// a script block where we assign the resource publishers.
|
|
294
|
+
// tell the client what resources are available on the server.
|
|
295
|
+
|
|
296
|
+
// include a js script block.
|
|
297
|
+
// jsgui.register_server_resources({...})
|
|
298
|
+
// o_def
|
|
299
|
+
// an object that describes how the resources are published.
|
|
300
|
+
|
|
301
|
+
// app_server.def_resource_publishers
|
|
302
|
+
// the urls
|
|
303
|
+
// what data it provides / its schema.
|
|
304
|
+
// a def from each of the publishers
|
|
305
|
+
// with a schema similar to graphql?
|
|
306
|
+
|
|
307
|
+
//throw 'stop';
|
|
308
|
+
|
|
221
309
|
var body = hd.body;
|
|
222
310
|
let o_params = this.params || {};
|
|
223
311
|
Object.assign(o_params, {
|
|
@@ -229,7 +317,10 @@ class Single_Control_Server extends Server {
|
|
|
229
317
|
ctrl.active();
|
|
230
318
|
//var ctrl2 = new jsgui.Control({});
|
|
231
319
|
body.add(ctrl);
|
|
232
|
-
|
|
320
|
+
|
|
321
|
+
let resources_script = new jsgui.script({
|
|
322
|
+
context: server_page_context
|
|
323
|
+
});
|
|
233
324
|
// it will be a client-side function.
|
|
234
325
|
|
|
235
326
|
// Should not use 'add' here.
|
|
@@ -241,57 +332,31 @@ class Single_Control_Server extends Server {
|
|
|
241
332
|
hd.include_js('/js/app.js');
|
|
242
333
|
|
|
243
334
|
// Would this be a place to register icons?
|
|
244
|
-
// and register client data.
|
|
245
335
|
|
|
246
|
-
// If we have the client data, we merge these items into the context.
|
|
247
|
-
// register_context_data
|
|
248
|
-
// because the page_context js object won't have been created yet...
|
|
249
336
|
|
|
250
|
-
|
|
251
|
-
|
|
337
|
+
const strc = new jsgui.String_Control({
|
|
338
|
+
context: server_page_context,
|
|
252
339
|
|
|
253
|
-
|
|
254
|
-
|
|
340
|
+
// Won't have access to the context when registering there?
|
|
341
|
+
// Will need to access the client-side context.
|
|
342
|
+
// Setting jsgui.context on the client-side does make sense.
|
|
343
|
+
// There would only be one context per instance of jsgui on the client.
|
|
255
344
|
|
|
256
|
-
|
|
257
|
-
|
|
345
|
+
// Could raise an event on jsgui, which the page_context listens to?
|
|
346
|
+
// The calls need to be set up within the page_context, I think.
|
|
258
347
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
let statements = [];
|
|
348
|
+
// Could just set the def_server_resources property.
|
|
349
|
+
// Then later activation with the page_context could refer to it.
|
|
262
350
|
|
|
263
|
-
|
|
264
|
-
|
|
351
|
+
// setting up the def_resource_publishers
|
|
352
|
+
// maybe 'resource' will be a generic term for something in some place.
|
|
353
|
+
// can be non-local, but api will localise its use.
|
|
265
354
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
if (this.app_server.def_resource_publishers) {
|
|
269
|
-
const c = Object.keys(this.app_server.def_resource_publishers).length;
|
|
270
|
-
if (c > 0) {
|
|
271
|
-
statement_rsr = `jsgui.register_server_resources(${JSON.stringify(this.app_server.def_resource_publishers)});`;
|
|
272
|
-
statements.push(statement_rsr);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
if (context_data) {
|
|
277
|
-
const c = Object.keys(context_data).length;
|
|
278
|
-
if (c > 0) {
|
|
279
|
-
statement_context_data = `jsgui.register_context_data(${JSON.stringify(context_data)});`;
|
|
280
|
-
statements.push(statement_context_data);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
355
|
+
text: `jsgui.register_server_resources(${JSON.stringify(this.app_server.def_resource_publishers)});`
|
|
356
|
+
});
|
|
283
357
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
context: server_page_context
|
|
287
|
-
});
|
|
288
|
-
const strc = new jsgui.String_Control({
|
|
289
|
-
context: server_page_context,
|
|
290
|
-
text: statements.join('')
|
|
291
|
-
});
|
|
292
|
-
resources_script.add(strc);
|
|
293
|
-
body.add(resources_script);
|
|
294
|
-
}
|
|
358
|
+
resources_script.add(strc);
|
|
359
|
+
body.add(resources_script);
|
|
295
360
|
|
|
296
361
|
hd.all_html_render(function (err, deferred_html) {
|
|
297
362
|
if (err) {
|
|
@@ -325,15 +390,11 @@ class Single_Control_Server extends Server {
|
|
|
325
390
|
load_icon_set(path, map_icons) {
|
|
326
391
|
// will load each icon into the image resource.
|
|
327
392
|
// sequential way of doing this?
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
//console.log('site_images', site_images);
|
|
334
|
-
// site_images.load_icon_set?
|
|
335
|
-
// read each of them from disk individually?
|
|
336
|
-
site_images.load_icon_set(path, map_icons);
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
|
|
337
398
|
}
|
|
338
399
|
}
|
|
339
400
|
|