jsgui3-server 0.0.99 → 0.0.100
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 +2 -1
- package/examples/controls/1) window/server.js +2 -1
- package/examples/controls/__old/_html-server-color-palette.js +2 -2
- package/package.json +2 -2
- package/publishers/helpers/preparers/static/bundle/Static_Routes_Responses_Webpage_Bundle_Preparer.js +7 -0
- package/publishers/http-webpage-publisher.js +3 -0
- package/publishers/http-webpageorsite-publisher.js +8 -1
- package/resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild.js +109 -49
- package/resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild.js +20 -8
- package/server.js +12 -0
|
@@ -83,7 +83,8 @@ if (require.main === module) {
|
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
//'js_mode': 'debug',
|
|
86
|
-
'src_path_client_js': require.resolve('./client.js')
|
|
86
|
+
'src_path_client_js': require.resolve('./client.js'),
|
|
87
|
+
debug: true // should not minify the js, should include the symbols.
|
|
87
88
|
//js_client: require.resolve('./square_box.js')
|
|
88
89
|
});
|
|
89
90
|
// A callback or event for when the bundling has been completed
|
|
@@ -17,9 +17,9 @@ var jsgui = require('jsgui3-html');
|
|
|
17
17
|
var Start_Stop_Toggle_Button = jsgui.Start_Stop_Toggle_Button;
|
|
18
18
|
var Color_Palette = jsgui.Color_Palette;
|
|
19
19
|
|
|
20
|
-
var Server = require('
|
|
20
|
+
var Server = require('../../../server');
|
|
21
21
|
var port = 8000;
|
|
22
|
-
var Server_Page_Context = require('
|
|
22
|
+
var Server_Page_Context = require('../../../page-context');
|
|
23
23
|
|
|
24
24
|
var server = new Server({
|
|
25
25
|
'routes': {
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
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.84",
|
|
18
18
|
"jsgui3-webpage": "^0.0.6",
|
|
19
19
|
"jsgui3-website": "^0.0.6",
|
|
20
20
|
"lang-tools": "^0.0.17",
|
|
@@ -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.100"
|
|
49
49
|
}
|
|
@@ -10,6 +10,13 @@ class Static_Routes_Responses_Webpage_Bundle_Preparer {
|
|
|
10
10
|
|
|
11
11
|
constructor(spec = {}) {
|
|
12
12
|
|
|
13
|
+
// Probably should be able to operate in debug mode.
|
|
14
|
+
// Not minifying the js, and including the js debug symbols / map as well.
|
|
15
|
+
|
|
16
|
+
// But something else prepares the bundle....
|
|
17
|
+
|
|
18
|
+
//if (spec.debug !== undefined) this.debug = spec.debug;
|
|
19
|
+
|
|
13
20
|
this.routes_assigner = new Single_Control_Webpage_Server_Static_Routes_Assigner();
|
|
14
21
|
|
|
15
22
|
// And the uncompressed response buffer(s) assigner....?
|
|
@@ -126,6 +126,9 @@ class HTTP_Webpage_Publisher extends HTTP_Webpageorsite_Publisher {
|
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
129
132
|
// But like the website publisher, this would need to bundle the page (JS, CSS, maybe more).
|
|
130
133
|
// Consider that an SPA may reference images. May not exactly be one page in some ways.
|
|
131
134
|
|
|
@@ -97,6 +97,8 @@ class HTTP_Webpageorsite_Publisher extends HTTP_Publisher {
|
|
|
97
97
|
constructor(spec) {
|
|
98
98
|
super(spec);
|
|
99
99
|
|
|
100
|
+
if (spec.debug !== undefined) this.debug = spec.debug;
|
|
101
|
+
|
|
100
102
|
// But then some properties to do with the js client(s?) file path.
|
|
101
103
|
|
|
102
104
|
// This should be fairly simple in terms of making use of the bundler, then providing the server (maybe the router component)
|
|
@@ -124,7 +126,9 @@ class HTTP_Webpageorsite_Publisher extends HTTP_Publisher {
|
|
|
124
126
|
|
|
125
127
|
// Maybe need a get_ready (async or obs) function....
|
|
126
128
|
|
|
127
|
-
this.js_bundler = new JS_Bundler(
|
|
129
|
+
this.js_bundler = new JS_Bundler({
|
|
130
|
+
'debug': this.debug || false
|
|
131
|
+
});
|
|
128
132
|
|
|
129
133
|
|
|
130
134
|
}
|
|
@@ -156,6 +160,9 @@ class HTTP_Webpageorsite_Publisher extends HTTP_Publisher {
|
|
|
156
160
|
|
|
157
161
|
//console.log('src_path_client_js', src_path_client_js);
|
|
158
162
|
|
|
163
|
+
|
|
164
|
+
// The js_bundler may need to operate in 'debug' mode.
|
|
165
|
+
|
|
159
166
|
const js_bundler_res = await js_bundler.bundle(src_path_client_js);
|
|
160
167
|
// Should also get the CSS from it....
|
|
161
168
|
|
|
@@ -21,12 +21,20 @@ class Advanced_JS_Bundler_Using_ESBuild extends Bundler_Using_ESBuild {
|
|
|
21
21
|
constructor(spec) {
|
|
22
22
|
super(spec);
|
|
23
23
|
|
|
24
|
+
if (spec.debug !== undefined) this.debug = spec.debug;
|
|
25
|
+
|
|
24
26
|
//this.css_extractor = new CSS_Extractor();
|
|
25
27
|
|
|
26
28
|
|
|
27
|
-
this.non_minifying_bundler = new Core_JS_Non_Minifying_Bundler_Using_ESBuild(
|
|
29
|
+
this.non_minifying_bundler = new Core_JS_Non_Minifying_Bundler_Using_ESBuild({
|
|
30
|
+
debug: this.debug
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
|
|
28
34
|
this.css_and_js_from_js_string_extractor = new CSS_And_JS_From_JS_String_Extractor();
|
|
29
35
|
|
|
36
|
+
|
|
37
|
+
// Probably don't use that minifying bundler in debug mode.
|
|
30
38
|
this.minifying_js_single_file_bundler = new Core_JS_Single_File_Minifying_Bundler_Using_ESBuild();
|
|
31
39
|
|
|
32
40
|
}
|
|
@@ -59,132 +67,184 @@ class Advanced_JS_Bundler_Using_ESBuild extends Bundler_Using_ESBuild {
|
|
|
59
67
|
//console.log('bundle_item', bundle_item);
|
|
60
68
|
|
|
61
69
|
if (bundle_item.type === 'JavaScript') {
|
|
70
|
+
|
|
71
|
+
// But in debug mode don't minify it.
|
|
72
|
+
// Maybe create and add the sourcemap here instead....?
|
|
73
|
+
|
|
62
74
|
const {text} = bundle_item;
|
|
63
75
|
// Then use the css and js from js extractor.
|
|
64
76
|
|
|
65
77
|
const res_extract_css_and_js_from_js = await css_and_js_from_js_string_extractor.extract(text);
|
|
78
|
+
const {css, js} = res_extract_css_and_js_from_js;
|
|
66
79
|
|
|
80
|
+
if (this.debug) {
|
|
67
81
|
|
|
68
|
-
|
|
82
|
+
// sourcemap: 'inline'
|
|
69
83
|
|
|
70
|
-
|
|
84
|
+
// Don't minify the js.
|
|
71
85
|
|
|
72
|
-
|
|
73
|
-
//console.log('minified_js.length', minified_js.length);
|
|
86
|
+
// Make res bundle items that include the CSS and the non-minified JS.
|
|
74
87
|
|
|
75
|
-
|
|
88
|
+
// Including the source map would be better still.
|
|
76
89
|
|
|
77
|
-
|
|
90
|
+
const res_bundle = new Bundle();
|
|
91
|
+
// Add the non-minified JS (as a bundle item object)
|
|
78
92
|
|
|
79
|
-
|
|
93
|
+
const o_js_bundle_item = {
|
|
94
|
+
type: 'JavaScript',
|
|
95
|
+
extension: 'JS',
|
|
96
|
+
text: js
|
|
97
|
+
}
|
|
98
|
+
res_bundle.add(o_js_bundle_item);
|
|
99
|
+
const o_css_bundle_item = {
|
|
100
|
+
type: 'CSS',
|
|
101
|
+
extension: 'css',
|
|
102
|
+
text: css
|
|
103
|
+
}
|
|
80
104
|
|
|
105
|
+
res_bundle.push(o_css_bundle_item);
|
|
106
|
+
next(res_bundle);
|
|
107
|
+
complete(res_bundle);
|
|
81
108
|
|
|
82
|
-
// Should put it all in a single res bundle though....
|
|
83
|
-
// Though merging / concating bundles will be fine too.
|
|
84
109
|
|
|
85
110
|
|
|
86
111
|
|
|
87
|
-
const minified_js_bundle_collection = minified_js[0];
|
|
88
112
|
|
|
89
|
-
|
|
90
113
|
|
|
91
|
-
const o_css_bundle_item = {
|
|
92
|
-
type: 'CSS',
|
|
93
|
-
extension: 'css',
|
|
94
|
-
text: css
|
|
95
|
-
}
|
|
96
114
|
|
|
97
|
-
minified_js_bundle_collection.push(o_css_bundle_item);
|
|
98
115
|
|
|
116
|
+
} else {
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
const minified_js = await minifying_js_single_file_bundler.bundle(js);
|
|
99
120
|
|
|
100
|
-
|
|
121
|
+
//console.log('minified_js', minified_js);
|
|
122
|
+
//console.log('minified_js.length', minified_js.length);
|
|
101
123
|
|
|
124
|
+
// it's an array....
|
|
102
125
|
|
|
126
|
+
if (is_array(minified_js)) {
|
|
103
127
|
|
|
104
|
-
|
|
128
|
+
if (minified_js.length === 1) {
|
|
105
129
|
|
|
106
130
|
|
|
131
|
+
// Should put it all in a single res bundle though....
|
|
132
|
+
// Though merging / concating bundles will be fine too.
|
|
107
133
|
|
|
108
|
-
next(minified_js_bundle_collection);
|
|
109
134
|
|
|
110
|
-
// But create a CSS bundle item...
|
|
111
135
|
|
|
136
|
+
const minified_js_bundle_collection = minified_js[0];
|
|
112
137
|
|
|
138
|
+
|
|
113
139
|
|
|
140
|
+
const o_css_bundle_item = {
|
|
141
|
+
type: 'CSS',
|
|
142
|
+
extension: 'css',
|
|
143
|
+
text: css
|
|
144
|
+
}
|
|
114
145
|
|
|
146
|
+
minified_js_bundle_collection.push(o_css_bundle_item);
|
|
115
147
|
|
|
116
|
-
// And also the CSS...
|
|
117
148
|
|
|
149
|
+
// Maybe will provide the class / class instance that processes CSS or SASS/SCSS / whatever else.
|
|
118
150
|
|
|
119
151
|
|
|
120
152
|
|
|
153
|
+
// Could add the extracted CSS here.
|
|
121
154
|
|
|
122
|
-
complete(minified_js_bundle_collection);
|
|
123
155
|
|
|
124
156
|
|
|
157
|
+
next(minified_js_bundle_collection);
|
|
125
158
|
|
|
126
|
-
|
|
127
|
-
if (minified_js_bundle_collection._arr) {
|
|
159
|
+
// But create a CSS bundle item...
|
|
128
160
|
|
|
129
|
-
if (minified_js_bundle_collection._arr.length === 1) {
|
|
130
161
|
|
|
131
|
-
const minified_js_bundle_item = minified_js_bundle_collection._arr[0];
|
|
132
|
-
console.log('minified_js_bundle_item', minified_js_bundle_item);
|
|
133
162
|
|
|
134
163
|
|
|
135
|
-
if (minified_js_bundle_item.type === 'JavaScript') {
|
|
136
164
|
|
|
137
|
-
|
|
165
|
+
// And also the CSS...
|
|
138
166
|
|
|
139
|
-
//const res =
|
|
140
167
|
|
|
141
168
|
|
|
142
169
|
|
|
143
170
|
|
|
171
|
+
complete(minified_js_bundle_collection);
|
|
144
172
|
|
|
145
|
-
} else {
|
|
146
173
|
|
|
147
|
-
console.trace();
|
|
148
|
-
throw 'NYI';
|
|
149
174
|
|
|
150
|
-
|
|
175
|
+
const unneeded_looking_into_the_js_bundle = () => {
|
|
176
|
+
if (minified_js_bundle_collection._arr) {
|
|
177
|
+
|
|
178
|
+
if (minified_js_bundle_collection._arr.length === 1) {
|
|
179
|
+
|
|
180
|
+
const minified_js_bundle_item = minified_js_bundle_collection._arr[0];
|
|
181
|
+
console.log('minified_js_bundle_item', minified_js_bundle_item);
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
if (minified_js_bundle_item.type === 'JavaScript') {
|
|
185
|
+
|
|
186
|
+
//const str_minified_js = minified_js_bundle_item.text;
|
|
187
|
+
|
|
188
|
+
//const res =
|
|
151
189
|
|
|
152
190
|
|
|
153
|
-
// Could even check it's js here...?
|
|
154
191
|
|
|
155
192
|
|
|
156
|
-
console.trace();
|
|
157
|
-
throw 'NYI';
|
|
158
193
|
|
|
194
|
+
} else {
|
|
195
|
+
|
|
196
|
+
console.trace();
|
|
197
|
+
throw 'NYI';
|
|
198
|
+
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
// Could even check it's js here...?
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
console.trace();
|
|
206
|
+
throw 'NYI';
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
} else {
|
|
210
|
+
console.trace();
|
|
211
|
+
throw 'NYI';
|
|
212
|
+
}
|
|
159
213
|
|
|
160
214
|
} else {
|
|
215
|
+
|
|
161
216
|
console.trace();
|
|
162
217
|
throw 'NYI';
|
|
163
|
-
}
|
|
164
218
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
console.trace();
|
|
168
|
-
throw 'NYI';
|
|
219
|
+
}
|
|
169
220
|
|
|
170
221
|
}
|
|
171
222
|
|
|
172
|
-
|
|
223
|
+
|
|
173
224
|
|
|
174
|
-
|
|
225
|
+
} else {
|
|
226
|
+
console.trace();
|
|
227
|
+
throw 'stop';
|
|
228
|
+
}
|
|
175
229
|
|
|
176
230
|
} else {
|
|
231
|
+
|
|
177
232
|
console.trace();
|
|
178
233
|
throw 'stop';
|
|
179
234
|
}
|
|
180
235
|
|
|
181
|
-
} else {
|
|
182
236
|
|
|
183
|
-
console.trace();
|
|
184
|
-
throw 'stop';
|
|
185
237
|
}
|
|
186
238
|
|
|
187
239
|
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
188
248
|
|
|
189
249
|
//console.trace();
|
|
190
250
|
//throw 'stop';
|
package/resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild.js
CHANGED
|
@@ -16,6 +16,10 @@ const Bundler_Using_ESBuild = require('./Bundler_Using_ESBuild');
|
|
|
16
16
|
class Core_JS_Non_Minifying_Bundler_Using_ESBuild extends Bundler_Using_ESBuild {
|
|
17
17
|
constructor(spec) {
|
|
18
18
|
super(spec);
|
|
19
|
+
|
|
20
|
+
if (spec.debug !== undefined) this.debug = spec.debug;
|
|
21
|
+
|
|
22
|
+
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
// And the options....
|
|
@@ -47,7 +51,7 @@ class Core_JS_Non_Minifying_Bundler_Using_ESBuild extends Bundler_Using_ESBuild
|
|
|
47
51
|
|
|
48
52
|
// Looks like we need better linking build options....
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
const o_build = {
|
|
51
55
|
entryPoints: [js_file_path],
|
|
52
56
|
bundle: true,
|
|
53
57
|
|
|
@@ -59,23 +63,31 @@ class Core_JS_Non_Minifying_Bundler_Using_ESBuild extends Bundler_Using_ESBuild
|
|
|
59
63
|
//sourcemap: 'external',
|
|
60
64
|
write: false,
|
|
61
65
|
outdir: 'out',
|
|
62
|
-
})
|
|
63
|
-
console.log('result.outputFiles:\n\n');
|
|
64
|
-
for (let out of result.outputFiles) {
|
|
65
|
-
//console.log('out.path, out.contents, out.hash, out.text', out.path, out.contents, out.hash, out.text)
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
if (this.debug) {
|
|
69
|
+
o_build.sourcemap = 'inline';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
let result = await esbuild.build(o_build);
|
|
75
|
+
//console.log('result.outputFiles:\n\n');
|
|
76
|
+
//for (let out of result.outputFiles) {
|
|
77
|
+
//console.log('out.path, out.contents, out.hash, out.text', out.path, out.contents, out.hash, out.text)
|
|
78
|
+
//}
|
|
79
|
+
|
|
80
|
+
//console.log('result.outputFiles.length', result.outputFiles.length);
|
|
69
81
|
|
|
70
82
|
|
|
71
83
|
if (result.outputFiles.length === 1) {
|
|
72
84
|
|
|
73
85
|
const output_file = result.outputFiles[0];
|
|
74
86
|
|
|
75
|
-
console.log('output_file.text.length', output_file.text.length);
|
|
87
|
+
//console.log('output_file.text.length', output_file.text.length);
|
|
76
88
|
//console.log('output_file.text', output_file.text);
|
|
77
89
|
|
|
78
|
-
console.log('Object.keys(output_file)', Object.keys(output_file));
|
|
90
|
+
//console.log('Object.keys(output_file)', Object.keys(output_file));
|
|
79
91
|
|
|
80
92
|
// The Bundle is a subclass of Collection.
|
|
81
93
|
// Maybe its better to make it an Object class that assigns all properties from spec.
|
package/server.js
CHANGED
|
@@ -50,6 +50,11 @@ class JSGUI_Single_Process_Server extends Evented_Class {
|
|
|
50
50
|
disk_path_client_js = spec.source_path_client_js;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
|
|
54
|
+
if (spec.debug !== undefined) {
|
|
55
|
+
this.debug = spec.debug;
|
|
56
|
+
}
|
|
57
|
+
|
|
53
58
|
// or src_path_client_js as well...
|
|
54
59
|
|
|
55
60
|
Object.defineProperty(this, 'disk_path_client_js', {get: () => disk_path_client_js, set: (value) => disk_path_client_js = value});
|
|
@@ -166,12 +171,19 @@ class JSGUI_Single_Process_Server extends Evented_Class {
|
|
|
166
171
|
|
|
167
172
|
};
|
|
168
173
|
|
|
174
|
+
if (this.debug) {
|
|
175
|
+
opts_wp_publisher.debug = this.debug;
|
|
176
|
+
}
|
|
177
|
+
|
|
169
178
|
if (disk_path_client_js) opts_wp_publisher.src_path_client_js = disk_path_client_js;
|
|
170
179
|
|
|
171
180
|
|
|
172
181
|
|
|
173
182
|
// HTTP_Webpage_Publisher probably needs to build the JavaScript. Possibly other assets too.
|
|
174
183
|
const wp_publisher = new HTTP_Webpage_Publisher(opts_wp_publisher);
|
|
184
|
+
// Specific options for when that publisher is in debug mode.
|
|
185
|
+
|
|
186
|
+
|
|
175
187
|
console.log('waiting for wp_publisher ready');
|
|
176
188
|
|
|
177
189
|
// Server can (maybe just in theory) serve multiple websites at once.
|