jsgui3-server 0.0.73 → 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 (155) 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 +11 -0
  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 +14 -0
  130. package/resources/jsbuilder/Platforms.js +70 -0
  131. package/resources/jsbuilder/Project.js +109 -0
  132. package/resources/jsbuilder/Reference.js +1 -0
  133. package/resources/jsbuilder/Reference_Sequence.js +16 -0
  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 +304 -0
  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 -1347
  151. package/resources/website-resource.js +390 -797
  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
@@ -0,0 +1,180 @@
1
+
2
+
3
+ const JS_AST_Node = require('../../JS_AST_Node');
4
+ const JS_AST_Root_Node_Feature_Exports = require('./JS_AST_Root_Node_Feature_Exports');
5
+
6
+
7
+ const {each} = require('lang-mini');
8
+ // A map of named / relevant inner nodes could be a useful feature of the ast node overall.
9
+
10
+ // or is it an index if it's mapping to an array?
11
+
12
+ // idx_named_nodes (so it can apply to ancestors or others in the ast)
13
+
14
+ // map_named_inner_nodes
15
+
16
+ // map_named_inner_nodes['exports'] = [...] // always an array
17
+
18
+
19
+ class JS_AST_Root_Node_Interpreted extends JS_AST_Node {
20
+
21
+ // Root node features could be of use.
22
+ // Want to recognise features in a convenient way.
23
+ // Signatures could definitely help with that
24
+ // But a feature may not be best recognised with a signature.
25
+
26
+ // Could do a more formal decision tree for determining features.
27
+ // could have a set of determinations and values.
28
+ //
29
+
30
+
31
+ // This is the best place for it to come up with more info on the import and export?
32
+ // Or further down near the core?
33
+
34
+ constructor(spec) {
35
+ super(spec);
36
+
37
+ const {get_arr_named_node, index_named_node} = this;
38
+
39
+ // .exported.type 'object', 'class'
40
+ // .exported.keys
41
+
42
+ // This will handle non-special case things.
43
+ // If there is demand jsgui or other special cases could be brought into normal interpretation.
44
+
45
+ // An index of the relevant statements.
46
+
47
+ let ast_node_exports_statement;
48
+ //let arr_ast_node_import_statements = [];
49
+
50
+ const get_module_exports_statement_node = () => {
51
+
52
+ if (!ast_node_exports_statement) {
53
+
54
+
55
+ this.setup_node_index('identifiers_by_name', node => node.is_identifier, node => node.name);
56
+
57
+ //let res;
58
+ const mod_ids = this.get_indexed_nodes_by_key('identifiers_by_name', 'module');
59
+ each(mod_ids, node => {
60
+ // want to be able to get the next sibling from a node easily.
61
+ //console.log('node', node);
62
+ //console.log('node.parent_node', node.parent_node);
63
+
64
+ //console.log('node.sibling.count', node.sibling.count);
65
+
66
+ if (node.sibling.count === 1) {
67
+ const sibling = node.sibling.collect()[0];
68
+ //console.log('sibling.name', sibling.name);
69
+ if (sibling.name === 'exports') {
70
+ //console.log('node.parent_node.parent_node', node.parent_node.parent_node);
71
+ //console.log('node.parent_node.parent_node.parent_node', node.parent_node.parent_node.parent_node);
72
+ //console.log('node.parent.node.parent.node.parent.node', node.parent.node.parent.node.parent.node);
73
+ //console.log('node.ggparent.node', node.ggparent.node);
74
+ //console.log('node.ggparent.node.is_statement', node.ggparent.node.is_statement);
75
+
76
+ if (node.ggparent.node && node.ggparent.node.is_statement) {
77
+ ast_node_exports_statement = node.ggparent.node;
78
+ }
79
+ }
80
+ }
81
+ });
82
+ }
83
+
84
+ // Get the Member Expression module.exports
85
+
86
+ // Signature matches probably are the best way to compare for the moment.
87
+ // How about just indexing shallow signatures?
88
+
89
+ // Looking it up from the index seems like it makes the most sense.
90
+
91
+ // sig_from_source
92
+ // sig(src)
93
+
94
+ // Maybe set this up before.
95
+ // Nodes by type as well?
96
+
97
+ //console.log('mod_ids', mod_ids);
98
+ return ast_node_exports_statement;
99
+
100
+ }
101
+
102
+ let exports;
103
+ Object.defineProperty(this, 'exports', {
104
+ get() {
105
+ if (exports === undefined) {
106
+ // Worth creating some kind of 'feature' object here.
107
+ // Would have more understanding of the node being exported?
108
+
109
+ // Create the exports feature, and that will be given the module.exports statement (or maybe the exported statement)
110
+
111
+ // exports.exported.node
112
+ // could be ok for the moment.
113
+
114
+ // will really be querying the exports object
115
+ // exports.exported.keys
116
+ // exports.exported.type
117
+
118
+ // // const $1 = new $2($3);\n
119
+ // const $1 = new $2($3);\n
120
+
121
+ // find the exports statement.
122
+ //this.select
123
+
124
+ const exports_statement_node = get_module_exports_statement_node();
125
+ //console.log('exports_statement_node', exports_statement_node);
126
+
127
+ exports = new JS_AST_Root_Node_Feature_Exports({
128
+ node: exports_statement_node
129
+ });
130
+
131
+ //let node;
132
+
133
+ /*
134
+ Object.defineProperty(exports, 'node', {
135
+ get() {
136
+ return ;
137
+ },
138
+ enumerable: true,
139
+ configurable: false
140
+ });
141
+ */
142
+
143
+
144
+ //const module_exports_statement_node = get_module_exports_statement_node();
145
+ //console.log('module_exports_statement_node', module_exports_statement_node);
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+ }
159
+ return exports;
160
+ },
161
+ enumerable: true,
162
+ configurable: false
163
+ });
164
+
165
+
166
+ //
167
+ // Further properties.
168
+ // Need to look into .exports.
169
+ // Don't want so much functionality on the JS_File side of things, it's better to layer the relevant abstractions on top of JS_AST_Node.
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+ }
178
+ }
179
+
180
+ module.exports = JS_AST_Root_Node_Interpreted;
@@ -0,0 +1,43 @@
1
+ // Similar in purpose to a document feature.
2
+
3
+ // Will be used to handle special cases / unusual ways of declaring exports.
4
+
5
+ // So the root node could itself feature exports.
6
+
7
+ // So a feature could be that JSGUI_AST_Interpreter understands it and understands what it's about.
8
+ // However, want the Interpreter to itself be / act as a node within the AST.
9
+
10
+ // JSGUI_AST_Root_Node_Interpretation
11
+
12
+ // So it loads the node, an also applies higher level special case rules.
13
+ // If it does not recognise how a JS file works, then program in the special rules that will allow it to.
14
+ // Normal types of syntax should be covered on a lower level. This special case system will allow that to
15
+ // not accumulate too much code clutter and continue to be a nice codebase.
16
+
17
+ // So the feature would be 'JSGUI Interpreted'.
18
+
19
+ // At least special case rules and interpretation can be as lengthy as required to do the task, and stay out of the way of lower level parts.
20
+
21
+
22
+ const Root_Node_Interpreted = require('./JS_AST_Root_Node_Interpreted');
23
+
24
+
25
+
26
+
27
+
28
+ class JSGUI_Root_Node_Interpreted extends Root_Node_Interpreted {
29
+ constructor(spec) {
30
+ super(spec);
31
+
32
+
33
+ // .exported.type 'object', 'class'
34
+ // .exported.keys
35
+
36
+ }
37
+ }
38
+
39
+
40
+ module.exports = JSGUI_Root_Node_Interpreted;
41
+
42
+
43
+
@@ -0,0 +1,12 @@
1
+
2
+
3
+ // Covers the case such as in lang-tools:
4
+
5
+ // An Evented_Class is made
6
+ // Object.assign is used to assign its properties.
7
+
8
+ // May as well not treat this as a special case?
9
+ // Just the logic within find_keys
10
+ // It's fine to go into various specifics if it's written in a way so that if they don't occurr, no unwanted effects.
11
+
12
+
@@ -0,0 +1,35 @@
1
+ // Basically a collection but chose a shorter name.
2
+
3
+
4
+ // Want to be able to operate on the group as a whole.
5
+
6
+
7
+ // each.child
8
+ // each.ancestor
9
+ // each.inner
10
+ // each (including self buut no ancestrors)
11
+
12
+ // each will produce the callback
13
+ // all the array
14
+ // first the item
15
+
16
+ // filter like each with a callback
17
+ // select returns the array
18
+
19
+
20
+
21
+ // .filter
22
+
23
+
24
+
25
+ // .all
26
+ // is collect
27
+
28
+ // .find.all
29
+ // that is select
30
+
31
+ //
32
+
33
+ // .find.first
34
+
35
+
@@ -0,0 +1,11 @@
1
+ class JS_AST_Operation {
2
+ constructor(spec = {}) {
3
+ let name;
4
+
5
+ if (spec.name !== undefined) {
6
+ name = spec.name;
7
+ }
8
+ }
9
+ }
10
+
11
+ module.exports = JS_AST_Operation;
@@ -0,0 +1,32 @@
1
+ class JS_AST_Operation_On_Relationship {
2
+ constructor(spec = {}) {
3
+
4
+
5
+
6
+
7
+ let operation, relationship;
8
+
9
+ if (spec.operation !== undefined) {
10
+ operation = spec.operation;
11
+ }
12
+
13
+ if (spec.relationship !== undefined) {
14
+ relationship = spec.relationship;
15
+ }
16
+
17
+
18
+ // From things like collect all.
19
+
20
+ // May be better to use the select command for the moment.
21
+
22
+ // collect.all.declaration
23
+
24
+
25
+
26
+
27
+
28
+
29
+ }
30
+ }
31
+
32
+ module.exports = JS_AST_Operation_On_Relationship;
@@ -0,0 +1,38 @@
1
+ const JS_AST_Relationship_Node_To_Group = require('./JS_AST_Relationship_Node_To_Group');
2
+
3
+ class JS_AST_Ordered_Relationship_Node_To_Group extends JS_AST_Relationship_Node_To_Group {
4
+ constructor(spec = {}) {
5
+ super(spec);
6
+ let index;
7
+ if (spec.index !== undefined) index = spec.index;
8
+
9
+
10
+
11
+ Object.defineProperty(this, 'index', {
12
+ get() {
13
+ return index;
14
+ },
15
+ enumerable: true,
16
+ configurable: false
17
+ });
18
+
19
+ // A 'pre' property
20
+
21
+ // Could be another group / a subgroup.
22
+
23
+ // a previous object.
24
+ // seems like a Node_group?
25
+
26
+ // .each
27
+ // .all
28
+ //
29
+
30
+
31
+
32
+
33
+ //
34
+
35
+ }
36
+ }
37
+
38
+ module.exports = JS_AST_Ordered_Relationship_Node_To_Group;
@@ -0,0 +1,40 @@
1
+ class JS_AST_Ordinal {
2
+
3
+
4
+ // Not a relationship
5
+ // First child is an ordinal relationship
6
+
7
+
8
+
9
+
10
+ constructor(spec = {}) {
11
+
12
+
13
+
14
+
15
+ let origin, obtainer, number;
16
+
17
+ //let relationship_to;
18
+
19
+ if (spec.origin) {
20
+ origin = spec.origin;
21
+ }
22
+
23
+ if (spec.number !== undefined) {
24
+ number = spec.number;
25
+ }
26
+
27
+ //if (spec.obtainer) {
28
+ // obtainer = spec.obtainer;
29
+ //}
30
+ //if (spec.relationship_to) {
31
+ // relationship_to = spec.relationship_to;
32
+ //}
33
+
34
+ let arr_cached;
35
+
36
+
37
+ }
38
+ }
39
+
40
+ module.exports = JS_AST_Ordinal;
@@ -0,0 +1,25 @@
1
+ class JS_AST_Ordinal_Relationship {
2
+ constructor(spec = {}) {
3
+ let ordinal, relationship;
4
+
5
+
6
+
7
+ if (spec.ordinal !== undefined) ordinal = spec.ordinal;
8
+ if (spec.relationship !== undefined) relationship = spec.relationship;
9
+
10
+
11
+
12
+ Object.defineProperty(this, 'origin', {
13
+ get() {
14
+ return ordinal.origin;
15
+
16
+ },
17
+ //set(newValue) { bValue = newValue; },
18
+ enumerable: true,
19
+ configurable: false
20
+ });
21
+
22
+ }
23
+ }
24
+
25
+ module.exports = JS_AST_Ordinal_Relationship;
@@ -0,0 +1,201 @@
1
+ // Change to Group_Relationship?
2
+ const {each} = require('lang-mini');
3
+ const JS_AST_Group_Shared = require('./JS_AST_Group_Shared');
4
+
5
+
6
+
7
+ class JS_AST_Relationship_Node_To_Group {
8
+ constructor(spec = {}) {
9
+
10
+ let name;
11
+ if (spec.name !== undefined) {
12
+ name = spec.name;
13
+ }
14
+ let origin;
15
+ if (spec.origin !== undefined) {
16
+ origin = spec.origin;
17
+ }
18
+
19
+
20
+
21
+
22
+
23
+ // eg 'child'
24
+
25
+ // Iteration of sibling and ancestor groups here.
26
+
27
+ // And a sibling_nodes property.
28
+
29
+ // Integrate sibling iteration into the system.
30
+ // Will make some queries / other parts of the system easier to write.
31
+
32
+ // A version of this that is ordinal as well, with .next and .previous.
33
+ // so we start by knowing the ordinal and the origin
34
+
35
+
36
+ // all previous sibling nodes?
37
+ // node.sibling.previous.each
38
+ // node.each.previous.sibling
39
+
40
+
41
+ const iterate_group = callback => {
42
+ // available_in_scope
43
+ // all previous siblings that are declarations / assignment expressions (of the right sort)
44
+ // iterate ancestors
45
+ // all child declarations
46
+ // (maybe just the ones before current)
47
+
48
+ // or something like above
49
+ //
50
+
51
+ if (name === 'post-sibling') {
52
+ if (origin.parent_node) {
53
+ //const postsibs = [];
54
+ let i2 = 0;
55
+ each(origin.parent_node.child_nodes, (node, idx, stop) => {
56
+ if (idx > origin.index) {
57
+ callback(node, i2++, stop);
58
+ } else {
59
+ }
60
+ });
61
+ }
62
+ } else if (name === 'previous-sibling') {
63
+ if (origin.parent_node) {
64
+ const presibs = [];
65
+ each(origin.parent_node.child_nodes, (node, idx, stop) => {
66
+ if (idx < origin.index) {
67
+ presibs.push(node)
68
+ } else {
69
+ stop();
70
+ }
71
+ });
72
+ presibs.reverse();
73
+ each(presibs, (node, idx, stop) => callback(node, idx, stop));
74
+ }
75
+ } else if (name === 'sibling') {
76
+ if (origin.parent_node) {
77
+ each(origin.parent_node.child_nodes, (node, idx, stop) => {
78
+ if (node !== origin) {
79
+ callback(node, idx, stop);
80
+ }
81
+ });
82
+ }
83
+ } else if (name === 'all') {
84
+ origin.deep_iterate(callback);
85
+ } else if (name === 'inner') {
86
+ origin.inner_deep_iterate(callback);
87
+ } else if (name === 'child') {
88
+
89
+ each(origin.child_nodes, callback);
90
+ //origin.each_child(callback);
91
+ } else if (name === 'available_in_scope') {
92
+ throw 'NYI';
93
+ } else {
94
+ console.log('name', name);
95
+ throw 'stop';
96
+ }
97
+ }
98
+
99
+ const find = (finder) => {
100
+ let res;
101
+ iterate_group((node, idx, stop) => {
102
+ if (finder(node)) {
103
+ if (!res) res = node; // TODO fix stop
104
+ //stop();
105
+ }
106
+ })
107
+ return res;
108
+ }
109
+
110
+ const shared = new JS_AST_Group_Shared({
111
+ group_iterator: iterate_group
112
+ });
113
+
114
+
115
+ // And collect is still a verb here.
116
+ // Use property sugar with a different name.
117
+ let _collected;
118
+ const collect = () => {
119
+ if (!_collected) {
120
+ _collected = [];
121
+ iterate_group(node => _collected.push(node));
122
+ }
123
+ return _collected;
124
+ }
125
+
126
+
127
+ // and .all could be like .collect but a property.
128
+ // and with groups could be used in a fair few places.
129
+
130
+ Object.defineProperty(this, 'all', {
131
+ get() {
132
+ return this.collect();
133
+ },
134
+ //set(newValue) { bValue = newValue; },
135
+ enumerable: true,
136
+ configurable: false
137
+ });
138
+
139
+ let _count;
140
+
141
+ const count = () => {
142
+ if (_count === undefined) {
143
+ if (_collected) {
144
+ _count = _collected.length;
145
+ } else {
146
+
147
+ if (name === 'child') {
148
+ _count = origin.child_nodes.length;
149
+ } else {
150
+ _count = 0;
151
+ iterate_group(node => _count++);
152
+ }
153
+
154
+
155
+ }
156
+ }
157
+ return _count;
158
+ }
159
+
160
+ Object.defineProperty(this, 'count', {
161
+ get() {
162
+ return count();
163
+ },
164
+ //set(newValue) { bValue = newValue; },
165
+ enumerable: true,
166
+ configurable: false
167
+ });
168
+
169
+
170
+ const select = (fn_select) => {
171
+ // Could return another group?
172
+ //
173
+
174
+ const res = [];
175
+ iterate_group(node => {
176
+ if (fn_select(node)) res.push(node);
177
+ });
178
+ return res;
179
+ }
180
+
181
+
182
+ Object.assign(this, {
183
+ select: select,
184
+ shared: shared,
185
+ each: iterate_group,
186
+ find: find,
187
+ collect: collect
188
+ });
189
+
190
+
191
+ /*
192
+ this.select = select;
193
+ this.shared = shared;
194
+ this.each = iterate_group;
195
+ this.find = find;
196
+ this.collect = collect;
197
+ */
198
+ }
199
+ }
200
+
201
+ module.exports = JS_AST_Relationship_Node_To_Group;
@@ -0,0 +1,44 @@
1
+ class JS_AST_Relationship_Node_Within_Group_To_Node {
2
+ constructor(spec = {}) {
3
+ let name;
4
+ if (spec.name !== undefined) {
5
+ name = spec.name;
6
+ }
7
+ let origin;
8
+ if (spec.origin !== undefined) {
9
+ origin = spec.origin;
10
+ }
11
+ let node;
12
+ if (spec.node !== undefined) {
13
+ node = spec.node;
14
+ }
15
+ let origin_ordinal_value_within_node;
16
+ if (spec.origin_ordinal_value_within_node !== undefined) {
17
+ origin_ordinal_value_within_node = spec.origin_ordinal_value_within_node;
18
+ }
19
+
20
+
21
+
22
+ Object.defineProperty(this, 'node', {
23
+ get() {
24
+ return node;
25
+ },
26
+ enumerable: true,
27
+ configurable: false
28
+ });
29
+ Object.defineProperty(this, 'origin', {
30
+ get() {
31
+ return origin;
32
+ },
33
+ set(new_value) {
34
+ origin = new_value;
35
+ },
36
+ enumerable: true,
37
+ configurable: false
38
+ });
39
+
40
+
41
+ }
42
+ }
43
+
44
+ module.exports = JS_AST_Relationship_Node_Within_Group_To_Node;