jsgui3-server 0.0.85 → 0.0.88
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/bundler/bundle.js +8 -0
- package/bundler/css-bundler.js +147 -5
- package/bundler/js-bundler.js +15 -1
- package/bundler/webpage-bundler.js +412 -164
- package/examples/square_box.js +6 -1
- package/examples/square_box_client.js +24 -2
- package/old/square_box.js +4 -0
- package/package.json +4 -4
- package/publishing/http-website-publisher.js +209 -64
- package/resources/jsbuilder/JS_AST/JS_AST_Node_6.0-Type.js +2 -0
- package/resources/jsbuilder/babel/babel_consts.js +14 -1
- package/resources/jsbuilder/babel/deep_iterate/deep_iterate_babel.js +254 -1
- package/resources/local-server-info-resource.js +28 -10
- package/server.js +24 -8
package/bundler/bundle.js
CHANGED
package/bundler/css-bundler.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const Bundler = require('./bundler');
|
|
2
2
|
const Bundle = require('./bundle');
|
|
3
3
|
const {obs, prom_or_cb} = require('fnl');
|
|
4
|
-
const {tof} = require('jsgui3-html');
|
|
4
|
+
const {tof, each} = require('jsgui3-html');
|
|
5
5
|
const fnlfs = require('fnlfs');
|
|
6
6
|
const browserify = require('browserify');
|
|
7
7
|
const babel = require('@babel/core');
|
|
@@ -10,6 +10,8 @@ const util = require('util');
|
|
|
10
10
|
const Stream = require('stream');
|
|
11
11
|
// Will put the JS together. Maybe images?
|
|
12
12
|
|
|
13
|
+
const JS_AST_Node = require('./../resources/jsbuilder/JS_AST/JS_AST_Node');
|
|
14
|
+
|
|
13
15
|
// Will put the JS together. Maybe images?
|
|
14
16
|
// Get everything ready to serve.
|
|
15
17
|
|
|
@@ -34,12 +36,152 @@ const Stream = require('stream');
|
|
|
34
36
|
|
|
35
37
|
|
|
36
38
|
|
|
37
|
-
const
|
|
39
|
+
const bundle_css_from_js_str = (js_str, options = {}) => {
|
|
40
|
+
|
|
41
|
+
console.log('js_str.length', js_str.length);
|
|
42
|
+
// Moving towards using observables as a matter of course for longer-running functions.
|
|
43
|
+
|
|
44
|
+
// Seems like this makes a settimeout as well???
|
|
45
|
+
return obs((next, complete, error) => {
|
|
46
|
+
|
|
47
|
+
console.log('js_str.length', js_str.length);
|
|
48
|
+
|
|
49
|
+
// Returning a Bundle object when done could be best...?
|
|
50
|
+
|
|
51
|
+
const spec = {
|
|
52
|
+
source: js_str
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const js_ast_node = JS_AST_Node.from_spec(spec);
|
|
56
|
+
|
|
57
|
+
console.log('!!js_ast_node', !!js_ast_node);
|
|
58
|
+
|
|
59
|
+
console.log('Object.keys(js_ast_node)', Object.keys(js_ast_node));
|
|
60
|
+
|
|
61
|
+
// count all
|
|
62
|
+
|
|
63
|
+
//console.log('js_ast_node.query("count all")', js_ast_node.query("count all"));
|
|
64
|
+
|
|
65
|
+
console.log('js_ast_node.query.count.all.exe()', js_ast_node.query.count.all.exe());
|
|
66
|
+
|
|
67
|
+
// A filter iterate query....? filter_deep_iterate could work.
|
|
68
|
+
// but we are looking specifically for 'ClassName.css'
|
|
69
|
+
// .css property assignments.
|
|
70
|
+
|
|
71
|
+
const ae_nodes = [];
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
// Just assigning a template literal to .css?
|
|
75
|
+
const css_ae_nodes = [];
|
|
76
|
+
|
|
77
|
+
js_ast_node.deep_iterate(node => {
|
|
78
|
+
//console.log('node', node);
|
|
79
|
+
//console.log('Object.keys(node)', Object.keys(node));
|
|
80
|
+
//console.log('node.type_signature', node.type_signature);
|
|
81
|
+
//console.log('node.signature', node.signature);
|
|
82
|
+
//console.log('node.type', node.type);
|
|
83
|
+
//console.log('node.abbreviated_type', node.abbreviated_type);
|
|
84
|
+
|
|
85
|
+
if (node.type === 'AssignmentExpression') {
|
|
86
|
+
//return true;
|
|
87
|
+
ae_nodes.push(node);
|
|
88
|
+
//console.log('node.source', node.source);
|
|
89
|
+
|
|
90
|
+
//console.log('Object.keys(node)', Object.keys(node));
|
|
91
|
+
|
|
92
|
+
//console.log('node.child_nodes.length', node.child_nodes.length);
|
|
93
|
+
|
|
94
|
+
const [node_assigned_to, node_assigned] = node.child_nodes;
|
|
95
|
+
//console.log('node_assigned_to.source', node_assigned_to.source);
|
|
96
|
+
//console.log('node_assigned_to.type', node_assigned_to.type);
|
|
97
|
+
//console.log('node_assigned.type', node_assigned.type);
|
|
98
|
+
|
|
99
|
+
if (node_assigned.type === 'TemplateLiteral') {
|
|
100
|
+
|
|
101
|
+
if (node_assigned_to.type === 'MemberExpression') {
|
|
102
|
+
|
|
103
|
+
//console.log('node_assigned_to', node_assigned_to);
|
|
104
|
+
|
|
105
|
+
// the last ID being .css?
|
|
106
|
+
const last_me_child = node_assigned_to.child_nodes[node_assigned_to.child_nodes.length - 1];
|
|
107
|
+
//console.log('last_me_child', last_me_child);
|
|
108
|
+
//console.log('last_me_child.source', last_me_child.source);
|
|
109
|
+
|
|
110
|
+
if (last_me_child.source === 'css') {
|
|
111
|
+
css_ae_nodes.push(node);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
// does it end '.css'?
|
|
117
|
+
// break it down further?
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
///console.log('node.source', node.source);
|
|
122
|
+
//throw 'stop';
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//console.log('');
|
|
127
|
+
// look at the left part...
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
//throw 'stop';
|
|
131
|
+
});
|
|
132
|
+
//console.log('ae_nodes', ae_nodes);
|
|
133
|
+
//console.log('ae_nodes.length', ae_nodes.length);
|
|
134
|
+
//console.log('css_ae_nodes.length', css_ae_nodes.length);
|
|
135
|
+
|
|
136
|
+
const arr_css = [];
|
|
137
|
+
|
|
138
|
+
if (css_ae_nodes.length > 0) {
|
|
139
|
+
//console.log('css_ae_nodes', css_ae_nodes);
|
|
140
|
+
|
|
141
|
+
each(css_ae_nodes, css_ae_node => {
|
|
142
|
+
//console.log('css_ae_node.source', css_ae_node.source);
|
|
143
|
+
const tl = css_ae_node.child_nodes[1].child_nodes[0];
|
|
144
|
+
//console.log('tl', tl);
|
|
145
|
+
console.log('tl.source', tl.source);
|
|
146
|
+
arr_css.push(tl.source);
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (arr_css.length > 0) {
|
|
153
|
+
const str_css = arr_css.join('\n');
|
|
154
|
+
|
|
155
|
+
complete(str_css);
|
|
156
|
+
} else {
|
|
157
|
+
complete();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
38
162
|
|
|
39
|
-
return obs(async (next, complete, error) => {
|
|
40
163
|
|
|
41
|
-
// Go through each file? Just the first?
|
|
42
164
|
|
|
165
|
+
// Can then do query to get all .css properties that are string templates.
|
|
166
|
+
// is it a property of a Class object?
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
// Need to get an AST from it....
|
|
173
|
+
// Or could simply search (regex?) for .css = `...`?
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
// Go through each file? Just the first?
|
|
179
|
+
|
|
180
|
+
// Or should the whole bundled (browserified) JS be consulted?
|
|
181
|
+
|
|
182
|
+
const [stop, pause, resume] = [() => {}, () => {}, () => {}];
|
|
183
|
+
return [stop, pause, resume];
|
|
184
|
+
|
|
43
185
|
});
|
|
44
186
|
|
|
45
187
|
}
|
|
@@ -52,5 +194,5 @@ class CSS_Bundler extends Bundler {
|
|
|
52
194
|
}
|
|
53
195
|
}
|
|
54
196
|
|
|
55
|
-
CSS_Bundler.
|
|
197
|
+
CSS_Bundler.bundle_css_from_js_str = bundle_css_from_js_str;
|
|
56
198
|
module.exports = CSS_Bundler;
|
package/bundler/js-bundler.js
CHANGED
|
@@ -80,6 +80,8 @@ const bundle_js = (js_file_path, options = {}, callback) => {
|
|
|
80
80
|
// are there any replacements to do?
|
|
81
81
|
// options.replacements
|
|
82
82
|
|
|
83
|
+
|
|
84
|
+
|
|
83
85
|
if (options.js_mode === 'debug') {
|
|
84
86
|
options.include_sourcemaps = true;
|
|
85
87
|
}
|
|
@@ -130,9 +132,22 @@ const bundle_js = (js_file_path, options = {}, callback) => {
|
|
|
130
132
|
let buf_js = Buffer.concat(buffers);
|
|
131
133
|
let str_js = buf_js.toString();
|
|
132
134
|
|
|
135
|
+
next({
|
|
136
|
+
'lang': 'JavaScript',
|
|
137
|
+
'operation': 'bundle',
|
|
138
|
+
'compress': false,
|
|
139
|
+
'type': 'single-string',
|
|
140
|
+
'value': str_js
|
|
141
|
+
});
|
|
142
|
+
|
|
133
143
|
// full browserified (client) js app.
|
|
134
144
|
|
|
135
145
|
let babel_option = options.babel
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
// could send str_js to a CSS extractor / bundler.
|
|
149
|
+
|
|
150
|
+
|
|
136
151
|
//console.log('babel_option', babel_option);
|
|
137
152
|
if (babel_option === 'es5') {
|
|
138
153
|
|
|
@@ -177,7 +192,6 @@ const bundle_js = (js_file_path, options = {}, callback) => {
|
|
|
177
192
|
//plugins: ["minify-dead-code-elimination"]
|
|
178
193
|
};
|
|
179
194
|
if (options.include_sourcemaps) o_transform.sourceMaps = 'inline';
|
|
180
|
-
|
|
181
195
|
let res_transform = babel.transform(str_js, o_transform);
|
|
182
196
|
buf_js = Buffer.from(res_transform.code);
|
|
183
197
|
} else {
|