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.
- package/examples/client-side-popup-menu-button.html +93 -93
- package/examples/controls/_html-server-color-palette.js +114 -114
- package/examples/controls/html-server-combo-box.js +104 -104
- package/examples/controls/html-server-list.js +98 -98
- package/examples/controls/html-server-popup-menu-button.js +114 -114
- package/examples/controls/html-server-start-stop-toggle-button.js +146 -146
- package/examples/controls/scs-arrow-button.js +36 -36
- package/examples/controls/scs-date-picker.js +157 -157
- package/examples/controls/scs-file-browser.js +82 -82
- package/examples/controls/scs-item.js +159 -159
- package/examples/controls/scs-month-arrow-selector.js +126 -126
- package/examples/controls/scs-month-view.js +95 -95
- package/examples/controls/scs-start-stop-toggle-button.js +40 -40
- package/examples/controls/scs-tree.js +49 -49
- package/examples/controls/scs-year-arrow-selector.js +127 -127
- package/examples/demos/date-picker.js +119 -119
- package/examples/demos/explain-encapsulation.js +9 -9
- package/examples/demos/resizing.js +35 -35
- package/examples/demos/server_time.js +6 -6
- package/examples/demos/square_box.js +324 -324
- package/examples/html-rendering.js +20 -20
- package/examples/html-server.js +100 -100
- package/fs2.js +1836 -1836
- package/module.js +21 -21
- package/old/single-control-server.js +418 -418
- package/package.json +44 -42
- package/publishing/function-publisher.js +202 -202
- package/publishing/notes.md +5 -5
- package/publishing/observable-publisher.js +118 -118
- package/publishing/resource-publisher.js +306 -306
- package/resources/data-resource.js +104 -104
- package/resources/fs-resource.js +148 -148
- package/resources/jsbuilder/Abstract_Single_Declaration.js +105 -0
- package/resources/jsbuilder/Abstract_Single_Declaration_Sequence.js +43 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Abstract_Node.js +62 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Abstract_Node_Group.js +42 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Group_Shared.js +62 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node.js +94 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_0-Core.js +228 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_1-Babel.js +338 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_10-Changing.js +40 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_2.1.1-Child.js +97 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_2.1.2-Parent.js +38 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_2.1.3-Ancestor.js +62 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_2.2-Inner.js +44 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_2.3-All.js +73 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_2.4-Sibling.js +93 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_2.5-Available_In_Scope.js +29 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_2.9-Signature.js +116 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3-Basics.js +160 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.0.0-Basics_First.js +179 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.0.1-Basics_Second.js +88 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.0.99-Basics_Last.js +92 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.1-Basics_Each.js +137 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.1.5-Basics_Count.js +74 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.2-Basics_Filter.js +40 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.3-Basics_Collect.js +86 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.4-Basics_Select.js +43 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.5-Basics_Find.js +41 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_3.6-Basics_Callmap.js +55 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_4.0-Index_Indexes.js +46 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_4.1-Index.js +344 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_5.0-Category.js +39 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_5.1-Category_Identifier.js +31 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_5.2-Category_Literal.js +29 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_5.3-Category_Expression.js +27 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_5.4-Category_Pattern.js +9 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_5.5-Category_Declaration.js +44 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_5.6-Category_Statement.js +22 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_6.0-Type.js +87 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_6.1-Type_Class_Declaration.js +9 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_6.2-Type_Variable_Declaration.js +28 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_6.3-Type_Variable_Declarator.js +29 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_7-Query.js +737 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_8-Features.js +65 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_9-Planning.js +32 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Arrangement.js +15 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Node_Declared_Object.js +306 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Node_Feature.js +78 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Node_Feature_Declaration.js +249 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Node_Feature_Declarator.js +139 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/JS_AST_Root_Node_Feature.js +10 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/JS_AST_Root_Node_Feature_Exported.js +101 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/JS_AST_Root_Node_Feature_Exports.js +61 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/JS_AST_Root_Node_Interpreted.js +180 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/_JSGUI_Root_Node_Interpreted.js +43 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Feature/JS_AST_Root_Node_Feature/special_case_objectassign_to_object.js +12 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_Group.js +35 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Operation.js +11 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Operation_On_Relationship.js +32 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Ordered_Relationship_Node_To_Group.js +38 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Ordinal.js +40 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Ordinal_Relationship.js +25 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Relationship_Node_To_Group.js +201 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Relationship_Node_Within_Group_To_Node.js +44 -0
- package/resources/jsbuilder/JS_AST/_JS_AST_Node_3.8-Query_Features.js +77 -0
- package/resources/jsbuilder/JS_AST/query/all.js +0 -0
- package/resources/jsbuilder/JS_AST/query/enable_array_as_queryable.js +228 -0
- package/resources/jsbuilder/JS_AST/query/find_object_keys.js +405 -0
- package/resources/jsbuilder/JS_AST/query/node_queries.js +9 -0
- package/resources/jsbuilder/JS_AST/query/root_queries.js +0 -0
- package/resources/jsbuilder/JS_AST/query/root_query_identidy.js +12 -0
- package/resources/jsbuilder/JS_AST_Node_Extended/JSGUI_Singular_Declaration.js +86 -0
- package/resources/jsbuilder/JS_AST_Node_Extended/JS_AST_Node_Declaration.js +124 -0
- package/resources/jsbuilder/JS_AST_Node_Extended/JS_AST_Node_Extended.js +88 -0
- package/resources/jsbuilder/JS_AST_Node_Extended/JS_AST_Node_Extended_0-Core.js +11 -0
- package/resources/jsbuilder/JS_Builder.js +11 -0
- package/resources/jsbuilder/JS_File/Feature/JS_File_Declared_Object.js +32 -0
- package/resources/jsbuilder/JS_File/Feature/JS_File_Exported_Object_Info.js +26 -0
- package/resources/jsbuilder/JS_File/Feature/JS_File_Exports.js +79 -0
- package/resources/jsbuilder/JS_File/Feature/JS_File_Feature.js +18 -0
- package/resources/jsbuilder/JS_File/Feature/JS_File_Imported_Object_Info.js +26 -0
- package/resources/jsbuilder/JS_File/Feature/JS_File_Imports.js +9 -0
- package/resources/jsbuilder/JS_File/JS_File.js +12 -0
- package/resources/jsbuilder/JS_File/JS_File_0-Core.js +202 -0
- package/resources/jsbuilder/JS_File/JS_File_1-Early_Parse.js +175 -0
- package/resources/jsbuilder/JS_File/JS_File_2-Babel.js +81 -0
- package/resources/jsbuilder/JS_File/JS_File_3-JS_AST_Node.js +86 -0
- package/resources/jsbuilder/JS_File/JS_File_4-Query.js +414 -0
- package/resources/jsbuilder/JS_File/JS_File_4.1-Query_Features.js +415 -0
- package/resources/jsbuilder/JS_File/JS_File_5-Planning.js +59 -0
- package/resources/jsbuilder/JS_File/JS_File_6-Changing.js +24 -0
- package/resources/jsbuilder/JS_File/JS_File_Export_Reference.js +12 -0
- package/resources/jsbuilder/JS_File/JS_File_Import_Reference.js +24 -0
- package/resources/jsbuilder/JS_File/JS_File_Import_References.js +32 -0
- package/resources/jsbuilder/JS_File/JS_File_Processor.js +16 -0
- package/resources/jsbuilder/JS_File/JS_Files.js +16 -0
- package/resources/jsbuilder/Module.js +14 -0
- package/resources/jsbuilder/Platform.js +14 -0
- package/resources/jsbuilder/Platforms.js +70 -0
- package/resources/jsbuilder/Project.js +109 -0
- package/resources/jsbuilder/Reference.js +1 -0
- package/resources/jsbuilder/Reference_Sequence.js +16 -0
- package/resources/jsbuilder/Scope.js +30 -0
- package/resources/jsbuilder/Variable_Name_Provider.js +43 -0
- package/resources/jsbuilder/_JS_File.js +226 -0
- package/resources/jsbuilder/ast_query.js +21 -0
- package/resources/jsbuilder/babel/babel_consts.js +150 -0
- package/resources/jsbuilder/babel/babel_node_tools.js +542 -0
- package/resources/jsbuilder/babel/deep_iterate/deep_iterate_babel.js +604 -0
- package/resources/jsbuilder/build.js +16 -0
- package/resources/jsbuilder/platform_notes.md +66 -0
- package/resources/jsbuilder/test/test_ast_node.js +451 -0
- package/resources/jsbuilder/test/test_js_file.js +304 -0
- package/resources/jsbuilder/test/test_project.js +157 -0
- package/resources/local-server-info-resource.js +78 -78
- package/resources/process-js.js +537 -537
- package/resources/server-resource-pool.js +84 -84
- package/resources/website-css-resource.js +411 -411
- package/resources/website-javascript-resource.js +761 -1347
- package/resources/website-resource.js +390 -797
- package/resources/website-static-html-resource.js +196 -196
- package/server.js +170 -170
- package/single-control-server.js +398 -398
- package/single-page-app.js +129 -129
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const JS_AST_Node_Extended_Core = require('./JS_AST_Node_Extended_0-Core');
|
|
2
|
+
const JS_AST_Node_Declaration = require('./JS_AST_Node_Declaration');
|
|
3
|
+
|
|
4
|
+
class JS_AST_Node_Extended extends JS_AST_Node_Extended_Core {
|
|
5
|
+
constructor(spec = {}) {
|
|
6
|
+
super(spec);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
JS_AST_Node_Extended.from_babel_node = (spec) => {
|
|
11
|
+
|
|
12
|
+
const {babel_node} = spec;
|
|
13
|
+
const {type} = babel_node;
|
|
14
|
+
if (type === 'VariableDeclaration' || type === "ClassDeclaration") {
|
|
15
|
+
return new JS_AST_Node_Declaration(spec);
|
|
16
|
+
} else {
|
|
17
|
+
return new JS_AST_Node_Extended_Core(spec);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//return new JS_AST_Node(spec);
|
|
21
|
+
}
|
|
22
|
+
JS_AST_Node_Extended.from_spec = spec => {
|
|
23
|
+
|
|
24
|
+
let {babel_node} = spec;
|
|
25
|
+
//console.log('spec', spec);
|
|
26
|
+
|
|
27
|
+
if (!babel_node) {
|
|
28
|
+
if (spec.source) {
|
|
29
|
+
// create it, but then upgrade its type if necessary.
|
|
30
|
+
// or first create the babel node.
|
|
31
|
+
// that seems to make more sense in terms of the order of parsing.
|
|
32
|
+
const parser = require('@babel/parser');
|
|
33
|
+
const babel_ast = parser.parse(spec.source, {
|
|
34
|
+
sourceType: 'module',
|
|
35
|
+
plugins: [
|
|
36
|
+
'asyncGenerators',
|
|
37
|
+
'bigInt',
|
|
38
|
+
'classPrivateMethods',
|
|
39
|
+
'classPrivateProperties',
|
|
40
|
+
'classProperties',
|
|
41
|
+
'doExpressions',
|
|
42
|
+
//'exportDefaultFrom',
|
|
43
|
+
'nullishCoalescingOperator',
|
|
44
|
+
'numericSeparator',
|
|
45
|
+
'objectRestSpread',
|
|
46
|
+
'optionalCatchBinding',
|
|
47
|
+
'optionalChaining',
|
|
48
|
+
]});
|
|
49
|
+
|
|
50
|
+
//console.log('babel_ast', babel_ast);
|
|
51
|
+
|
|
52
|
+
babel_node_file = babel_ast;
|
|
53
|
+
babel_node_program = babel_ast.program;
|
|
54
|
+
|
|
55
|
+
//console.log('babel_node_program', babel_node_program);
|
|
56
|
+
|
|
57
|
+
const {body} = babel_node_program;
|
|
58
|
+
|
|
59
|
+
if (body.length === 1) {
|
|
60
|
+
const node0 = body[0];
|
|
61
|
+
|
|
62
|
+
babel_node = node0;
|
|
63
|
+
} else {
|
|
64
|
+
throw 'NYI';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if (babel_node) {
|
|
73
|
+
const {type} = babel_node;
|
|
74
|
+
|
|
75
|
+
if (type === 'VariableDeclaration' || type === "ClassDeclaration") {
|
|
76
|
+
return new JS_AST_Node_Declaration(spec);
|
|
77
|
+
} else {
|
|
78
|
+
return new JS_AST_Node_Extended_Core(spec);
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
throw 'stop';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
//return new JS_AST_Node(spec);
|
|
87
|
+
}
|
|
88
|
+
module.exports = JS_AST_Node_Extended;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const JS_AST_Node = require('../JS_AST/JS_AST_Node');
|
|
2
|
+
//const JS_AST_Node_Declaration = require('./JS_AST_Node_Declaration');
|
|
3
|
+
|
|
4
|
+
class JS_AST_Node_Extended extends JS_AST_Node {
|
|
5
|
+
constructor(spec = {}) {
|
|
6
|
+
super(spec);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
module.exports = JS_AST_Node_Extended;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Like 'Declaration', but moving away from the JS syntax and possibilities of a declaration statement containing declarations for multiple objects.
|
|
2
|
+
|
|
3
|
+
const JS_File_Feature = require('./JS_File_Feature');
|
|
4
|
+
|
|
5
|
+
// Or just use the AST node one?
|
|
6
|
+
// This would be a different abstraction layer, possibly needed.
|
|
7
|
+
|
|
8
|
+
class JS_File_Declared_Object extends JS_File_Feature {
|
|
9
|
+
constructor(spec = {}) {
|
|
10
|
+
super(spec);
|
|
11
|
+
|
|
12
|
+
// Will iterate root declaration statements to get the declared objects from them.
|
|
13
|
+
// Can do that now.
|
|
14
|
+
|
|
15
|
+
// Whether or not the declared object gets exported
|
|
16
|
+
// directly
|
|
17
|
+
// as property of object
|
|
18
|
+
// other, such as member of array.
|
|
19
|
+
// And the export type (here getting into detail of the statement, could reference the statement, maybe another property layer above to understand that)
|
|
20
|
+
|
|
21
|
+
// .usage
|
|
22
|
+
// .outer_corresponding_js_ast_node
|
|
23
|
+
|
|
24
|
+
console.log('JS_File_Declared_Object spec', spec);
|
|
25
|
+
|
|
26
|
+
throw 'stop';
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = JS_File_Declared_Object;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class JS_File_Exported_Object_Info {
|
|
2
|
+
constructor(spec = {}) {
|
|
3
|
+
|
|
4
|
+
// local name
|
|
5
|
+
// does not necessarily have one, could be imported into a numbered array
|
|
6
|
+
// but if that happens can throw exception.
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
The ast_statement node where the import is done
|
|
10
|
+
declared local (imported) variable name: the name, or false if it does not have one
|
|
11
|
+
|
|
12
|
+
Lookup: the AST for the file it was imported from
|
|
13
|
+
Then information about what was exported from that.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
So, focus on obtaining great export information, as that will be used in the process of understanding the imports.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
module.exports = JS_File_Exported_Object_Info;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const JS_File_Feature = require('./JS_File_Feature');
|
|
2
|
+
|
|
3
|
+
class JS_File_Exports extends JS_File_Feature {
|
|
4
|
+
constructor(spec = {}) {
|
|
5
|
+
spec.name = "Exports";
|
|
6
|
+
let ast_node_exports_statement;
|
|
7
|
+
let exported_object_name;
|
|
8
|
+
let value;
|
|
9
|
+
|
|
10
|
+
if (spec.name !== 'Exports') {
|
|
11
|
+
throw 'stop';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (spec.ast_node_exports_statement) {
|
|
15
|
+
ast_node_exports_statement = spec.ast_node_exports_statement;
|
|
16
|
+
}
|
|
17
|
+
super(spec);
|
|
18
|
+
|
|
19
|
+
// What a file exports is a 'feature' of the file.
|
|
20
|
+
// This 'feature' API moves further away from the JS language spec and is closer to being a conceptual representation of what the file is / does.
|
|
21
|
+
|
|
22
|
+
if (ast_node_exports_statement) {
|
|
23
|
+
//console.log('ast_node_exports_statement.type_signature', ast_node_exports_statement.type_signature);
|
|
24
|
+
|
|
25
|
+
if (ast_node_exports_statement.type_signature === 'ES(AsE(ME(ID,ID),ID))') {
|
|
26
|
+
// find_x_node_using_signature ('ES(AsE(ME(ID,ID),x))')
|
|
27
|
+
|
|
28
|
+
// May require parsing such a signature into a tree?
|
|
29
|
+
|
|
30
|
+
const x_node = ast_node_exports_statement.child_nodes[0].child_nodes[1];
|
|
31
|
+
//console.log('x_node', x_node);
|
|
32
|
+
//console.log('x_node.name', x_node.name);
|
|
33
|
+
|
|
34
|
+
exported_object_name = x_node.name;
|
|
35
|
+
|
|
36
|
+
} else {
|
|
37
|
+
throw 'NYI';
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
throw 'expected .ast_node_exports_statement'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (exported_object_name) {
|
|
44
|
+
// find the declaration of such an object.
|
|
45
|
+
//console.log('exported_object_name', exported_object_name);
|
|
46
|
+
|
|
47
|
+
// Query the js file for Declaration (or maybe Declared features)
|
|
48
|
+
|
|
49
|
+
// Would iterate through the root nodes looking for 'Declared' features.
|
|
50
|
+
// Would carry out closer examination of declarations. In the case of array decomposition would need to match the elements.
|
|
51
|
+
|
|
52
|
+
// Declared features would be useful for discovering what goes into the single object that gets exported.
|
|
53
|
+
// In many cases we will be exporting variables local to the file body.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
} else {
|
|
58
|
+
throw 'NYI';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
Object.defineProperty(this, 'value', {
|
|
63
|
+
get() { return exported_object_name; },
|
|
64
|
+
enumerable: true,
|
|
65
|
+
configurable: false
|
|
66
|
+
});
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
Object.defineProperty(this, 'exported_object_name', {
|
|
70
|
+
get() { return exported_object_name; },
|
|
71
|
+
enumerable: true,
|
|
72
|
+
configurable: false
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = JS_File_Exports;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class JS_File_Feature {
|
|
2
|
+
constructor(spec = {}) {
|
|
3
|
+
|
|
4
|
+
let name;
|
|
5
|
+
|
|
6
|
+
if (spec.name) {
|
|
7
|
+
name = spec.name;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(this, 'name', {
|
|
11
|
+
get() { return name; },
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: false
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = JS_File_Feature;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class JS_File_Imported_Object_Info {
|
|
2
|
+
constructor(spec = {}) {
|
|
3
|
+
|
|
4
|
+
// local name
|
|
5
|
+
// does not necessarily have one, could be imported into a numbered array
|
|
6
|
+
// but if that happens can throw exception.
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
The ast_statement node where the import is done
|
|
10
|
+
declared local (imported) variable name: the name, or false if it does not have one
|
|
11
|
+
|
|
12
|
+
Lookup: the AST for the file it was imported from
|
|
13
|
+
Then information about what was exported from that.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
So, focus on obtaining great export information, as that will be used in the process of understanding the imports.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
module.exports = JS_File_Imported_Object_Info;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
const {each, Evented_Class} = require('lang-mini');
|
|
2
|
+
const crypto = require('crypto');
|
|
3
|
+
|
|
4
|
+
const whitespace_chars = {
|
|
5
|
+
'32': true
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
|
|
10
|
+
const get_char_type = e_rlc => {
|
|
11
|
+
const {char, char_code} = e_rlc;
|
|
12
|
+
|
|
13
|
+
if (char_code === 32 || char_code === 9 || char_code === 13 || char_code === 10) return 'whitespace';
|
|
14
|
+
if (char === '0' || char === '1' || char === '2' || char === '3' || char === '4' || char === '5' || char === '6' || char === '7' || char === '8' || char === '9') return 'digit'
|
|
15
|
+
|
|
16
|
+
if (char === '=' || char === '<' || char === '>' || char === '(' || char === ')' || char === '{' || char === "," ||
|
|
17
|
+
char === '}' || char === '[' || char === ']' || char === ':' || char === ';' || char === '?' || char === '!' || char === '.' || char === '&' || char === '%' ||
|
|
18
|
+
char === '"' || char === '\'' || char === '|' || char === '~' || char === '#' || char === '@' ||
|
|
19
|
+
char === '+' || char === '*' || char === '/' || char === '\\' || char === '-' || char === '^') return 'punctuation'
|
|
20
|
+
if (char_code >= 65 && char_code <= 90) return 'letter' // ucase
|
|
21
|
+
if (char_code >= 97 && char_code <= 122) return 'letter' // lcase
|
|
22
|
+
if (char === '_' || char === '$') return 'letter-like';
|
|
23
|
+
console.log('char', char);
|
|
24
|
+
console.log('e_rlc', e_rlc);
|
|
25
|
+
throw 'unknown';
|
|
26
|
+
}
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
class JS_File extends Evented_Class {
|
|
30
|
+
constructor(spec = {}) {
|
|
31
|
+
super();
|
|
32
|
+
|
|
33
|
+
const rs = (() => spec.rs || undefined)();
|
|
34
|
+
const line_break_hex = (() => spec.line_break_hex || '0A')();
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
let path = spec.path;
|
|
38
|
+
|
|
39
|
+
let sha512, source;
|
|
40
|
+
|
|
41
|
+
//Object.assign(this, {
|
|
42
|
+
// body: {}
|
|
43
|
+
//})
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
Object.defineProperty(this, 'path', {
|
|
48
|
+
get() { return path; },
|
|
49
|
+
enumerable: true,
|
|
50
|
+
configurable: false
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(this, 'sha512', {
|
|
53
|
+
get() { return sha512; },
|
|
54
|
+
//set(newValue) { bValue = newValue; },
|
|
55
|
+
enumerable: true,
|
|
56
|
+
configurable: false
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(this, 'source', {
|
|
59
|
+
get() { return source; },
|
|
60
|
+
//set(newValue) { bValue = newValue; },
|
|
61
|
+
enumerable: true,
|
|
62
|
+
configurable: false
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
//if (spec.source) source = spec.source;
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
//this.on('recieve-line-char', e_rlc => {
|
|
71
|
+
// //console.log('e_rlc', e_rlc);
|
|
72
|
+
// const char_type = get_char_type(e_rlc)
|
|
73
|
+
// //console.log('char_type', char_type);
|
|
74
|
+
// /*
|
|
75
|
+
// if (!began_first_token_of_line) {
|
|
76
|
+
// if (whitespace_chars[e_rlc.char_code]) {
|
|
77
|
+
|
|
78
|
+
// } else {
|
|
79
|
+
// began_first_token_of_line = true;
|
|
80
|
+
// }
|
|
81
|
+
// }
|
|
82
|
+
// */
|
|
83
|
+
//})
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
if (rs) {
|
|
88
|
+
this.on('complete-file-recieved', (e_end) => {
|
|
89
|
+
const {str_all} = e_end;
|
|
90
|
+
//console.log('e_end', e_end);
|
|
91
|
+
|
|
92
|
+
// Work out the hash value here?
|
|
93
|
+
|
|
94
|
+
//sha512 = e_end.sha512;
|
|
95
|
+
source = str_all;
|
|
96
|
+
//console.log('source', source);
|
|
97
|
+
//throw 'stop';
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
// Wait for subclass listeners to be set up.
|
|
101
|
+
//setTimeout(() => {
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
// Interpret it in chunks.
|
|
105
|
+
// Read it line by line, after character by character.
|
|
106
|
+
// Very event driven parser, or partial parser at least.
|
|
107
|
+
|
|
108
|
+
//let buf1;
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
// An array of tokens as strings???
|
|
115
|
+
|
|
116
|
+
// Or just be able to identify the first tokens?
|
|
117
|
+
// The part before the equals sign?
|
|
118
|
+
|
|
119
|
+
// Best to creat OO oprogrammatic objects from these.
|
|
120
|
+
// But maybe best to use an existing parsing tool.
|
|
121
|
+
|
|
122
|
+
// Identifying all variable declarations may be possible.
|
|
123
|
+
// All function calls too...
|
|
124
|
+
|
|
125
|
+
// Identifying all local variable references.
|
|
126
|
+
// Putting it into JS objects would make sense.
|
|
127
|
+
// Into highly OO JS objects in the right structure.
|
|
128
|
+
|
|
129
|
+
// Could raise an event whenever it finds a token.
|
|
130
|
+
// Then will need to make sense of these tokens.
|
|
131
|
+
|
|
132
|
+
// Being able to get a list of which declarations were made where in the code would helo.
|
|
133
|
+
|
|
134
|
+
// block, conditional, switch, loop
|
|
135
|
+
|
|
136
|
+
// Maybe an existing parser would make a lot more sense.
|
|
137
|
+
// Be better able to identify
|
|
138
|
+
|
|
139
|
+
// https://esprima.org/
|
|
140
|
+
//
|
|
141
|
+
|
|
142
|
+
//console.log('rs', rs);
|
|
143
|
+
|
|
144
|
+
rs.on('data', chunk => {
|
|
145
|
+
//if (!buf1) {buf1 = chunk} else {
|
|
146
|
+
// buf1 = Buffer.concat([buf1, chunk]);
|
|
147
|
+
const l = chunk.length;
|
|
148
|
+
//console.log('l', l);
|
|
149
|
+
for (let c = 0; c < l; c++) {
|
|
150
|
+
this.raise('recieve-byte', {
|
|
151
|
+
byte_value: chunk.readUInt8(c)
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
//}
|
|
155
|
+
});
|
|
156
|
+
let ast;
|
|
157
|
+
|
|
158
|
+
rs.on('end', e_end => {
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
//console.log('arr_lines.length', arr_lines.length);
|
|
163
|
+
this.raise('input-stream-end', {
|
|
164
|
+
//str_all: str_all,
|
|
165
|
+
//sha512: gen_hash
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
this.raise('ready');
|
|
169
|
+
});
|
|
170
|
+
//}, 0);
|
|
171
|
+
// then divide by line break character?
|
|
172
|
+
// not sure of the formating, probably unicode.
|
|
173
|
+
} else {
|
|
174
|
+
|
|
175
|
+
// may have been given the source in the constructor.
|
|
176
|
+
|
|
177
|
+
throw 'stop';
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Worth being able to load this abstraction from the string text too.
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
JS_File.load_from_stream = (rs, path) => {
|
|
187
|
+
const res = new JS_File({rs: rs, path: path});
|
|
188
|
+
return res;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
JS_File.load_from_path = (path) => {
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Interpret / arrange a file in terms of the other objects within this system.
|
|
196
|
+
|
|
197
|
+
// References at the beginning - will also work in terms of references to declarations, platforms, and declaration sequences.
|
|
198
|
+
|
|
199
|
+
// Make it operate in a streaming way?
|
|
200
|
+
// Event driven too?
|
|
201
|
+
// So it can have events as it goes through the file or the stream.
|
|
202
|
+
module.exports = JS_File;
|