jsgui3-server 0.0.78 → 0.0.81
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.
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
A simple demo. This will require a bit more work regarding separating / compiling client-side code.
|
|
3
|
-
Being able to write a whole (simple) app in one JS file will be very useful for writing and using something quickly.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Will be a demo of some styling, maybe theming.
|
|
7
|
-
Size / pos / dim props.
|
|
8
|
-
Maybe some things like dragging it.
|
|
9
|
-
Maybe it could bounce back into place.
|
|
10
|
-
See about physics modelling, eg simulated mass and accelerations, elastic forces.
|
|
11
|
-
Maybe that will be in a mixin? Written as a mixin within the demo?
|
|
12
|
-
Want interesting functionality to be encapsulated in mixins rather than controls where possible.
|
|
13
|
-
Encapsulated so that controls can use this functionality easily.
|
|
14
|
-
A little page explaining encapsulation would help...
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
All the code will be valid on the server, apart from inner parts of functions that do checking to see the context (ie activate)
|
|
18
|
-
Its not important to hide this code from the server like it is with hiding server-side code from the client.
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// Will a client js file be generated?
|
|
24
|
-
// How will it be generated?
|
|
25
|
-
|
|
26
|
-
// Yes - will need to reference html-client.js, while having the control definitions, or code appropriately lifted from here.
|
|
27
|
-
// However, would need to create a string js file that does what's needed.
|
|
28
1
|
|
|
29
2
|
const jsgui = require('jsgui3-html'); // and will replace this with jsgui-client, I presume.
|
|
30
3
|
const {controls, Control, mixins} = jsgui;
|
|
@@ -59,72 +32,6 @@ class Demo_UI extends Control {
|
|
|
59
32
|
console.log('window-resize', e_resize);
|
|
60
33
|
});
|
|
61
34
|
|
|
62
|
-
/*
|
|
63
|
-
|
|
64
|
-
const freq = 10000;
|
|
65
|
-
let ts_last_exec;
|
|
66
|
-
|
|
67
|
-
const proc = (obj_frame) => {
|
|
68
|
-
console.log('proc');
|
|
69
|
-
console.log('obj_frame', obj_frame);
|
|
70
|
-
|
|
71
|
-
// Need the dims for the dom controls.
|
|
72
|
-
// Need i_dom_id for the index of items within the DOM.
|
|
73
|
-
// Forget about iid for the moment?
|
|
74
|
-
// As these indexes become too sparse for the typed array.
|
|
75
|
-
|
|
76
|
-
// Need to look at the map_dom_controls
|
|
77
|
-
// This map_dom_controls should be automatically maintained.
|
|
78
|
-
// Needs to be updated whenever a control gets added to or removed from the DOM.
|
|
79
|
-
|
|
80
|
-
// Could use mutation observer?
|
|
81
|
-
// May make more sense to update it when we know that anything has been added to or removed from the DOM.
|
|
82
|
-
// Nullify references to the controls when removed from the DOM?
|
|
83
|
-
// Use delete? Is this still very slow? Is it appropriate?
|
|
84
|
-
// Or build up new object?
|
|
85
|
-
|
|
86
|
-
// arr_dom_ctrls...?
|
|
87
|
-
|
|
88
|
-
// or keep track of what's being added or removed from the DOM, and deal with it at various stages between frames.
|
|
89
|
-
// keeping track of and working within frames will make things work well.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
//const dims = context.create_dims_from_current_ctrls();
|
|
93
|
-
//console.log('dims', dims);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
context.on('frame', obj_frame => {
|
|
97
|
-
//console.log('obj_frame', obj_frame);
|
|
98
|
-
// Want to use the translate feature in the ctrl.ta.
|
|
99
|
-
|
|
100
|
-
const {timestamp} = obj_frame;
|
|
101
|
-
// Goes rather quickly.
|
|
102
|
-
// The page context may do some kinds of observations.
|
|
103
|
-
|
|
104
|
-
// The locations of all controls...
|
|
105
|
-
// The locations of controls that we are monitoring for dimension changes
|
|
106
|
-
|
|
107
|
-
// List / map of controls to check for different positions.
|
|
108
|
-
|
|
109
|
-
if (ts_last_exec) {
|
|
110
|
-
if (timestamp - ts_last_exec >= freq) {
|
|
111
|
-
ts_last_exec = timestamp;
|
|
112
|
-
proc(obj_frame);
|
|
113
|
-
}
|
|
114
|
-
} else {
|
|
115
|
-
ts_last_exec = timestamp;
|
|
116
|
-
proc(obj_frame);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
*/
|
|
120
|
-
|
|
121
|
-
// listen for the movement events?
|
|
122
|
-
// Context will do more to handle movement.
|
|
123
|
-
|
|
124
|
-
// Get a ta of positions etc from the context?
|
|
125
|
-
// But a lot of that should be handled behind the scenes. Will keep a whole load of controls' properties together in a big typed array.
|
|
126
|
-
|
|
127
|
-
|
|
128
35
|
}
|
|
129
36
|
}
|
|
130
37
|
}
|
|
@@ -139,32 +46,6 @@ Demo_UI.css = `
|
|
|
139
46
|
min-height: 100vh;
|
|
140
47
|
}
|
|
141
48
|
`;
|
|
142
|
-
/*
|
|
143
|
-
|
|
144
|
-
*/
|
|
145
|
-
|
|
146
|
-
// Will most likely make use of mixins to give the box some functionality.
|
|
147
|
-
// Responding to clicks / presses.
|
|
148
|
-
// Drags.
|
|
149
|
-
// An elastic effect does seeem like it would be useful.
|
|
150
|
-
// Physics sims too...
|
|
151
|
-
// Double elastic drag...?
|
|
152
|
-
// Could also predict / plan how it will move and set it up with css animation frames.
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
// Making functionality as a mixin makes most sense for many things.
|
|
156
|
-
// Code will be more adaptable, and the class defs will be clearer and more concise by referencing the named functionality rather than having the implementation code in there.
|
|
157
|
-
|
|
158
|
-
// Could split it into functions?
|
|
159
|
-
// client = () => {...}, iso, server
|
|
160
|
-
|
|
161
|
-
// Stylistic definition in the code?
|
|
162
|
-
// Worth using CSS?
|
|
163
|
-
// It's the developer's choics.
|
|
164
|
-
|
|
165
|
-
// Will make use of dims / dimensions functionality.
|
|
166
|
-
// Changing values in dims could be recognised between frames, and in the next frame, the size & position get updated.
|
|
167
|
-
// batching CSS changes?
|
|
168
49
|
|
|
169
50
|
class Square_Box extends Control {
|
|
170
51
|
constructor(spec) {
|
|
@@ -177,16 +58,6 @@ class Square_Box extends Control {
|
|
|
177
58
|
super.activate();
|
|
178
59
|
console.log('Activate square box');
|
|
179
60
|
|
|
180
|
-
// By default should be able to move it around.
|
|
181
|
-
// Breaking out of its current positioning, if necessary.
|
|
182
|
-
// Or will use a transformation to show it displaced from its current position.
|
|
183
|
-
// Easier than not setting it to abs pos and setting left and top properties.
|
|
184
|
-
|
|
185
|
-
// Will interact with the typed array that deals with translation properties.
|
|
186
|
-
// Needs to happen on that lower level.
|
|
187
|
-
|
|
188
|
-
// Will do work on translate mode dragging.
|
|
189
|
-
|
|
190
61
|
dragable(this, {
|
|
191
62
|
drag_mode: 'translate'
|
|
192
63
|
});
|
|
@@ -197,42 +68,7 @@ class Square_Box extends Control {
|
|
|
197
68
|
|
|
198
69
|
this.on('dragend', e => {
|
|
199
70
|
console.log('square box dragend e', e);
|
|
200
|
-
|
|
201
|
-
// Then snap it back to its original position?
|
|
202
|
-
// Get a snap back function here?
|
|
203
|
-
|
|
204
|
-
// Could snap it back by changing / animating the transform properties.
|
|
205
|
-
// Or not right now... at least we have the main translate drag functionality working.
|
|
206
|
-
|
|
207
|
-
// Also, could allow extensions / custom modes to be draggable.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
})
|
|
215
|
-
|
|
216
|
-
// Use a variety of pieces of functionality.
|
|
217
|
-
|
|
218
|
-
// Draggable
|
|
219
|
-
// Then elastic effect upon release.
|
|
220
|
-
|
|
221
|
-
// This should work quickly on a lower level.
|
|
222
|
-
// Making a system for faster interactions.
|
|
223
|
-
|
|
224
|
-
// Some other parts of the framework will use direct access to these typed arrays.
|
|
225
|
-
// Need things coded on that lower level.
|
|
226
|
-
// quite a lot of code involved....
|
|
227
|
-
|
|
228
|
-
/*
|
|
229
|
-
|
|
230
|
-
setTimeout(() => {
|
|
231
|
-
// const X = 0, Y = 1, H = 2, W = 3, R = 4, B = 5, TX = 6, TY = 7;
|
|
232
|
-
this.ta[6] = 100;
|
|
233
|
-
}, 4000); // this works
|
|
234
|
-
*/
|
|
235
|
-
|
|
71
|
+
});
|
|
236
72
|
|
|
237
73
|
}
|
|
238
74
|
}
|
|
@@ -246,67 +82,12 @@ Square_Box.css = `
|
|
|
246
82
|
`;
|
|
247
83
|
controls.Square_Box = Square_Box;
|
|
248
84
|
|
|
249
|
-
// Client and server
|
|
250
|
-
|
|
251
|
-
// Overall control.
|
|
252
|
-
// A square box inside that control.
|
|
253
|
-
|
|
254
|
-
// Server
|
|
255
|
-
// The definition of and loading in of server object.
|
|
256
|
-
// Starting it up. All of the code within the part where the module runs.
|
|
257
|
-
|
|
258
|
-
// SCS makes sense for this though.
|
|
259
|
-
|
|
260
|
-
// Then will make a nice demo to do with dragging and elasticity.
|
|
261
|
-
// Need to do more work on the js resource converting single file js to client-side js.
|
|
262
|
-
// Won't be all that complicated overall but has parts with a bit of complexity that need to be written.
|
|
263
|
-
|
|
264
85
|
if (require.main === module) {
|
|
265
86
|
const SCS = require('../../single-control-server');
|
|
266
|
-
// generate client js from this js itself...
|
|
267
|
-
// possibly need to save client js in same path too...?
|
|
268
|
-
// same file name, .client.js?
|
|
269
|
-
// would make sense.
|
|
270
|
-
// probably nicer without, but not sure how easy / possible to do it.
|
|
271
|
-
|
|
272
|
-
// client js - be able to detect if its a server module.
|
|
273
|
-
// if so, will need to do some replacements and removals.
|
|
274
|
-
// (transformations)
|
|
275
87
|
const server = new SCS({
|
|
276
88
|
Ctrl: Demo_UI,
|
|
277
89
|
|
|
278
|
-
//
|
|
279
|
-
// Would first spot that it's a module that can run on the server.
|
|
280
|
-
// Need this to work within jsgui like here, and outside.
|
|
281
|
-
// Will need to do some replacements at some points in the process.
|
|
282
|
-
// Further than just the CSS removal and extraction.
|
|
283
|
-
// Needs server code removal.
|
|
284
|
-
// Needs to include the client side js...
|
|
285
|
-
// Or replace the jsgui3-html with jsgui3-client at the top.
|
|
286
|
-
|
|
287
|
-
// Also interested in removing controls that are not used within the app.
|
|
288
|
-
// Will save on download size.
|
|
289
|
-
// For the moment, focus on splitting out the client-side code from server-side, and making it a nice package to serve to the client.
|
|
290
|
-
/// Will be easier not to have to make a separate client js file in many cases.
|
|
291
|
-
// Find a way to include activation code that references the context?
|
|
292
|
-
// Could be within the controls' activation.
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
// Need to go through / make the client side js at a relatively early stage.
|
|
296
|
-
// Preferable before browserify (linking).
|
|
297
|
-
// May be best / necessary to save a .client.js file.
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
// Client package processing to remove any server references.
|
|
301
|
-
// Change necessary ref to the client file.
|
|
302
|
-
// A somewhat complex recomplition process but it will make the examples and demos simpler.
|
|
303
|
-
// Single file full / single control server demos will be of great use.
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
// String-only control definitions may come.
|
|
307
|
-
// All properties available when given as text.
|
|
308
|
-
// Property parsing.
|
|
309
|
-
'js_mode': 'debug',
|
|
90
|
+
//'js_mode': 'debug',
|
|
310
91
|
|
|
311
92
|
'client_package': require.resolve('./square_box.js')
|
|
312
93
|
//js_client: require.resolve('./square_box.js')
|
|
@@ -314,6 +95,8 @@ if (require.main === module) {
|
|
|
314
95
|
|
|
315
96
|
// then start the server....
|
|
316
97
|
|
|
98
|
+
// be able to choose the port / ports?
|
|
99
|
+
|
|
317
100
|
server.start(function (err, cb_start) {
|
|
318
101
|
if (err) {
|
|
319
102
|
throw err;
|
package/package.json
CHANGED
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
"child-process": "^1.0.2",
|
|
13
13
|
"cookies": "^0.8.0",
|
|
14
14
|
"fnl": "^0.0.21",
|
|
15
|
-
"fnlfs": "^0.0.
|
|
16
|
-
"jsgui3-client": "^0.0.
|
|
17
|
-
"jsgui3-html": "0.0.
|
|
15
|
+
"fnlfs": "^0.0.24",
|
|
16
|
+
"jsgui3-client": "^0.0.65",
|
|
17
|
+
"jsgui3-html": "0.0.91",
|
|
18
18
|
"lang-mini": "^0.0.24",
|
|
19
19
|
"multiparty": "^4.2.3",
|
|
20
20
|
"ncp": "^2.0.0",
|
|
21
|
-
"obext": "0.0.
|
|
21
|
+
"obext": "0.0.22",
|
|
22
22
|
"rimraf": "^3.0.2",
|
|
23
23
|
"stream-to-array": "^2.3.0",
|
|
24
24
|
"url-parse": "^1.5.10"
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"type": "git",
|
|
41
41
|
"url": "https://github.com/metabench/jsgui3-server.git"
|
|
42
42
|
},
|
|
43
|
-
"version": "0.0.
|
|
43
|
+
"version": "0.0.81"
|
|
44
44
|
}
|
|
@@ -287,69 +287,6 @@ const test_js_ast_node = () => {
|
|
|
287
287
|
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
// query.collect.pattern.inner.identifier.exe()
|
|
296
|
-
// query.collect.pattern.child.property.exe()
|
|
297
|
-
|
|
298
|
-
// query.collect.pattern.exe().query.collect.child.property.exe();
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
// Nice, being able to query the results is good.
|
|
305
|
-
// But will get it working with more verbs than just collect.
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
// .string?
|
|
312
|
-
// .qstring
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
//const q2res = q2.exe(cn => {
|
|
316
|
-
// console.log('cn', cn);
|
|
317
|
-
//});
|
|
318
|
-
|
|
319
|
-
// each child declaration
|
|
320
|
-
// identifier
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
// .exe function executes the query.
|
|
324
|
-
|
|
325
|
-
// Could load in various query handling modules in a tree.
|
|
326
|
-
|
|
327
|
-
// .each.child.declaration
|
|
328
|
-
|
|
329
|
-
// Then a fairly large OO query system could do it.
|
|
330
|
-
// Consider if that's best.
|
|
331
|
-
// Seems best, considering usage of various objects such as relationships.
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
// then can use specific (level 2) properties when we have a Declaration of VariableDeclaration
|
|
343
|
-
|
|
344
|
-
// let's put it in the VariableDeclaration class.
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
// declaration.left_terms?
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
290
|
const earlier_tests = () => {
|
|
354
291
|
|
|
355
292
|
console.log('js_ast_node.category', js_ast_node.category);
|
|
@@ -28,6 +28,17 @@ var serve_html_file_from_disk = function(filePath, response) {
|
|
|
28
28
|
// File_Server_Resource?
|
|
29
29
|
// So the resource has code to route to the file and then serve it.
|
|
30
30
|
|
|
31
|
+
// Also a Templated_HTML resource?
|
|
32
|
+
// Connects to HTML_Template
|
|
33
|
+
// Connects to Data_Resource
|
|
34
|
+
// Populates the HTML_Template data from the Data_Resource
|
|
35
|
+
|
|
36
|
+
// HTML_Template being a Data_Transformation / Data_Transformation_Resource / Transformation_Resource
|
|
37
|
+
// Codecs could be another type of Transformation_Resource
|
|
38
|
+
|
|
39
|
+
// Transformation Resource could / should appear in jsgui3-client. Makes sense on the client too.
|
|
40
|
+
|
|
41
|
+
|
|
31
42
|
class Site_Static_HTML extends Resource {
|
|
32
43
|
|
|
33
44
|
constructor(spec) {
|
package/single-control-server.js
CHANGED
|
@@ -33,40 +33,8 @@ var Server_Page_Context = require('./page-context');
|
|
|
33
33
|
// debug
|
|
34
34
|
// (standard)
|
|
35
35
|
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
/*
|
|
39
|
-
var server = new Server({
|
|
40
|
-
'*': {
|
|
41
|
-
'name': 'html-server'
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
*/
|
|
46
|
-
/*
|
|
47
|
-
var resource_pool = root_server.resource_pool;
|
|
48
|
-
// link these getters with the resource pool resource getters?
|
|
49
|
-
let app_server = resource_pool['HTML Server'];
|
|
50
|
-
//console.log('app_server', app_server);
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
//console.log('app_server.resource_names', app_server.resource_names);
|
|
54
|
-
//console.log('!!app_server.resource_pool', !!app_server.resource_pool);
|
|
55
|
-
let js = app_server.resource_pool['Site JavaScript'];
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
//console.log('Server', Server);
|
|
59
|
-
|
|
60
|
-
// And choose the CSS file / files to send it.
|
|
61
|
-
// Could send basic jsgui css by default
|
|
62
|
-
// Then there would be app css on top of that.
|
|
63
|
-
|
|
64
|
-
// Authenticated_Server?
|
|
65
|
-
// Has got authentication mechanisms as a wrapper for the controls inside.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
// Want to be able to set up icons as well.
|
|
69
|
-
|
|
36
|
+
// Assumes port 80 for the moment, but want control over ports.
|
|
37
|
+
// May have / need dedicated websocket port, maybe https, secure websocket?
|
|
70
38
|
|
|
71
39
|
class Single_Control_Server extends Server {
|
|
72
40
|
constructor(spec) {
|
|
@@ -96,19 +64,7 @@ class Single_Control_Server extends Server {
|
|
|
96
64
|
|
|
97
65
|
if (spec.js_mode) this.js_mode = spec.js_mode;
|
|
98
66
|
if (spec.js_client) this.js_client = spec.js_client;
|
|
99
|
-
// js client could be this file itself...?
|
|
100
|
-
// creating a js client file in the same location probably makes most sense.
|
|
101
|
-
// maybe a way of skipping that later...? Deleting it?
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
// Context data
|
|
106
|
-
// will get loaded into the context, and usable on the server too.
|
|
107
|
-
|
|
108
|
-
|
|
109
67
|
if (spec.context_data) this.context_data = spec.context_data;
|
|
110
|
-
// deliver app specific css
|
|
111
|
-
// an obj
|
|
112
68
|
if (spec.css) this.css = spec.css;
|
|
113
69
|
|
|
114
70
|
// Not handling icons in the spec(yet). Now using load_icon_set.
|
|
@@ -156,6 +112,9 @@ class Single_Control_Server extends Server {
|
|
|
156
112
|
}
|
|
157
113
|
|
|
158
114
|
// 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?
|
|
159
118
|
|
|
160
119
|
'start' (callback) {
|
|
161
120
|
|
|
@@ -213,7 +172,7 @@ class Single_Control_Server extends Server {
|
|
|
213
172
|
|
|
214
173
|
|
|
215
174
|
|
|
216
|
-
console.log('js_client', js_client);
|
|
175
|
+
//console.log('js_client', js_client);
|
|
217
176
|
//throw 'stop';
|
|
218
177
|
|
|
219
178
|
js.serve_package('/js/app.js', js_client, o_serve_package, (err, served) => {
|