jsgui3-server 0.0.75 → 0.0.77

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.
Files changed (158) hide show
  1. package/examples/client-side-popup-menu-button.html +93 -93
  2. package/examples/controls/_html-server-color-palette.js +114 -114
  3. package/examples/controls/html-server-combo-box.js +104 -104
  4. package/examples/controls/html-server-list.js +98 -98
  5. package/examples/controls/html-server-popup-menu-button.js +114 -114
  6. package/examples/controls/html-server-start-stop-toggle-button.js +146 -146
  7. package/examples/controls/scs-arrow-button.js +36 -36
  8. package/examples/controls/scs-date-picker.js +157 -157
  9. package/examples/controls/scs-file-browser.js +82 -82
  10. package/examples/controls/scs-item.js +159 -159
  11. package/examples/controls/scs-month-arrow-selector.js +126 -126
  12. package/examples/controls/scs-month-view.js +95 -95
  13. package/examples/controls/scs-start-stop-toggle-button.js +40 -40
  14. package/examples/controls/scs-tree.js +49 -49
  15. package/examples/controls/scs-year-arrow-selector.js +127 -127
  16. package/examples/demos/date-picker.js +119 -119
  17. package/examples/demos/explain-encapsulation.js +9 -9
  18. package/examples/demos/resizing.js +35 -35
  19. package/examples/demos/server_time.js +6 -6
  20. package/examples/demos/square_box.js +324 -324
  21. package/examples/html-rendering.js +20 -20
  22. package/examples/html-server.js +100 -100
  23. package/fs2.js +1836 -1836
  24. package/module.js +21 -21
  25. package/old/single-control-server.js +418 -418
  26. package/package.json +44 -42
  27. package/publishing/function-publisher.js +202 -202
  28. package/publishing/notes.md +5 -5
  29. package/publishing/observable-publisher.js +118 -118
  30. package/publishing/resource-publisher.js +306 -306
  31. package/resources/data-resource.js +104 -104
  32. package/resources/fs-resource.js +148 -148
  33. package/resources/jsbuilder/Abstract_Single_Declaration.js +105 -0
  34. package/resources/jsbuilder/Abstract_Single_Declaration_Sequence.js +43 -0
  35. package/resources/jsbuilder/JS_AST/JS_AST_Abstract_Node.js +62 -0
  36. package/resources/jsbuilder/JS_AST/JS_AST_Abstract_Node_Group.js +42 -0
  37. package/resources/jsbuilder/JS_AST/JS_AST_Group_Shared.js +62 -0
  38. package/resources/jsbuilder/JS_AST/JS_AST_Node.js +94 -0
  39. package/resources/jsbuilder/JS_AST/JS_AST_Node_0-Core.js +228 -0
  40. package/resources/jsbuilder/JS_AST/JS_AST_Node_1-Babel.js +338 -0
  41. package/resources/jsbuilder/JS_AST/JS_AST_Node_10-Changing.js +40 -0
  42. package/resources/jsbuilder/JS_AST/JS_AST_Node_2.1.1-Child.js +97 -0
  43. package/resources/jsbuilder/JS_AST/JS_AST_Node_2.1.2-Parent.js +38 -0
  44. package/resources/jsbuilder/JS_AST/JS_AST_Node_2.1.3-Ancestor.js +62 -0
  45. package/resources/jsbuilder/JS_AST/JS_AST_Node_2.2-Inner.js +44 -0
  46. package/resources/jsbuilder/JS_AST/JS_AST_Node_2.3-All.js +73 -0
  47. package/resources/jsbuilder/JS_AST/JS_AST_Node_2.4-Sibling.js +93 -0
  48. package/resources/jsbuilder/JS_AST/JS_AST_Node_2.5-Available_In_Scope.js +29 -0
  49. package/resources/jsbuilder/JS_AST/JS_AST_Node_2.9-Signature.js +116 -0
  50. package/resources/jsbuilder/JS_AST/JS_AST_Node_3-Basics.js +160 -0
  51. package/resources/jsbuilder/JS_AST/JS_AST_Node_3.0.0-Basics_First.js +179 -0
  52. package/resources/jsbuilder/JS_AST/JS_AST_Node_3.0.1-Basics_Second.js +88 -0
  53. package/resources/jsbuilder/JS_AST/JS_AST_Node_3.0.99-Basics_Last.js +92 -0
  54. package/resources/jsbuilder/JS_AST/JS_AST_Node_3.1-Basics_Each.js +137 -0
  55. package/resources/jsbuilder/JS_AST/JS_AST_Node_3.1.5-Basics_Count.js +74 -0
  56. package/resources/jsbuilder/JS_AST/JS_AST_Node_3.2-Basics_Filter.js +40 -0
  57. package/resources/jsbuilder/JS_AST/JS_AST_Node_3.3-Basics_Collect.js +86 -0
  58. package/resources/jsbuilder/JS_AST/JS_AST_Node_3.4-Basics_Select.js +43 -0
  59. package/resources/jsbuilder/JS_AST/JS_AST_Node_3.5-Basics_Find.js +41 -0
  60. package/resources/jsbuilder/JS_AST/JS_AST_Node_3.6-Basics_Callmap.js +55 -0
  61. package/resources/jsbuilder/JS_AST/JS_AST_Node_4.0-Index_Indexes.js +46 -0
  62. package/resources/jsbuilder/JS_AST/JS_AST_Node_4.1-Index.js +344 -0
  63. package/resources/jsbuilder/JS_AST/JS_AST_Node_5.0-Category.js +39 -0
  64. package/resources/jsbuilder/JS_AST/JS_AST_Node_5.1-Category_Identifier.js +31 -0
  65. package/resources/jsbuilder/JS_AST/JS_AST_Node_5.2-Category_Literal.js +29 -0
  66. package/resources/jsbuilder/JS_AST/JS_AST_Node_5.3-Category_Expression.js +27 -0
  67. package/resources/jsbuilder/JS_AST/JS_AST_Node_5.4-Category_Pattern.js +9 -0
  68. package/resources/jsbuilder/JS_AST/JS_AST_Node_5.5-Category_Declaration.js +44 -0
  69. package/resources/jsbuilder/JS_AST/JS_AST_Node_5.6-Category_Statement.js +22 -0
  70. package/resources/jsbuilder/JS_AST/JS_AST_Node_6.0-Type.js +87 -0
  71. package/resources/jsbuilder/JS_AST/JS_AST_Node_6.1-Type_Class_Declaration.js +9 -0
  72. package/resources/jsbuilder/JS_AST/JS_AST_Node_6.2-Type_Variable_Declaration.js +28 -0
  73. package/resources/jsbuilder/JS_AST/JS_AST_Node_6.3-Type_Variable_Declarator.js +29 -0
  74. package/resources/jsbuilder/JS_AST/JS_AST_Node_7-Query.js +737 -0
  75. package/resources/jsbuilder/JS_AST/JS_AST_Node_8-Features.js +65 -0
  76. package/resources/jsbuilder/JS_AST/JS_AST_Node_9-Planning.js +32 -0
  77. package/resources/jsbuilder/JS_AST/JS_AST_Node_Arrangement.js +15 -0
  78. package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Node_Declared_Object.js +306 -0
  79. package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Node_Feature.js +78 -0
  80. package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Node_Feature_Declaration.js +249 -0
  81. package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Node_Feature_Declarator.js +139 -0
  82. package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/JS_AST_Root_Node_Feature.js +10 -0
  83. package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/JS_AST_Root_Node_Feature_Exported.js +101 -0
  84. package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/JS_AST_Root_Node_Feature_Exports.js +61 -0
  85. package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/JS_AST_Root_Node_Interpreted.js +180 -0
  86. package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/_JSGUI_Root_Node_Interpreted.js +43 -0
  87. package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/special_case_objectassign_to_object.js +12 -0
  88. package/resources/jsbuilder/JS_AST/JS_AST_Node_Group.js +35 -0
  89. package/resources/jsbuilder/JS_AST/JS_AST_Operation.js +11 -0
  90. package/resources/jsbuilder/JS_AST/JS_AST_Operation_On_Relationship.js +32 -0
  91. package/resources/jsbuilder/JS_AST/JS_AST_Ordered_Relationship_Node_To_Group.js +38 -0
  92. package/resources/jsbuilder/JS_AST/JS_AST_Ordinal.js +40 -0
  93. package/resources/jsbuilder/JS_AST/JS_AST_Ordinal_Relationship.js +25 -0
  94. package/resources/jsbuilder/JS_AST/JS_AST_Relationship_Node_To_Group.js +201 -0
  95. package/resources/jsbuilder/JS_AST/JS_AST_Relationship_Node_Within_Group_To_Node.js +44 -0
  96. package/resources/jsbuilder/JS_AST/_JS_AST_Node_3.8-Query_Features.js +77 -0
  97. package/resources/jsbuilder/JS_AST/query/all.js +0 -0
  98. package/resources/jsbuilder/JS_AST/query/enable_array_as_queryable.js +228 -0
  99. package/resources/jsbuilder/JS_AST/query/find_object_keys.js +405 -0
  100. package/resources/jsbuilder/JS_AST/query/node_queries.js +9 -0
  101. package/resources/jsbuilder/JS_AST/query/root_queries.js +0 -0
  102. package/resources/jsbuilder/JS_AST/query/root_query_identidy.js +12 -0
  103. package/resources/jsbuilder/JS_AST_Node_Extended/JSGUI_Singular_Declaration.js +86 -0
  104. package/resources/jsbuilder/JS_AST_Node_Extended/JS_AST_Node_Declaration.js +124 -0
  105. package/resources/jsbuilder/JS_AST_Node_Extended/JS_AST_Node_Extended.js +88 -0
  106. package/resources/jsbuilder/JS_AST_Node_Extended/JS_AST_Node_Extended_0-Core.js +11 -0
  107. package/resources/jsbuilder/JS_Builder.js +10 -36
  108. package/resources/jsbuilder/JS_File/Feature/JS_File_Declared_Object.js +32 -0
  109. package/resources/jsbuilder/JS_File/Feature/JS_File_Exported_Object_Info.js +26 -0
  110. package/resources/jsbuilder/JS_File/Feature/JS_File_Exports.js +79 -0
  111. package/resources/jsbuilder/JS_File/Feature/JS_File_Feature.js +18 -0
  112. package/resources/jsbuilder/JS_File/Feature/JS_File_Imported_Object_Info.js +26 -0
  113. package/resources/jsbuilder/JS_File/Feature/JS_File_Imports.js +9 -0
  114. package/resources/jsbuilder/JS_File/JS_File.js +12 -0
  115. package/resources/jsbuilder/JS_File/JS_File_0-Core.js +202 -0
  116. package/resources/jsbuilder/JS_File/JS_File_1-Early_Parse.js +175 -0
  117. package/resources/jsbuilder/JS_File/JS_File_2-Babel.js +81 -0
  118. package/resources/jsbuilder/JS_File/JS_File_3-JS_AST_Node.js +86 -0
  119. package/resources/jsbuilder/JS_File/JS_File_4-Query.js +414 -0
  120. package/resources/jsbuilder/JS_File/JS_File_4.1-Query_Features.js +415 -0
  121. package/resources/jsbuilder/JS_File/JS_File_5-Planning.js +59 -0
  122. package/resources/jsbuilder/JS_File/JS_File_6-Changing.js +24 -0
  123. package/resources/jsbuilder/JS_File/JS_File_Export_Reference.js +12 -0
  124. package/resources/jsbuilder/JS_File/JS_File_Import_Reference.js +24 -0
  125. package/resources/jsbuilder/JS_File/JS_File_Import_References.js +32 -0
  126. package/resources/jsbuilder/JS_File/JS_File_Processor.js +16 -0
  127. package/resources/jsbuilder/JS_File/JS_Files.js +16 -0
  128. package/resources/jsbuilder/Module.js +14 -0
  129. package/resources/jsbuilder/Platform.js +13 -53
  130. package/resources/jsbuilder/Platforms.js +69 -15
  131. package/resources/jsbuilder/Project.js +109 -0
  132. package/resources/jsbuilder/Reference.js +1 -1
  133. package/resources/jsbuilder/Reference_Sequence.js +16 -7
  134. package/resources/jsbuilder/Scope.js +30 -0
  135. package/resources/jsbuilder/Variable_Name_Provider.js +43 -0
  136. package/resources/jsbuilder/_JS_File.js +226 -0
  137. package/resources/jsbuilder/ast_query.js +21 -0
  138. package/resources/jsbuilder/babel/babel_consts.js +150 -0
  139. package/resources/jsbuilder/babel/babel_node_tools.js +542 -0
  140. package/resources/jsbuilder/babel/deep_iterate/deep_iterate_babel.js +604 -0
  141. package/resources/jsbuilder/build.js +16 -0
  142. package/resources/jsbuilder/platform_notes.md +66 -0
  143. package/resources/jsbuilder/test/test_ast_node.js +451 -0
  144. package/resources/jsbuilder/test/test_js_file.js +303 -11
  145. package/resources/jsbuilder/test/test_project.js +157 -0
  146. package/resources/local-server-info-resource.js +78 -78
  147. package/resources/process-js.js +537 -537
  148. package/resources/server-resource-pool.js +84 -84
  149. package/resources/website-css-resource.js +411 -411
  150. package/resources/website-javascript-resource.js +761 -751
  151. package/resources/website-resource.js +390 -390
  152. package/resources/website-static-html-resource.js +196 -196
  153. package/server.js +170 -170
  154. package/single-control-server.js +398 -398
  155. package/single-page-app.js +129 -129
  156. package/resources/jsbuilder/Declaration.js +0 -15
  157. package/resources/jsbuilder/Declaration_Sequence.js +0 -15
  158. package/resources/jsbuilder/JS_File.js +0 -77
@@ -0,0 +1,415 @@
1
+ const {each, tof} = require('lang-mini');
2
+ const JS_File_Query = require('./JS_File_4-Query');
3
+
4
+ const JS_File_Import_References = require('./JS_File_Import_References');
5
+
6
+ const JS_File_Exports = require('./Feature/JS_File_Exports');
7
+ const JS_AST_Node_Declared_Object = require('../JS_AST/JS_AST_Node_Feature/JS_AST_Node_Declared_Object');
8
+ //const { default: JS_File_JS_AST_Node } = require('./JS_File_2-JS_AST_Node');
9
+ //const { default: Import_References } = require('./JS_File_Import_References');
10
+ // Will extract relevant AST code functionality. Files often import things at the beginning, then have declarations, then export what was declared at the end.
11
+
12
+ // Understanding the import declarations so they could be localised.
13
+ // So we can refer to the ast of them, because we have recognised them elsewhere.
14
+
15
+ // Can build the functions into a js file.
16
+ // Later on - renaming local variables within a scope.
17
+
18
+ // JS_File_Writable too...
19
+ // .imports = ... or requires
20
+ // .add_platform?
21
+
22
+ // Or better to create the platform objects out of the functions which have been comprehended from various files.
23
+ // JS_File_Platform?
24
+ // This will be more about understanding the js file. Basic structure will have already been obtained.
25
+
26
+ // Maybe a Babel level below?
27
+
28
+ const log = console.log;
29
+ //const log = () => [];
30
+
31
+ class JS_File_Query_Features extends JS_File_Query {
32
+ constructor(spec) {
33
+ super(spec);
34
+
35
+
36
+ // Not going to use .features for the moment.
37
+ // Will have more properties added to the root node that get the things we are likely looking for.
38
+
39
+
40
+
41
+
42
+
43
+ const made_obselete = () => {
44
+
45
+
46
+ const features = {}; // external interface
47
+ const map_arr_features_by_name = {};
48
+
49
+ // Querying features on a file level
50
+
51
+ // Number of imported variables
52
+ // Number of exported variables
53
+ // If it uses module.exports to do this
54
+ // the module.exports statement
55
+ // Number of declarations in the root of the document.
56
+
57
+ // Names of these variables
58
+ // Each of the variables within a JSGUI_Single_Declaration abstraction.
59
+
60
+
61
+ // Queries specific to a type....
62
+
63
+ // root_defined_names
64
+
65
+ // the export feature.
66
+ // Maybe make a 'feature' object. Won't necessarily correspond with specific syntax.
67
+
68
+ // an exports property
69
+
70
+ //let feature_export;
71
+ //let arr_features_declared_object = [];
72
+
73
+ const get_declared_object_features = () => {
74
+ //log('get_declared_object_features');
75
+ const res = [];
76
+
77
+ //console.log('this.body.each', this.body.each);
78
+ //console.log('this.body.each.child', this.body.each.child);
79
+
80
+ this.body.each.child.declaration(node_dec => {
81
+ //log('');
82
+ //log('node_dec', node_dec);
83
+ //log('node_dec.source', node_dec.source);
84
+
85
+ // then get the array of features from each declaration.
86
+
87
+ const node_declared_object_features = JS_AST_Node_Declared_Object.arr_from_js_ast_node(node_dec);
88
+ //log('node_declared_object_features.length', node_declared_object_features.length);
89
+ each(node_declared_object_features, x => res.push(x));
90
+
91
+ })
92
+
93
+ //throw 'stop';
94
+ return res;
95
+
96
+ }
97
+
98
+ const get_feature_export = () => {
99
+ //let res;
100
+
101
+ log('this.body.type', this.body.type);
102
+
103
+ const get_exports_statement = () => {
104
+ let res_inner;
105
+
106
+ this.body.each.child.expression_statement(child_es => {
107
+ //log('child_es', child_es);
108
+ //log('child_es.source', child_es.source);
109
+
110
+ const ase = child_es.child_nodes[0];
111
+ if (ase.t === 'AsE') {
112
+ if (ase.child_nodes.length === 2) {
113
+ const me = ase.child_nodes[0];
114
+ if (me.t === 'ME') {
115
+ // then 2 ids.
116
+
117
+ if (me.child_nodes.length === 0);
118
+ const names = [me.child_nodes[0].name, me.child_nodes[1].name];
119
+
120
+ if (names[0] === 'module' && names[1] === 'exports') {
121
+ res_inner = child_es;
122
+ }
123
+ //log('names', names);
124
+ }
125
+ }
126
+ }
127
+ //
128
+ })
129
+ return res_inner;
130
+ }
131
+
132
+
133
+ const exports_statement = get_exports_statement();
134
+ log('get_feature_export exports_statement', exports_statement);
135
+
136
+ const res = new JS_File_Exports({
137
+ ast_node_exports_statement: exports_statement
138
+ });
139
+ // Can return undefined.
140
+
141
+ return res;
142
+ }
143
+
144
+ Object.defineProperty(this, 'features', {
145
+ // Using shorthand method names (ES2015 feature).
146
+ // This is equivalent to:
147
+ // get: function() { return bValue; },
148
+ // set: function(newValue) { bValue = newValue; },
149
+
150
+
151
+ get() {
152
+ return features;
153
+ },
154
+ //set(newValue) { bValue = newValue; },
155
+ enumerable: true,
156
+ configurable: false
157
+ });
158
+ // get_declared_object_features
159
+
160
+ Object.defineProperty(features, 'declared_objects', {
161
+ // Using shorthand method names (ES2015 feature).
162
+ // This is equivalent to:
163
+ // get: function() { return bValue; },
164
+ // set: function(newValue) { bValue = newValue; },
165
+
166
+
167
+ get() {
168
+ if (!map_arr_features_by_name['declared_objects']) {
169
+ map_arr_features_by_name['declared_objects'] = get_declared_object_features();
170
+ }
171
+ return map_arr_features_by_name['declared_objects'];
172
+ //return features;
173
+ },
174
+ //set(newValue) { bValue = newValue; },
175
+ enumerable: true,
176
+ configurable: false
177
+ });
178
+
179
+ // features
180
+
181
+ Object.defineProperty(features, 'export', {
182
+ // Using shorthand method names (ES2015 feature).
183
+ // This is equivalent to:
184
+ // get: function() { return bValue; },
185
+ // set: function(newValue) { bValue = newValue; },
186
+
187
+
188
+ get() {
189
+ if (!map_arr_features_by_name['export']) {
190
+ map_arr_features_by_name['export'] = get_feature_export();
191
+ }
192
+ return map_arr_features_by_name['export'];
193
+ //return features;
194
+ },
195
+ //set(newValue) { bValue = newValue; },
196
+ enumerable: true,
197
+ configurable: false
198
+ });
199
+
200
+ let _exported;
201
+ let _exported_keys;
202
+
203
+ const that = this;
204
+
205
+
206
+
207
+ Object.defineProperty(this, 'exported', {
208
+ // Using shorthand method names (ES2015 feature).
209
+ // This is equivalent to:
210
+ // get: function() { return bValue; },
211
+ // set: function(newValue) { bValue = newValue; },
212
+
213
+
214
+ get() {
215
+ if (_exported === undefined) { // can be false
216
+ // will lookup the assignment statement
217
+
218
+
219
+ throw 'NYI';
220
+
221
+
222
+ // use the map / index of variable names / usage (incl dotted paths)
223
+ //this.body.find()
224
+
225
+ _exported = {
226
+
227
+ };
228
+ Object.defineProperty(_exported, 'keys', {
229
+ get() {
230
+ if (_exported_keys === undefined) {
231
+ const jsf = that;
232
+
233
+ const mdecnames = jsf.body.node.map.declaration.identifier.name;
234
+ log('mdecnames', mdecnames);
235
+
236
+ log('jsf.features.export', jsf.features.export);
237
+ log('jsf.features.export.name', jsf.features.export.name);
238
+ log('jsf.features.export.exported_object_name', jsf.features.export.exported_object_name);
239
+
240
+
241
+ // No longer finds the export declaration as a feature
242
+
243
+ // Probably will have a query-export section specifically for this.
244
+
245
+ const export_dec = mdecnames.get(jsf.features.export.exported_object_name);
246
+ log('export_dec', export_dec);
247
+ log('export_dec.source', export_dec.source);
248
+
249
+ //log('export_dec.collect.child.identifier.name', export_dec.collect.child.identifier.name);
250
+
251
+ // Or some means to collect keys....
252
+ //log('export_dec.child.count', export_dec.child.count);
253
+ //log('export_dec.child.first.child.count', export_dec.child.first.child.count);
254
+
255
+ //log('export_dec.child.first.collect.child.type()', export_dec.child.first.collect.child.type());
256
+ //log('export_dec.child.first.collect.child.category()', export_dec.child.first.collect.child.category());
257
+
258
+ // .collect.type
259
+
260
+ const cats = export_dec.child.first.collect.child.category();
261
+ const types = export_dec.child.first.collect.child.type();
262
+
263
+ log('cats', cats);
264
+ log('types', types);
265
+
266
+ let res = false;
267
+ if (cats[0] === 'Identifier' && cats[1] === 'Expression') {
268
+ const expression = export_dec.child.first.child.last;
269
+ if (types[1] === 'ObjectExpression') {
270
+ log('expression', expression);
271
+ log('expression.child.shared.type', expression.child.shared.type);
272
+ // Reading keys out of an object expression like this would be helpful.
273
+ //log('oe.keys', oe.keys);
274
+
275
+ if (expression.child.shared.type === 'ObjectProperty') {
276
+ //const keys = oe.child.first.collect.child.last.name;
277
+ const ops = expression.child_nodes;
278
+
279
+ // can't overwrite the 'name' property of a function, so it seems.
280
+
281
+ // but not what we want here!!!
282
+ //const keys = oe.collect.child.identifier.str_name();
283
+ //const keys = oe.collect.child.first.value();
284
+
285
+ // oe.keys
286
+ res = [];
287
+ // have it get a keys property?
288
+ // consider explanding the API in such ways.
289
+
290
+
291
+ expression.filter(n => n.type === 'StringLiteral', n => {
292
+ //log('n', n);
293
+ //log('n.source', n.source);
294
+ res.push(n.source.split('\'').join(''));
295
+ })
296
+ //const keys = ow.collect.literal.value;
297
+ //log('ops', ops);
298
+
299
+ //log('1) keys', keys);
300
+ } else {
301
+ throw 'stop';
302
+ }
303
+ //oe.each.child
304
+ } else {
305
+
306
+ if (types[1] === 'NewExpression') {
307
+ console.log('expression', expression);
308
+
309
+ // Current lang-tools:
310
+
311
+ // A new Evented_Class gets made.
312
+ // Then various values get assigned to it.
313
+
314
+ // Let's deal with the case of a class being made, and then Object.assign used to give it properties.
315
+ // It is a special case, but part of how jsgui is currently put together.
316
+ // So the jsgui object itself operates eventfully.
317
+
318
+ // Maybe put special cases in their own file?
319
+ // There could be quite a lot of them. Want to allow unusual syntax to be understood so that inventive JS can be built effectively too.
320
+
321
+ // Special case queries.
322
+ // Make the special cases operate as JS_AST_Nodes.
323
+ // The special case instance would check that the node it's attempting to wrap fits in with it's suitability test.
324
+
325
+ // Knowing when to use a special case...
326
+ // Could be from signature matching, could be from program logic like this.
327
+
328
+ // However, the special case may be a feature of the whole file.
329
+ // May also be considered a feature of the root node.
330
+
331
+ // Root_Node_Feature
332
+ // So yes it applies to nodes and uses that architecture. Then it can also be easily be applied to files.
333
+
334
+
335
+
336
+
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+
352
+ } else {
353
+ throw 'stop';
354
+ }
355
+
356
+
357
+
358
+ }
359
+
360
+ } else {
361
+ throw 'stop';
362
+ }
363
+ //return res;
364
+
365
+ _exported_keys = res;
366
+
367
+
368
+
369
+
370
+ }
371
+ return _exported_keys;
372
+ }
373
+ })
374
+
375
+
376
+ //throw 'stop';
377
+
378
+
379
+ }
380
+ return _exported;
381
+ //return features;
382
+ },
383
+ //set(newValue) { bValue = newValue; },
384
+ enumerable: true,
385
+ configurable: false
386
+ });
387
+
388
+ // An 'exported' object would be useful here.
389
+
390
+ // exported keys is the main thing we need to know.
391
+ // maybe it's false.
392
+
393
+ // such as if it exports a class
394
+
395
+ // .exported.class
396
+
397
+
398
+
399
+
400
+
401
+
402
+ }
403
+
404
+ // Exports feature.
405
+
406
+ //file.root.find_assignment_by_name('module.exports');
407
+
408
+
409
+
410
+
411
+
412
+
413
+ }
414
+ }
415
+ module.exports = JS_File_Query_Features;
@@ -0,0 +1,59 @@
1
+ const JS_File_Query_Features = require('./JS_File_4.1-Query_Features.js');
2
+ const Variable_Name_Provider = require('../Variable_Name_Provider');
3
+ const { each } = require('lang-mini');
4
+ class JS_File_Planning extends JS_File_Query_Features {
5
+ constructor(spec) {
6
+ super(spec);
7
+
8
+ // string path of the variable within the ast.
9
+ // can use that path to find the position at a later stage.
10
+ // Need to keep the planning stage separate for the moment.
11
+
12
+ // Want a way to access the paths of the nodes too.
13
+
14
+ // (node, path)
15
+
16
+ // propose_local_variable_name_remapping
17
+
18
+ const get_proposed_root_definitions_inner_name_remappings = this.get_proposed_root_definitions_inner_name_remappings = () => {
19
+ const res = {};
20
+ this.each_root_declaration(node => {
21
+ //console.log('node', node);
22
+ const idns = node.inner_declaration_names;
23
+ //throw 'stop';
24
+
25
+ if (idns.length > 0) {
26
+ //console.log('');
27
+ //console.log('node.own_declaration_names', node.own_declaration_names);
28
+
29
+ if (node.own_declaration_names.length === 1) {
30
+ const own_name = node.own_declaration_names[0];
31
+ //console.log('idns', idns);
32
+
33
+ const l_max = 2;
34
+
35
+ const arr_names_for_shortening = idns.filter(x => x.length > l_max);
36
+ //console.log('arr_names_for_shortening', arr_names_for_shortening);
37
+
38
+ if (arr_names_for_shortening.length > 0) {
39
+ const namer = new Variable_Name_Provider();
40
+ const map_renames = {};
41
+ each(arr_names_for_shortening, name => {
42
+ const new_name = namer.get_l();
43
+ map_renames[name] = new_name;
44
+ });
45
+ //console.log('map_renames', map_renames);
46
+ res[own_name] = map_renames;
47
+ }
48
+ } else {
49
+ console.log('node', node);
50
+ throw 'stop';
51
+ }
52
+ }
53
+ });
54
+ return res;
55
+ }
56
+ }
57
+ }
58
+
59
+ module.exports = JS_File_Planning;
@@ -0,0 +1,24 @@
1
+ const JS_File_Planning = require('./JS_File_5-Planning');
2
+ const Variable_Name_Provider = require('../Variable_Name_Provider');
3
+ const { each } = require('lang-mini');
4
+
5
+ const {transform} = require("@babel/core");
6
+ // import { transform } from "@babel/core";
7
+ const generate = require("@babel/generator").default;
8
+ //import generate from "@babel/generator";
9
+ //console.log('generate', generate);
10
+ //throw 'stop';
11
+
12
+ class JS_File_Changing extends JS_File_Planning {
13
+ constructor(spec) {
14
+ super(spec);
15
+
16
+
17
+
18
+ }
19
+ }
20
+ JS_File_Changing.load_from_stream = (rs, path) => {
21
+ const res = new JS_File_Changing({rs: rs, path: path});
22
+ return res;
23
+ }
24
+ module.exports = JS_File_Changing;
@@ -0,0 +1,12 @@
1
+
2
+ // Has to be a single object.
3
+ // But that single object can be expressed inline too.
4
+ // Shouldn't be so hard.
5
+
6
+ // Just a single object gets exported - but may help with some syntax that exports multiple objects.
7
+ // Eg libraries of utility functions.
8
+
9
+ // Spot class non prototype functions too?
10
+
11
+ // Maybe make JSGUI_Module_Exports declaration.
12
+
@@ -0,0 +1,24 @@
1
+
2
+ class Import_Reference {
3
+ constructor(spec = {}) {
4
+
5
+ // name and value pair.
6
+
7
+ let name, value;
8
+
9
+ Object.defineProperty(this, 'name', {
10
+ set: function(v) { name = v; },
11
+ get() { return name; },
12
+ enumerable: true,
13
+ configurable: false
14
+ });
15
+ Object.defineProperty(this, 'value', {
16
+ set: function(v) { value = v; },
17
+ get() { return value; },
18
+ enumerable: true,
19
+ configurable: false
20
+ });
21
+ }
22
+ }
23
+
24
+ module.exports = Import_Reference;
@@ -0,0 +1,32 @@
1
+ // May be removed / a changed version made.
2
+ // Possibly a more general version, not just for JS files (in theory)
3
+
4
+ // But this could be useful for understanding what the import references are and matching the code for them.
5
+
6
+ // An abstraction that represents an understanding of the references that get imported into a JS_File.
7
+ // Likely to be:
8
+ // Generated when a js file is loaded
9
+ // Used to understand where in the working and therefore output structure the functionality goes (if it is treated as a block).
10
+
11
+
12
+
13
+
14
+
15
+
16
+ class Import_References {
17
+ constructor(spec = {}) {
18
+
19
+ const arr = [];
20
+ Object.defineProperty(this, 'arr', {
21
+ //set: function(v) { arr = v; },
22
+ get() { return arr; },
23
+ enumerable: true,
24
+ configurable: false
25
+ });
26
+
27
+ this.push = value => arr.push(value);
28
+
29
+ }
30
+ }
31
+
32
+ module.exports = Import_References;
@@ -0,0 +1,16 @@
1
+ // Don't use? Use planning and changing instead?
2
+ // Come up with the course of action. Then carry it out.
3
+
4
+
5
+ const JS_File_Comprehension = require('./JS_File_4-Queryjs');
6
+
7
+ class JS_FIle_Processor extends JS_File_Comprehension {
8
+ constructor(spec) {
9
+ super(spec);
10
+
11
+
12
+
13
+ }
14
+ }
15
+
16
+ module.exports = JS_FIle_Processor;
@@ -0,0 +1,16 @@
1
+ const {each, Evented_Class} = require('lang-mini');
2
+
3
+ class JS_Files extends Evented_Class {
4
+ constructor(spec) {
5
+
6
+ const arr_files = [];
7
+ const map_files = {}; // by full path if provided, otherwise name.
8
+
9
+
10
+
11
+ super(spec);
12
+ }
13
+
14
+ }
15
+
16
+ module.exports = JS_Files;
@@ -0,0 +1,14 @@
1
+ // Corresponds to an npm module, JS code in a directory and with the package.json standard.
2
+
3
+ // Will be able to get data about what it imports and exports.
4
+
5
+ // Want a fairly simple API.
6
+
7
+ // Like load, get_compressed
8
+
9
+ // Some kind of categorisation / signature / signature match of the structure of the module.
10
+
11
+ // Want to do things such as load a file as a module, and it has information about what the module exports.
12
+
13
+
14
+