jsgui3-server 0.0.119 → 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.
- package/examples/boxes/square_boxes.js +3 -0
- package/examples/boxes/square_boxes_client.js +5 -1
- package/examples/controls/11) window, mirrored text fields/client.js +31 -273
- package/examples/controls/11b) window, shared Data_Object model mirrored text fields/client.js +331 -0
- package/examples/controls/{11b) window, shared model mirrored text fields → 11c) window, shared Data_Value model mirrored text fields}/client.js +17 -7
- package/examples/controls/11c) window, shared Data_Value model mirrored text fields/server.js +118 -0
- package/examples/controls/11d) window, shared model mirrored integer text fields/both.js +17 -0
- package/examples/controls/11d) window, shared model mirrored integer text fields/client.js +280 -0
- package/examples/controls/11d) window, shared model mirrored integer text fields/server.js +23 -0
- package/examples/controls/12) window, Select_Options control/client.js +17 -0
- package/examples/controls/13) window, shared model mirrored lat_long/client.js +933 -0
- package/examples/controls/13) window, shared model mirrored lat_long/server.js +50 -0
- package/examples/controls/14) window, control compositional model/client.js +328 -0
- package/examples/controls/14) window, control compositional model/server.js +118 -0
- package/examples/controls/14a) window, control spec has compositional model/client.js +440 -0
- package/examples/controls/14a) window, control spec has compositional model/server.js +118 -0
- package/examples/controls/15) window, text field/client.js +256 -0
- package/examples/controls/15) window, text field/server.js +39 -0
- package/examples/controls/16) Window([Text_Input])/client.js +266 -0
- package/examples/controls/16) Window([Text_Input])/server.js +109 -0
- package/examples/controls/16a) Window([Text_Input]) Integer data.model.data_type/client.js +494 -0
- package/examples/controls/16a) Window([Text_Input]) Integer data.model.data_type/isomorphic.js +24 -0
- package/examples/controls/16a) Window([Text_Input]) Integer data.model.data_type/server.js +73 -0
- package/examples/controls/2b) two window, context menus/client.js +193 -0
- package/examples/controls/2b) two window, context menus/server.js +114 -0
- package/examples/controls/3) five windows/server.js +0 -1
- package/examples/controls/4) window, tabbed panel/client.js +15 -2
- package/examples/controls/4a) window, tabbed panel with various controls inside/client.js +233 -0
- package/examples/controls/4a) window, tabbed panel with various controls inside/server.js +118 -0
- package/examples/controls/5) window, grid/client.js +289 -9
- package/examples/controls/5) window, grid/server.js +2 -0
- package/examples/controls/8) window, checkbox/client.js +63 -101
- package/package.json +11 -11
- package/publishers/http-webpage-publisher.js +4 -5
- package/resources/jsbuilder/Abstract_Single_Declaration.js +1 -1
- package/resources/jsbuilder/Abstract_Single_Declaration_Sequence.js +1 -1
- package/resources/jsbuilder/JS_AST/JS_AST_Node.js +1 -1
- package/resources/jsbuilder/JS_AST/JS_AST_Node_0-Core.js +1 -1
- package/resources/jsbuilder/JS_AST/JS_AST_Node_1-Babel.js +1 -1
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.6-Basics_Callmap.js +1 -1
- package/resources/jsbuilder/JS_AST/JS_AST_Node_4.1-Index.js +1 -1
- package/resources/jsbuilder/JS_AST/JS_AST_Node_8-Features.js +1 -1
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Node_Feature_Declaration.js +1 -1
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Node_Feature_Declarator.js +1 -1
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/JS_AST_Root_Node_Feature_Exported.js +1 -1
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/JS_AST_Root_Node_Interpreted.js +1 -1
- package/resources/jsbuilder/JS_AST/JS_AST_Relationship_Node_To_Group.js +1 -1
- package/resources/jsbuilder/JS_AST/query/enable_array_as_queryable.js +1 -1
- package/resources/jsbuilder/JS_AST/query/find_object_keys.js +1 -1
- package/resources/jsbuilder/JS_AST_Node_Extended/JS_AST_Node_Declaration.js +1 -1
- package/resources/jsbuilder/JS_Builder.js +1 -1
- package/resources/jsbuilder/JS_File/JS_File_0-Core.js +1 -1
- package/resources/jsbuilder/JS_File/JS_File_2-Babel.js +1 -1
- package/resources/jsbuilder/JS_File/JS_File_4-Query.js +1 -1
- package/resources/jsbuilder/JS_File/JS_File_4.1-Query_Features.js +1 -1
- package/resources/jsbuilder/JS_File/JS_File_5-Planning.js +1 -1
- package/resources/jsbuilder/JS_File/JS_File_6-Changing.js +1 -1
- package/resources/jsbuilder/JS_File/JS_Files.js +1 -1
- package/resources/jsbuilder/Platform.js +1 -1
- package/resources/jsbuilder/Platforms.js +1 -1
- package/resources/jsbuilder/Project.js +1 -1
- package/resources/jsbuilder/Scope.js +1 -1
- package/resources/jsbuilder/_JS_File.js +1 -1
- package/resources/jsbuilder/babel/babel_node_tools.js +1 -1
- package/resources/jsbuilder/babel/deep_iterate/deep_iterate_babel.js +6 -2
- package/resources/jsbuilder/test/test_ast_node.js +1 -1
- package/resources/jsbuilder/test/test_js_file.js +2 -2
- package/resources/jsbuilder/test/test_project.js +1 -1
- package/resources/process-js.js +1 -1
- package/resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild.js +9 -6
- package/resources/processors/bundlers/js/esbuild/Core_JS_Single_File_Minifying_Bundler_Using_ESBuild.js +2 -1
- package/resources/processors/bundlers/test_ast.js +1 -1
- package/resources/processors/extractors/Extractor.js +3 -1
- package/resources/processors/extractors/js/css_and_js/AST_Node/CSS_And_JS_From_JS_String_Using_AST_Node_Extractor.js +19 -4
- /package/examples/controls/{11b) window, shared model mirrored text fields → 11b) window, shared Data_Object model mirrored text fields}/server.js +0 -0
package/examples/controls/11b) window, shared Data_Object model mirrored text fields/client.js
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
const jsgui = require('jsgui3-client');
|
|
2
|
+
const {controls, Control, mixins, Data_Object} = jsgui;
|
|
3
|
+
const {dragable} = mixins;
|
|
4
|
+
|
|
5
|
+
const {field} = require('obext');
|
|
6
|
+
|
|
7
|
+
const {Checkbox, Date_Picker, Text_Input, Text_Field} = controls;
|
|
8
|
+
|
|
9
|
+
const Active_HTML_Document = require('../../../controls/Active_HTML_Document');
|
|
10
|
+
|
|
11
|
+
// Will make Date_Picker use progressive enhancement.
|
|
12
|
+
// On activation would create a new element? Create a new sibling?
|
|
13
|
+
// May want code that checks for .el being changed.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
// Want the data sharing to be really simple and intuitive to set up.
|
|
18
|
+
// But not so simple the comlexities of data flow can't be expressed when needed.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
// Make it so sharing a data model is very easy.
|
|
22
|
+
// Sharing a single value, or referring to different values within it.
|
|
23
|
+
|
|
24
|
+
// Be able to handle errors when the view model can't update the data_model for some reason(s).
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class Demo_UI extends Active_HTML_Document {
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
constructor(spec = {}) {
|
|
36
|
+
spec.__type_name = spec.__type_name || 'demo_ui';
|
|
37
|
+
super(spec);
|
|
38
|
+
const {context} = this;
|
|
39
|
+
|
|
40
|
+
/*
|
|
41
|
+
|
|
42
|
+
const setup_demo_ui_data_model = () => {
|
|
43
|
+
this.data = {
|
|
44
|
+
model: new Data_Value({
|
|
45
|
+
context
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
field(this.data.model, 'value');
|
|
49
|
+
context.register_control(this.data.model);
|
|
50
|
+
}
|
|
51
|
+
setup_demo_ui_data_model();
|
|
52
|
+
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
this.data.model.data_type = String;
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
if (typeof this.body.add_class === 'function') {
|
|
59
|
+
this.body.add_class('demo-ui');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//console.log('this.body', this.body);
|
|
63
|
+
//console.log('this.body.add_class', this.body.add_class);
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
const compose = () => {
|
|
67
|
+
|
|
68
|
+
// Not so sure how to persist the (shared) data_models upon composition.
|
|
69
|
+
// Maybe explicitly reassigning them on activation for the moment.
|
|
70
|
+
// Could actually be necessary right now, but should look into supporting it automatically on
|
|
71
|
+
// a lower level.
|
|
72
|
+
|
|
73
|
+
// Defining shared data models in the composition...
|
|
74
|
+
// Should be able to persist that info to the data-jsgui properties in the HTML.
|
|
75
|
+
// Also may be best to have some very explicit code that generates the app's Data_Model, or the page's Data_Model.
|
|
76
|
+
|
|
77
|
+
// Does seem like persisting the relationships between controls, the inner parts of them, and data_models is important.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
const window = new controls.Window({
|
|
86
|
+
context: context,
|
|
87
|
+
title: 'jsgui3-html Shared data.model Mirrored Text_Input controls',
|
|
88
|
+
pos: [5, 5]
|
|
89
|
+
});
|
|
90
|
+
window.size = [480, 160];
|
|
91
|
+
|
|
92
|
+
const tf1 = new Text_Field({
|
|
93
|
+
context,
|
|
94
|
+
text: 'A', // label.text???
|
|
95
|
+
// name???
|
|
96
|
+
|
|
97
|
+
data: {
|
|
98
|
+
model: this.data.model
|
|
99
|
+
|
|
100
|
+
// model: [this.data.model, 'value'] // this seems better
|
|
101
|
+
|
|
102
|
+
// model_property: 'value'
|
|
103
|
+
// model_property: 'value2' // for example
|
|
104
|
+
}
|
|
105
|
+
//label: {
|
|
106
|
+
// text: 'A checkbox'
|
|
107
|
+
//}
|
|
108
|
+
});
|
|
109
|
+
window.inner.add(tf1);
|
|
110
|
+
const tf2 = new Text_Field({
|
|
111
|
+
context,
|
|
112
|
+
|
|
113
|
+
text: 'B',
|
|
114
|
+
data: {
|
|
115
|
+
model: this.data.model
|
|
116
|
+
}
|
|
117
|
+
//label: {
|
|
118
|
+
// text: 'A checkbox'
|
|
119
|
+
//}
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
window.inner.add(tf2);
|
|
123
|
+
|
|
124
|
+
this.body.add(window);
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
this._ctrl_fields = this._ctrl_fields || {};
|
|
128
|
+
this._ctrl_fields.tf1 = tf1;
|
|
129
|
+
this._ctrl_fields.tf2 = tf2;
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
// Only after activate???
|
|
136
|
+
// On a higher level will not need to pay as much attention to activation.
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
// Both after compose and activate, need to set up the
|
|
142
|
+
|
|
143
|
+
if (!spec.el) {
|
|
144
|
+
compose();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
setup_inner_listeners() {
|
|
151
|
+
// Post compose or during activate.
|
|
152
|
+
const {tf1, tf2} = this;
|
|
153
|
+
|
|
154
|
+
tf1.data.model.on('change', e => {
|
|
155
|
+
console.log('tf1 data model e', e);
|
|
156
|
+
const {name, old, value} = e;
|
|
157
|
+
if (name === 'value') {
|
|
158
|
+
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
tf2.data.model.on('change', e => {
|
|
163
|
+
console.log('tf2 data model e', e);
|
|
164
|
+
const {name, old, value} = e;
|
|
165
|
+
if (name === 'value') {
|
|
166
|
+
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// A lower level way of reconstructing models on the client would help.
|
|
172
|
+
// Eg when a control gets composed, it could be specified that an internal control's
|
|
173
|
+
// view model is the same as, or is synced with this control's view model.
|
|
174
|
+
|
|
175
|
+
// Do want to handle both syncing as well as using the same JS objects where appropriate.
|
|
176
|
+
// Same objects will be best when one thing really is the other.
|
|
177
|
+
|
|
178
|
+
// Eg a Text_Field would have it's view data model value represented using a Text_Input.
|
|
179
|
+
|
|
180
|
+
// Late consider where in the namespacing things like
|
|
181
|
+
// label text, label text font, label icon image url etc can go.
|
|
182
|
+
// It's not the 'core' data model.
|
|
183
|
+
|
|
184
|
+
// Maybe presentation model???
|
|
185
|
+
// .ui model does seem convenient and explicit.
|
|
186
|
+
// ctrl.view.ui.label.text.font for example.
|
|
187
|
+
// ctrl.view.ui.label.text.font.size, ctrl.view.ui.label.text.size could be synonyms.
|
|
188
|
+
// Make the mid-level objects work so they provide a nice and flexible top level API.
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
// So within Text_Field, would use _ctrl_fields
|
|
193
|
+
// could also assign / reassign the data models upon activation???
|
|
194
|
+
|
|
195
|
+
// Concise code at the high level would be OK for the moment, but really want this on mid level.
|
|
196
|
+
|
|
197
|
+
// Or could rely on syncing for the moment....?
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
activate() {
|
|
216
|
+
if (!this.__active) {
|
|
217
|
+
super.activate();
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
const {context, tf1, tf2} = this;
|
|
222
|
+
|
|
223
|
+
console.log('activate Demo_UI');
|
|
224
|
+
|
|
225
|
+
// Want data model syncing and activation done for free.
|
|
226
|
+
|
|
227
|
+
const already_same_data_models_on_activation = this.data.model === tf1.data.model === tf2.data.model;
|
|
228
|
+
console.log('already_same_data_models_on_activation', already_same_data_models_on_activation);
|
|
229
|
+
|
|
230
|
+
if (!already_same_data_models_on_activation) {
|
|
231
|
+
console.log('Need to reassign the data_models of the two controls [tf1, tf2].');
|
|
232
|
+
|
|
233
|
+
// Probably need to have the specific code in Text_Field to handle data.model changing.
|
|
234
|
+
|
|
235
|
+
tf1.data.model = this.data.model;
|
|
236
|
+
tf2.data.model = this.data.model;
|
|
237
|
+
|
|
238
|
+
} else {
|
|
239
|
+
console.log('jsgui3 now supports client-side reconstruction of shared object models on a lower level.')
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
this.setup_inner_listeners();
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
context.on('window-resize', e_resize => {
|
|
246
|
+
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Include this in bundling.
|
|
254
|
+
// Want CSS bundling so that styles are read out from the JS document and compiled to a stylesheet.
|
|
255
|
+
|
|
256
|
+
//controls.Demo_UI = Demo_UI;
|
|
257
|
+
|
|
258
|
+
// A css file may be an easier way to get started...?
|
|
259
|
+
// Want to support but not require css in js.
|
|
260
|
+
|
|
261
|
+
// But need to set up the serving of the CSS both on the server, and on the client.
|
|
262
|
+
// Ofc setting it up on the server first is important - then can that stage set it up in the doc sent to the client?
|
|
263
|
+
|
|
264
|
+
// Including the CSS from the JS like before.
|
|
265
|
+
// Needs to extract the CSS and serve it as a separate CSS file.
|
|
266
|
+
// Should also have end-to-end regression tests so this does not break again in the future.
|
|
267
|
+
// The code was kind of clunky and got refactored away.
|
|
268
|
+
//
|
|
269
|
+
|
|
270
|
+
// Would need to parse the JS files to extract the CSS.
|
|
271
|
+
// Maybe could do it an easier way??? Now that it's easy, want a faster way.
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
Demo_UI.css = `
|
|
275
|
+
|
|
276
|
+
* {
|
|
277
|
+
margin: 0;
|
|
278
|
+
padding: 0;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
body {
|
|
282
|
+
overflow-x: hidden;
|
|
283
|
+
overflow-y: hidden;
|
|
284
|
+
background-color: #E0E0E0;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.demo-ui {
|
|
288
|
+
|
|
289
|
+
/*
|
|
290
|
+
|
|
291
|
+
display: flex;
|
|
292
|
+
flex-wrap: wrap;
|
|
293
|
+
|
|
294
|
+
flex-direction: column;
|
|
295
|
+
justify-content: center;
|
|
296
|
+
align-items: center;
|
|
297
|
+
text-align: center;
|
|
298
|
+
min-height: 100vh;
|
|
299
|
+
*/
|
|
300
|
+
|
|
301
|
+
}
|
|
302
|
+
`;
|
|
303
|
+
|
|
304
|
+
// But may want to remove them from that flex upon picking up / dropping them.
|
|
305
|
+
// Maybe best upon drop.
|
|
306
|
+
|
|
307
|
+
// Maybe want other examples that use absolute positioning to position the items at the start?
|
|
308
|
+
//
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
//controls.Square_Box = Square_Box;
|
|
313
|
+
// could export jsgui with the updated controls....
|
|
314
|
+
// so that they are in the correct Page Context.?
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
controls.Demo_UI = Demo_UI;
|
|
318
|
+
|
|
319
|
+
module.exports = jsgui;
|
|
320
|
+
|
|
321
|
+
/*
|
|
322
|
+
module.exports = {
|
|
323
|
+
Square_Box: Square_Box,
|
|
324
|
+
Demo_UI: Demo_UI
|
|
325
|
+
}
|
|
326
|
+
*/
|
|
327
|
+
|
|
328
|
+
// Then if window...?
|
|
329
|
+
|
|
330
|
+
// Need to add the Square_Box control to the context or original map of controls...
|
|
331
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const jsgui = require('jsgui3-client');
|
|
2
|
-
const {controls, Control, mixins,
|
|
2
|
+
const {controls, Control, mixins, Data_Value} = jsgui;
|
|
3
3
|
const {dragable} = mixins;
|
|
4
4
|
|
|
5
5
|
const {field} = require('obext');
|
|
@@ -68,13 +68,17 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
68
68
|
// Maybe adding the fields to the Data_Object is needed.
|
|
69
69
|
|
|
70
70
|
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
71
74
|
const setup_demo_ui_data_model = () => {
|
|
75
|
+
console.log('client pre creare data.model as Data_Value')
|
|
72
76
|
this.data = {
|
|
73
|
-
model: new
|
|
77
|
+
model: new Data_Value({
|
|
74
78
|
context
|
|
75
79
|
})
|
|
76
80
|
}
|
|
77
|
-
field(this.data.model, 'value');
|
|
81
|
+
//field(this.data.model, 'value');
|
|
78
82
|
context.register_control(this.data.model);
|
|
79
83
|
}
|
|
80
84
|
setup_demo_ui_data_model();
|
|
@@ -402,18 +406,24 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
402
406
|
/// Maybe a different function as standard to assign isomorphic things.
|
|
403
407
|
|
|
404
408
|
|
|
409
|
+
// What about (just) using a Data_Value???
|
|
410
|
+
// Data_Value_Model?
|
|
411
|
+
// Data_Model_Value???
|
|
412
|
+
|
|
413
|
+
// Just stick to Data_Value for now.
|
|
414
|
+
|
|
405
415
|
|
|
406
416
|
|
|
407
|
-
const dm = new
|
|
408
|
-
field(dm, 'value');
|
|
417
|
+
const dm = new Data_Value({context});
|
|
418
|
+
//field(dm, 'value');
|
|
409
419
|
ti1.data.model = dm;
|
|
410
420
|
ti2.data.model = dm;
|
|
411
421
|
|
|
412
422
|
// But then need to get them to reassign their data model change listeners....?
|
|
413
423
|
// value change even....
|
|
414
424
|
|
|
415
|
-
ti1.assign_data_model_value_change_handler();
|
|
416
|
-
ti2.assign_data_model_value_change_handler();
|
|
425
|
+
//ti1.assign_data_model_value_change_handler();
|
|
426
|
+
//ti2.assign_data_model_value_change_handler();
|
|
417
427
|
|
|
418
428
|
|
|
419
429
|
}
|
|
@@ -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.one('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
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const jsgui = require('lang-tools');
|
|
2
|
+
const {Data_Value, Functional_Data_Type} = jsgui;
|
|
3
|
+
const create_demo_ui_data_model = (context) => {
|
|
4
|
+
const res = new Data_Value({
|
|
5
|
+
context,
|
|
6
|
+
data_type: Functional_Data_Type.integer
|
|
7
|
+
});
|
|
8
|
+
if (context) {
|
|
9
|
+
context.register_control(res);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return res;
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
module.exports = {
|
|
16
|
+
create_demo_ui_data_model
|
|
17
|
+
}
|