jsgui3-server 0.0.75 → 0.0.79

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 +102 -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,65 @@
1
+ //const babel_node_tools = require('../babel/babel_node_tools');
2
+
3
+ //const { each } = require('lang-mini');
4
+ const JS_AST_Node_Query = require('./JS_AST_Node_7-Query');
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+ class JS_AST_Node_Features extends JS_AST_Node_Query {
15
+ constructor(spec = {}) {
16
+ super(spec);
17
+ // Getting the assigned values also seems important.
18
+ // Possibly will be made into some kind of autoquery? Or may be better to do queries lazily, and store the results.
19
+
20
+ // Declared Object features inside a node.
21
+
22
+ // If a node 'features' declared objects, then the syntax in which they are declared is not so important.
23
+ // This is an abstraction level above that.
24
+
25
+ // Want to keep it faitrly generic at this stage
26
+ // Will do more with root node interpretation for the moment I expect.
27
+ // First priority is to get everything linking together properly in an output file.
28
+ //
29
+ const arr_features_declared_object = [];
30
+ const features = [];
31
+ const map_arr_features_by_feature_name = {
32
+
33
+ }
34
+ Object.defineProperty(this, 'features', {
35
+ get() {
36
+ //if (!features) {
37
+ // features = [];
38
+ //}
39
+ return features;
40
+ },
41
+ //set(newValue) { bValue = newValue; },
42
+ enumerable: true,
43
+ configurable: false
44
+ });
45
+
46
+ // get literal names
47
+ // or is it value
48
+
49
+ // // Assignment Feature?
50
+
51
+
52
+ // Document features make the most sense to work on from the API point of view.
53
+ // Or root node features really.
54
+
55
+ // Will try loading up and querying an interpreted root node.
56
+ // Or jsgui root node interpreted?
57
+ // Even with that Object.assign trick, we can make it aware, keep that in the general purpose code.
58
+
59
+
60
+ // The imports and exports features are important for linking together the documents.
61
+
62
+ }
63
+ }
64
+
65
+ module.exports = JS_AST_Node_Features;
@@ -0,0 +1,32 @@
1
+ const JS_AST_Node_Index = require('./JS_AST_Node_8-Features');
2
+
3
+ class JS_AST_Node_Planning extends JS_AST_Node_Index {
4
+ constructor(spec = {}) {
5
+ super(spec);
6
+
7
+ // sets the childnodes here.
8
+ // will also make available the relevant bable properties.
9
+
10
+ // Use the lower level tools to kind of understand the node.
11
+ // Provide property getters that will do this.
12
+
13
+ // Seeing what pattern / recognised object / pattern it is.
14
+
15
+ // plan_variable_name_remapping
16
+
17
+ // Will be fastest to carry out multiple changes at once in one iteration.
18
+ // May use quite standard babel transform syntax once I have the changes arranged in a nice object that makes them clear.
19
+
20
+ // Set up more ctrl-alt-\ then a letter remappings.
21
+ // Can use that to quickly type a varierty of snippets.
22
+
23
+
24
+
25
+
26
+ }
27
+ plan_variable_name_remapping() {
28
+ this.each_inner_declaration_declarator_identifier()
29
+ }
30
+ }
31
+
32
+ module.exports = JS_AST_Node_Planning;
@@ -0,0 +1,15 @@
1
+ // A way / structure in which JS_AST_Node objects are arranged.
2
+
3
+ // Specifying conditions on the item and on the parents.
4
+
5
+ // A feature could use different optional arrangements.
6
+
7
+ // Getting more out of syntax matching with trees and signatures would be of use.
8
+
9
+ // Arrangement of nodes
10
+
11
+ // Maybe do this work on it later on.
12
+ // It gets into some further objects and algorithms involving trees.
13
+
14
+
15
+
@@ -0,0 +1,306 @@
1
+ const JS_AST_Node_Feature = require('./JS_AST_Node_Feature');
2
+
3
+ // Maybe getting this working will be best done with focused attention on separate declaration statements.
4
+ // Definitely want this to be a powerful abstraction, well defined in what it does.
5
+
6
+ // It will need flexibility and complexity to bridge the gap between declaration syntax in js, and what is in abstract theory a declared programmatic object, which in this
7
+ // case will be linked to the the ast nodes.
8
+
9
+ // The declared object abstraction will be used on a higher level still.
10
+ // In projects it will be used to understand what is referred to in the input to a module, as that module / file gets imported / loaded into the project.
11
+
12
+
13
+
14
+
15
+
16
+
17
+ class JS_AST_Node_Declared_Object extends JS_AST_Node_Feature {
18
+ constructor(spec = {}) {
19
+
20
+ //console.log('JS_AST_Node_Declared_Object constructor');
21
+ //console.log('Object.keys(spec)', Object.keys(spec));
22
+
23
+
24
+ spec.type = 'DeclaredObject';
25
+ super(spec);
26
+
27
+ const {js_ast_node, index_in_js_ast_node} = this;
28
+
29
+
30
+ /*
31
+ let js_ast_node_value;
32
+
33
+ Object.defineProperty(this, 'js_ast_node_value', {
34
+ get() {
35
+ return js_ast_node_value;
36
+ },
37
+ set(v) { js_ast_node_value = v; },
38
+ enumerable: true,
39
+ configurable: false
40
+ });
41
+ */
42
+
43
+
44
+ if (js_ast_node) {
45
+
46
+ //console.log('js_ast_node', js_ast_node);
47
+
48
+ // go through it, extracting the declarators.
49
+
50
+ const have_vdr = vdr => {
51
+
52
+ if (vdr.type === 'VariableDeclarator') {
53
+
54
+ if (vdr.child_nodes.length === 2) {
55
+ const [id, exp_or_lit] = vdr.child_nodes;
56
+ if (id.type === 'Identifier') {
57
+ //console.log('exp_or_lit', exp_or_lit);
58
+ //console.log('exp_or_lit.is_literal', exp_or_lit.is_literal);
59
+ if (exp_or_lit.is_expression || exp_or_lit.is_literal) {
60
+
61
+ this.name = id.name;
62
+ this.js_ast_node_value = exp_or_lit;
63
+
64
+ //throw 'NYI';
65
+ } else {
66
+
67
+ if (exp_or_lit.type === 'Identifier') {
68
+ // it's being set by reference using another identifier.
69
+
70
+ const id2 = exp_or_lit;
71
+
72
+ this.name = id.name;
73
+ this.value_name = id2.name;
74
+
75
+ } else {
76
+ throw 'stop';
77
+ }
78
+
79
+ // It's OK if it's an identifier.
80
+
81
+ // Not so sure though.
82
+ //console.log('js_ast_node.source', js_ast_node.source);
83
+ //console.log('vdr', vdr);
84
+
85
+ //throw 'stop';
86
+ }
87
+
88
+ } else {
89
+ throw 'stop';
90
+ }
91
+ } else {
92
+
93
+ //console.log('vdr.child_nodes.length', vdr.child_nodes.length);
94
+ //console.log('vdr.child_nodes', vdr.child_nodes);
95
+
96
+ if (vdr.child_nodes.length === 1) {
97
+ const id = vdr.child_nodes[0];
98
+ if (id.type === 'Identifier') {
99
+ this.name = id.name;
100
+ } else {
101
+ throw 'stop';
102
+ }
103
+ } else {
104
+ throw 'stop';
105
+ }
106
+
107
+ //throw 'stop';
108
+ }
109
+
110
+ //const [id, ]
111
+
112
+
113
+ } else {
114
+
115
+
116
+
117
+ throw 'stop';
118
+ }
119
+ }
120
+
121
+ if (js_ast_node.child_nodes.length === 1) {
122
+
123
+ const vdr = js_ast_node.child_nodes[0];
124
+
125
+ if (vdr.type === 'VariableDeclarator') {
126
+ //console.log('vdr', vdr);
127
+ have_vdr(vdr);
128
+ } else {
129
+
130
+ if (vdr.type === 'Identifier') {
131
+ const id = vdr;
132
+ //console.log('js_ast_node.source', js_ast_node.source);
133
+ //console.log('id', id);
134
+ //console.log('id.name', id.name);
135
+
136
+ this.name = id.name;
137
+
138
+ //throw 'stop';
139
+ } else {
140
+ throw 'stop';
141
+ }
142
+ }
143
+
144
+ } else {
145
+
146
+ //console.log('index_in_js_ast_node', index_in_js_ast_node);
147
+ const vdr = js_ast_node.child_nodes[index_in_js_ast_node];
148
+ have_vdr(vdr);
149
+
150
+ //throw 'NYI';
151
+ }
152
+ }
153
+ // .object_name
154
+ // .referenced_node (often the object is set after the =)
155
+ // cases like if it is a function call result.
156
+ //let referenced_node;
157
+
158
+ }
159
+ }
160
+
161
+ JS_AST_Node_Declared_Object.arr_from_js_ast_node = (js_ast_node) => {
162
+ // An ast node can have multiple items defined within it.
163
+
164
+ // consider 'let a;' where the value does not get set.
165
+ // it is still declared. just does not have a value / value is undefined.
166
+
167
+
168
+ if (js_ast_node.type === 'ClassDeclaration') {
169
+ return [new JS_AST_Node_Declared_Object({
170
+ js_ast_node: js_ast_node
171
+ })];
172
+ } else if (js_ast_node.type === 'VariableDeclaration') {
173
+ //
174
+
175
+ // Can have multiple declarators.
176
+ // Interested in getting each of them.
177
+ // But the array deconstruction case? Object deconstrucion?
178
+ // May need to do separate work on testing ast_node features.
179
+ // Features are a higher level abstraction.
180
+ // They will need to be able to handle different syntax for the same feature.
181
+
182
+ // These declared objects will themselves be usable as units.
183
+ // We will have the inner ast for what it's been declared as.
184
+ // Ability to look up references? May be better outside of here, at least for the moment.
185
+ const res = [];
186
+
187
+
188
+
189
+ if (js_ast_node.child_nodes.length === 1) {
190
+ const vdr = js_ast_node.child_nodes[0];
191
+ if (vdr.type === 'VariableDeclarator') {
192
+
193
+ if (vdr.child_nodes.length === 2) {
194
+ const id = vdr.child_nodes[0];
195
+ if (id.type === 'Identifier') {
196
+ //console.log('id.name', id.name);
197
+ const fdec = new JS_AST_Node_Declared_Object({
198
+ js_ast_node: js_ast_node
199
+ })
200
+ res.push(fdec);
201
+ } else {
202
+ throw 'stop';
203
+ }
204
+ } else {
205
+ throw 'stop';
206
+ }
207
+
208
+
209
+ //throw 'nyi stop';
210
+ } else {
211
+ console.log('js_ast_node.child_nodes.length', js_ast_node.child_nodes.length);
212
+ throw 'stop';
213
+ }
214
+ } else {
215
+ //console.log('js_ast_node.source', js_ast_node.source);
216
+ let index = 0;
217
+ js_ast_node.each.child(vdr => {
218
+ if (vdr.type === 'VariableDeclarator') {
219
+ if (vdr.child_nodes.length === 1) {
220
+ // just the identifier, no value set.
221
+ const id = vdr.child_nodes[0];
222
+ if (id.type === 'Identifier') {
223
+ const fdec = new JS_AST_Node_Declared_Object({
224
+ js_ast_node: js_ast_node,
225
+ index_in_js_ast_node: index
226
+ });
227
+ res.push(fdec);
228
+ } else {
229
+ throw 'stop';
230
+ }
231
+
232
+ } else {
233
+ //console.log('vdr', vdr);
234
+
235
+ // a var declarator can have both the id as well as the object expression.
236
+ // or presumably any other expression.
237
+
238
+ if (vdr.child_nodes.length === 2) {
239
+
240
+ const [id, exp] = vdr.child_nodes;
241
+
242
+
243
+
244
+ if (id.type === 'Identifier') {
245
+ if (exp.is_expression) {
246
+ const fdec = new JS_AST_Node_Declared_Object({
247
+ js_ast_node: js_ast_node,
248
+ index_in_js_ast_node: index
249
+ });
250
+ res.push(fdec);
251
+ } else {
252
+ // could be an identifier.
253
+ // presumably could be a boolean expression too.
254
+
255
+ if (exp.type === 'Identifier') {
256
+ const id2 = exp;
257
+ const fdec = new JS_AST_Node_Declared_Object({
258
+ js_ast_node: js_ast_node,
259
+ index_in_js_ast_node: index
260
+ });
261
+ res.push(fdec);
262
+ } else {
263
+ throw 'stop';
264
+ }
265
+
266
+
267
+
268
+ }
269
+
270
+ } else {
271
+ throw 'stop';
272
+ }
273
+ } else {
274
+ throw 'stop';
275
+ }
276
+
277
+ //throw 'NYI';
278
+ }
279
+
280
+ } else {
281
+ throw 'stop';
282
+ }
283
+ index++;
284
+ })
285
+
286
+ //throw 'NYI';
287
+ }
288
+ return res;
289
+
290
+
291
+
292
+
293
+
294
+
295
+ //if ()
296
+
297
+
298
+
299
+
300
+ } else {
301
+ throw 'stop';
302
+ }
303
+
304
+ }
305
+
306
+ module.exports = JS_AST_Node_Declared_Object;
@@ -0,0 +1,78 @@
1
+ class JS_AST_Node_Feature {
2
+
3
+ // Feature_Declaration subclass too?
4
+ //
5
+
6
+
7
+ constructor(spec = {}) {
8
+ //let name, type;
9
+
10
+ let node, value_name;
11
+
12
+ if (spec.name) {
13
+ name = spec.name;
14
+ }
15
+ //if (spec.type) {
16
+ // type = spec.type;
17
+ //}
18
+
19
+ if (spec.js_ast_node) { //check / confirm type?
20
+ node = spec.js_ast_node;
21
+ } else if (spec.node) { //check / confirm type?
22
+ node = spec.node;
23
+ }
24
+
25
+ /*
26
+ if (spec.index_in_js_ast_node !== undefined) {
27
+ index_in_node = spec.index_in_js_ast_node;
28
+ } else if (spec.index_in_node !== undefined) {
29
+ index_in_node = spec.index_in_node;
30
+ }
31
+ */
32
+
33
+ /*
34
+ Object.defineProperty(this, 'name', {
35
+ get() {
36
+ return name;
37
+ },
38
+ set(v) { name = v; },
39
+ enumerable: true,
40
+ configurable: false
41
+ });
42
+ */
43
+
44
+ /*
45
+ Object.defineProperty(this, 'value_name', {
46
+ get() {
47
+ return value_name;
48
+ },
49
+ set(v) { value_name = v; },
50
+ enumerable: true,
51
+ configurable: false
52
+ });
53
+ */
54
+ Object.defineProperty(this, 'node', {
55
+ get() {
56
+ return node;
57
+ },
58
+ //set(newValue) { bValue = newValue; },
59
+ enumerable: true,
60
+ configurable: false
61
+ });
62
+
63
+ // Maybe don't need this, with improved sibling and index property in the node itself.
64
+
65
+ /*
66
+ Object.defineProperty(this, 'index_in_node', {
67
+ get() {
68
+ return index_in_js_ast_node;
69
+ },
70
+ set(v) { index_in_js_ast_node = v; },
71
+ //set(newValue) { bValue = newValue; },
72
+ enumerable: true,
73
+ configurable: false
74
+ });
75
+ */
76
+ }
77
+ }
78
+ module.exports = JS_AST_Node_Feature;