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,70 @@
|
|
|
1
|
+
// May be irrelevant / directly equivalent with Platform.
|
|
2
|
+
// Platform should be able to contain multiple platforms.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
// Acts as an array / collection of platforms. Will use enumerator.
|
|
6
|
+
const {tof, each, Evented_Class} = require('lang-mini');
|
|
7
|
+
|
|
8
|
+
// A platform can require a variety of other platforms under it.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Platforms extends Evented_Class {
|
|
13
|
+
constructor(spec = {}) {
|
|
14
|
+
// Each platform has a scope level.
|
|
15
|
+
super(spec);
|
|
16
|
+
|
|
17
|
+
let arr_requires = [];
|
|
18
|
+
let arr_platforms = [];
|
|
19
|
+
|
|
20
|
+
const tsr = tof(spec.requires);
|
|
21
|
+
if (tsr === 'string') {
|
|
22
|
+
arr_requires.push(spec.requires);
|
|
23
|
+
} else {
|
|
24
|
+
if (tsr === 'array') {
|
|
25
|
+
each(spec.requires, item => spec.requires.push(item));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// Platforms is one of the main thing that a project contains.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// Can require platforms
|
|
32
|
+
// Can require single functions???
|
|
33
|
+
// In that case it would require the smallest platform that contains it, or it fishes the function out.
|
|
34
|
+
// Looks like we need tests for if a function is inline.
|
|
35
|
+
|
|
36
|
+
if (spec.platforms) {
|
|
37
|
+
const t = spec.platforms;
|
|
38
|
+
if (t === 'array') {
|
|
39
|
+
each(spec.platforms, platform => arr_platforms.push(platform));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
console.log('arr_requires', arr_requires);
|
|
44
|
+
console.log('arr_platforms', arr_platforms);
|
|
45
|
+
|
|
46
|
+
this.push = platform => {
|
|
47
|
+
const idx = arr_platforms.length;
|
|
48
|
+
arr_platforms.push(platform);
|
|
49
|
+
this.raise('change', {
|
|
50
|
+
'type': 'add',
|
|
51
|
+
'value': platform
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
// Still need the simple exports info
|
|
57
|
+
// despite it possibly being complex to get that info
|
|
58
|
+
//
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
// A bunch of local variables get defined within each platform.
|
|
64
|
+
|
|
65
|
+
// Make a platform about providing variables.
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = Platforms;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
|
|
2
|
+
// Will be a space where a load of JS can be loaded within.
|
|
3
|
+
// Loaded from different places.
|
|
4
|
+
|
|
5
|
+
// Load JS file into the project.
|
|
6
|
+
// Be able to then reference functions from that file.
|
|
7
|
+
// Or then load the functions individually?
|
|
8
|
+
// Could load a whole load of them / category.
|
|
9
|
+
// Or
|
|
10
|
+
|
|
11
|
+
const {each, Evented_Class} = require('lang-mini');
|
|
12
|
+
|
|
13
|
+
//const JS_File = require('./JS_File_Core');
|
|
14
|
+
const Platforms = require('./Platforms');
|
|
15
|
+
|
|
16
|
+
class Project extends Evented_Class {
|
|
17
|
+
|
|
18
|
+
// This will act as an overall library of JS functions.
|
|
19
|
+
// A project can have multiple builds?
|
|
20
|
+
|
|
21
|
+
// Or a build is basically the output of a platform. The platform gets put together, has the code ordering, can do things internally too.
|
|
22
|
+
// platform.build
|
|
23
|
+
|
|
24
|
+
// or it's a platform that meets conditions.
|
|
25
|
+
|
|
26
|
+
// A project could have different output files.
|
|
27
|
+
// For the moment, focus more on bringing together input.
|
|
28
|
+
// Arrange inputs to get output.
|
|
29
|
+
|
|
30
|
+
// Project-wide list / index of variable names
|
|
31
|
+
// The variable names inside classes too.
|
|
32
|
+
|
|
33
|
+
// Project-wide substitution of variable names for shorter ones
|
|
34
|
+
// Ongoing calculations of savings.
|
|
35
|
+
|
|
36
|
+
// Main thing will be to go further on code extraction - have the system able to deal with pieces of code, that it knows are required by something, to be
|
|
37
|
+
// dealt with in abstract ways.
|
|
38
|
+
|
|
39
|
+
// Named platforms make sense.
|
|
40
|
+
// Combining multiple platforms into one platform.
|
|
41
|
+
// Application code sits on top of those platforms.
|
|
42
|
+
|
|
43
|
+
// Moving closer towards a project system where JavaScript code gets put together.
|
|
44
|
+
// Want the jsgui build project to be really simple, much / most of it done using the structures built into the system.
|
|
45
|
+
// Maybe this is where structure definitions will be loaded.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
// The platform that is used as
|
|
61
|
+
|
|
62
|
+
constructor(spec) {
|
|
63
|
+
super(spec = {});
|
|
64
|
+
|
|
65
|
+
// The most outer layer.
|
|
66
|
+
|
|
67
|
+
// Load files into here...?
|
|
68
|
+
// Files exist independently within the project space.
|
|
69
|
+
|
|
70
|
+
// map of files by path?
|
|
71
|
+
|
|
72
|
+
// or by name, its equivalent.
|
|
73
|
+
|
|
74
|
+
const platforms = new Platforms();
|
|
75
|
+
|
|
76
|
+
platforms.on('change', e_change => {
|
|
77
|
+
console.log('platforms e_change', e_change);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
Object.defineProperty(this, 'platforms', {
|
|
81
|
+
get() { return platforms; },
|
|
82
|
+
//set(newValue) { bValue = newValue; },
|
|
83
|
+
enumerable: true,
|
|
84
|
+
configurable: false
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
//add_js_file(js_file) {
|
|
89
|
+
|
|
90
|
+
//}
|
|
91
|
+
//remove_js_file(js_file) {
|
|
92
|
+
|
|
93
|
+
//}
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// load_js_file
|
|
98
|
+
// then it knows the names of the root level functions.
|
|
99
|
+
|
|
100
|
+
// when loading JS files, it should be able to tell how they relate to each other.
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
module.exports = Project;
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// A reference within a file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// A sequence / set of references. Often / should be at the beginning of the file.
|
|
2
|
+
|
|
3
|
+
// Should correspond to named functions - but would start out as references to the files.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Reference_Sequence {
|
|
7
|
+
constructor(spec) {
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = Reference_Sequence;
|
|
16
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const {each, Evented_Class} = require('lang-mini');
|
|
2
|
+
const Declaration_Sequence = require('./Abstract_Single_Declaration_Sequence');
|
|
3
|
+
|
|
4
|
+
class Scope extends Evented_Class {
|
|
5
|
+
|
|
6
|
+
// Generally will be a block scope.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// Declarations are within scope.
|
|
10
|
+
// Only Declarations?
|
|
11
|
+
|
|
12
|
+
// Declarations are what matter for the moment.
|
|
13
|
+
|
|
14
|
+
constructor(spec) {
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const declarations = new Declaration_Sequence();
|
|
18
|
+
|
|
19
|
+
Object.defineProperty(this, 'declarations', {
|
|
20
|
+
get() { return declarations; },
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: false
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports = Scope;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
class Variable_Name_Provider { //Namer
|
|
2
|
+
constructor(spec = {}) {
|
|
3
|
+
|
|
4
|
+
const reserved = {};
|
|
5
|
+
|
|
6
|
+
Object.defineProperty(this, 'reserved', {
|
|
7
|
+
get() { return reserved; },
|
|
8
|
+
//set(newValue) { bValue = newValue; },
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: false
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// for the moment, x, and then a letter.
|
|
14
|
+
|
|
15
|
+
const map_counts = {
|
|
16
|
+
'l': 0,
|
|
17
|
+
'x': 0,
|
|
18
|
+
'p': 0,
|
|
19
|
+
'a': 0
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
// l as well for local
|
|
24
|
+
|
|
25
|
+
this.get_l = () => {
|
|
26
|
+
return 'l' + map_counts['l']++
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
this.get_x = () => {
|
|
30
|
+
return 'x' + map_counts['x']++
|
|
31
|
+
}
|
|
32
|
+
this.get_p = () => {
|
|
33
|
+
return 'p' + map_counts['p']++
|
|
34
|
+
}
|
|
35
|
+
this.get_a = () => {
|
|
36
|
+
return 'a' + map_counts['a']++
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = Variable_Name_Provider;
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// Could do this in a simpler way than full AST manipulation.
|
|
2
|
+
|
|
3
|
+
// Want to write out jsgui in such a way that the lower levels are all accessed as local functions and objects within an inner scope.
|
|
4
|
+
|
|
5
|
+
const {each, Evented_Class} = require('lang-mini');
|
|
6
|
+
//const { default: JS_Builder } = require('./JS_Builder');
|
|
7
|
+
|
|
8
|
+
// Interpret / arrange a file in terms of the other objects within this system.
|
|
9
|
+
|
|
10
|
+
// References at the beginning - will also work in terms of references to declarations, platforms, and declaration sequences.
|
|
11
|
+
|
|
12
|
+
// Make it operate in a streaming way?
|
|
13
|
+
// Event driven too?
|
|
14
|
+
// So it can have events as it goes through the file or the stream.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const whitespace_chars = {
|
|
18
|
+
'32': true
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const get_char_type = e_rlc => {
|
|
22
|
+
const {char, char_code} = e_rlc;
|
|
23
|
+
|
|
24
|
+
if (char_code === 32 || char_code === 9) return 'whitespace';
|
|
25
|
+
if (char === '0' || char === '1' || char === '2' || char === '3' || char === '4' || char === '5' || char === '6' || char === '7' || char === '8' || char === '9') return 'digit'
|
|
26
|
+
if (char === '<' || char === '>' || char === '(' || char === ')' || char === '{' ||
|
|
27
|
+
char === '}' || char === ':' || char === ';' || char === '?' || char === '!' || char === '.' ||
|
|
28
|
+
char === '"' || char === '\'' || char === '|' || char === '~' || char === '#' ||
|
|
29
|
+
char === '+' || char === '*' || char === '/' || char === '\\' || char === '-') return 'punctuation'
|
|
30
|
+
if (char_code >= 65 && char_code <= 90) return 'letter' // ucase
|
|
31
|
+
if (char_code >= 97 && char_code <= 122) return 'letter' // lcase
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
throw 'unknown';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// token types: number
|
|
39
|
+
|
|
40
|
+
// May be best to use an existing full AST tokeniser and parser.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class JS_File extends Evented_Class {
|
|
48
|
+
constructor(spec = {}) {
|
|
49
|
+
super();
|
|
50
|
+
|
|
51
|
+
const rs = (() => spec.rs || undefined)();
|
|
52
|
+
const line_break_hex = (() => spec.line_break_hex || '0A')();
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
//this.on('readline', e_readline => {
|
|
57
|
+
|
|
58
|
+
//});
|
|
59
|
+
|
|
60
|
+
if (rs) {
|
|
61
|
+
// Interpret it in chunks.
|
|
62
|
+
// Read it line by line, after character by character.
|
|
63
|
+
// Very event driven parser, or partial parser at least.
|
|
64
|
+
|
|
65
|
+
//let buf1;
|
|
66
|
+
|
|
67
|
+
const ta_line_buffer = new Uint8Array(1024);
|
|
68
|
+
let byte_in_line_num = 0;
|
|
69
|
+
|
|
70
|
+
let line_num = 0;
|
|
71
|
+
let last_recieved_byte;
|
|
72
|
+
let recieved_byte;
|
|
73
|
+
// Separate the chunks and the raise an event for each line.
|
|
74
|
+
// Charactrer by character???
|
|
75
|
+
|
|
76
|
+
// Array or something of the tokens?
|
|
77
|
+
|
|
78
|
+
//let first_token_of_line_char_pos = -1;
|
|
79
|
+
let began_first_token_of_line = false;
|
|
80
|
+
|
|
81
|
+
// An array of tokens as strings???
|
|
82
|
+
|
|
83
|
+
// Or just be able to identify the first tokens?
|
|
84
|
+
// The part before the equals sign?
|
|
85
|
+
|
|
86
|
+
// Best to creat OO oprogrammatic objects from these.
|
|
87
|
+
// But maybe best to use an existing parsing tool.
|
|
88
|
+
|
|
89
|
+
// Identifying all variable declarations may be possible.
|
|
90
|
+
// All function calls too...
|
|
91
|
+
|
|
92
|
+
// Identifying all local variable references.
|
|
93
|
+
// Putting it into JS objects would make sense.
|
|
94
|
+
// Into highly OO JS objects in the right structure.
|
|
95
|
+
|
|
96
|
+
// Could raise an event whenever it finds a token.
|
|
97
|
+
// Then will need to make sense of these tokens.
|
|
98
|
+
|
|
99
|
+
// Being able to get a list of which declarations were made where in the code would helo.
|
|
100
|
+
|
|
101
|
+
// block, conditional, switch, loop
|
|
102
|
+
|
|
103
|
+
// Maybe an existing parser would make a lot more sense.
|
|
104
|
+
// Be better able to identify
|
|
105
|
+
|
|
106
|
+
// https://esprima.org/
|
|
107
|
+
//
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
this.on('recieve-line-char', e_rlc => {
|
|
115
|
+
console.log('e_rlc', e_rlc);
|
|
116
|
+
const char_type = get_char_type(e_rlc)
|
|
117
|
+
console.log('char_type', char_type);
|
|
118
|
+
/*
|
|
119
|
+
if (!began_first_token_of_line) {
|
|
120
|
+
if (whitespace_chars[e_rlc.char_code]) {
|
|
121
|
+
|
|
122
|
+
} else {
|
|
123
|
+
began_first_token_of_line = true;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
this.on('recieve-line', e_recieve_line => {
|
|
132
|
+
console.log('e_recieve_line', e_recieve_line);
|
|
133
|
+
|
|
134
|
+
// and strip the tabs and whitespace.
|
|
135
|
+
|
|
136
|
+
// process the line character by character.
|
|
137
|
+
|
|
138
|
+
//console.log('e_recieve_linestr', str);
|
|
139
|
+
|
|
140
|
+
// And break up the line into statements;
|
|
141
|
+
|
|
142
|
+
const s = e_recieve_line.str, l = s.length;
|
|
143
|
+
for (let c = 0; c < l; c++) {
|
|
144
|
+
const ch = s[c];
|
|
145
|
+
this.raise('recieve-line-char', {
|
|
146
|
+
line_num: line_num,
|
|
147
|
+
char: ch,
|
|
148
|
+
char_code: s.charCodeAt(c)
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
console.log('rs', rs);
|
|
156
|
+
this.on('recieve-byte', e_receive_byte => {
|
|
157
|
+
last_recieved_byte = recieved_byte;
|
|
158
|
+
recieved_byte = e_receive_byte.byte_value;
|
|
159
|
+
ta_line_buffer[byte_in_line_num++] = recieved_byte;
|
|
160
|
+
//console.log('e_receive_byte', e_receive_byte);
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
if (recieved_byte === 10) {
|
|
165
|
+
// lf
|
|
166
|
+
if (last_recieved_byte === 13) {
|
|
167
|
+
// cr, for windows
|
|
168
|
+
|
|
169
|
+
const line_until_crlf = new Uint8Array(ta_line_buffer.subarray(0, byte_in_line_num - 2));
|
|
170
|
+
|
|
171
|
+
this.raise('recieve-line', {
|
|
172
|
+
ta_line: line_until_crlf,
|
|
173
|
+
bytes_length: byte_in_line_num,
|
|
174
|
+
str: String.fromCharCode.apply(null, line_until_crlf)
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
} else {
|
|
178
|
+
|
|
179
|
+
const line_until_lf = new Uint8Array(ta_line_buffer.subarray(0, byte_in_line_num - 1));
|
|
180
|
+
this.raise('recieve-line', {
|
|
181
|
+
ta_line: line_until_lf,
|
|
182
|
+
bytes_length: byte_in_line_num,
|
|
183
|
+
str: String.fromCharCode.apply(null, line_until_lf)
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
|
+
ta_line_buffer.fill(0);
|
|
187
|
+
line_num++;
|
|
188
|
+
byte_in_line_num = 0;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
rs.on('data', chunk => {
|
|
196
|
+
//if (!buf1) {buf1 = chunk} else {
|
|
197
|
+
// buf1 = Buffer.concat([buf1, chunk]);
|
|
198
|
+
const l = chunk.length;
|
|
199
|
+
console.log('l', l);
|
|
200
|
+
for (let c = 0; c < l; c++) {
|
|
201
|
+
this.raise('recieve-byte', {
|
|
202
|
+
byte_value: chunk.readUInt8(c)
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
//}
|
|
206
|
+
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// then divide by line break character?
|
|
210
|
+
// not sure of the formating, probably unicode.
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
JS_File.load_from_stream = (rs) => {
|
|
220
|
+
const res = new JS_File({rs: rs});
|
|
221
|
+
}
|
|
222
|
+
JS_File.load_from_path = (path) => {
|
|
223
|
+
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
module.exports = JS_File;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
|
|
2
|
+
const type_abbreviations = {
|
|
3
|
+
//'ArrowFunctionExpression': 'AFE',
|
|
4
|
+
'ArrowFunctionExpression': 'AFE',
|
|
5
|
+
'AssignmentExpression': 'AsE',
|
|
6
|
+
'AssignmentPattern': 'AsP',
|
|
7
|
+
'ArrayExpression': 'ArE',
|
|
8
|
+
'ArrayPattern': 'ArP',
|
|
9
|
+
'BinaryExpression': 'BE',
|
|
10
|
+
'BlockStatement': 'BS',
|
|
11
|
+
'BooleanLiteral': 'BL',
|
|
12
|
+
'CallExpression': 'CE', // change to CaE? Need to change sigs being looked for.
|
|
13
|
+
'ClassBody': 'CB',
|
|
14
|
+
'ClassDeclaration': 'CD',
|
|
15
|
+
'ClassMethod': 'CM',
|
|
16
|
+
'ConditionalExpression': 'CoE',
|
|
17
|
+
'EmptyStatement': '__',
|
|
18
|
+
'ExpressionStatement': 'ES',
|
|
19
|
+
'File': 'F',
|
|
20
|
+
'ForStatement': 'FS',
|
|
21
|
+
'FunctionExpression': 'FE',
|
|
22
|
+
'Identifier': 'ID',
|
|
23
|
+
'IfStatement': 'IS',
|
|
24
|
+
'LogicalExpression': 'LE',
|
|
25
|
+
'MemberExpression': 'ME',
|
|
26
|
+
'NullLiteral': 'null',
|
|
27
|
+
'NumericLiteral': 'NumL',
|
|
28
|
+
'NewExpression': 'NE',
|
|
29
|
+
'ObjectExpression': 'OE',
|
|
30
|
+
'ObjectMethod': 'OM',
|
|
31
|
+
'ObjectPattern': 'OPa',
|
|
32
|
+
'ObjectProperty': 'OPr',
|
|
33
|
+
'Program': 'P',
|
|
34
|
+
'ReturnStatement': 'RS',
|
|
35
|
+
'StringLiteral': 'SL',
|
|
36
|
+
'Super': 'S',
|
|
37
|
+
'ThisExpression': 'TE',
|
|
38
|
+
'ThrowStatement': 'TS',
|
|
39
|
+
'UnaryExpression': 'UnE',
|
|
40
|
+
'UpdateExpression': 'UpE',
|
|
41
|
+
'VariableDeclaration': 'VDn',
|
|
42
|
+
'VariableDeclarator': 'VDr',
|
|
43
|
+
'WhileStatement': 'WS'
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ArrowFunctionExpression
|
|
47
|
+
|
|
48
|
+
const map_expression_categories = {
|
|
49
|
+
'ArrowFunctionExpression': true,
|
|
50
|
+
'AssignmentExpression': true,
|
|
51
|
+
'ArrayExpression': true,
|
|
52
|
+
'BinaryExpression': true,
|
|
53
|
+
'CallExpression': true,
|
|
54
|
+
'ConditionalExpression': true,
|
|
55
|
+
// ExpressionStatement false because it's a statement
|
|
56
|
+
'FunctionExpression': true,
|
|
57
|
+
'LogicalExpression': true,
|
|
58
|
+
'MemberExpression': true,
|
|
59
|
+
'NewExpression': true,
|
|
60
|
+
'ObjectExpression': true,
|
|
61
|
+
'ThisExpression': true,
|
|
62
|
+
'UnaryExpression': true,
|
|
63
|
+
'UpdateExpression': true
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const map_literal_categories = {
|
|
67
|
+
'BooleanLiteral': true,
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
'NullLiteral': true,
|
|
71
|
+
'NumericLiteral': true,
|
|
72
|
+
'StringLiteral': true
|
|
73
|
+
|
|
74
|
+
// Must be more
|
|
75
|
+
|
|
76
|
+
// ExpressionStatement false because it's a statement
|
|
77
|
+
/*
|
|
78
|
+
'FunctionExpression': true,
|
|
79
|
+
'LogicalExpression': true,
|
|
80
|
+
'MemberExpression': true,
|
|
81
|
+
'NewExpression': true,
|
|
82
|
+
'ObjectExpression': true,
|
|
83
|
+
'ThisExpression': true,
|
|
84
|
+
'UnaryExpression': true,
|
|
85
|
+
'UpdateExpression': true
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const map_statement_categories = {
|
|
91
|
+
BlockStatement: true,
|
|
92
|
+
EmptyStatement: true,
|
|
93
|
+
ExpressionStatement: true,
|
|
94
|
+
ForStatement: true,
|
|
95
|
+
ReturnStatement: true,
|
|
96
|
+
ThrowStatement: true,
|
|
97
|
+
WhileStatement: true
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const map_categories = {
|
|
101
|
+
//'ArrowFunctionExpression': 'AFE',
|
|
102
|
+
'ArrowFunctionExpression': 'Expression',
|
|
103
|
+
'AssignmentExpression': 'Expression',
|
|
104
|
+
'AssignmentPattern': 'Pattern',
|
|
105
|
+
'ArrayExpression': 'Expression',
|
|
106
|
+
'ArrayPattern': 'APPattern',
|
|
107
|
+
'BinaryExpression': 'Expression',
|
|
108
|
+
'BlockStatement': 'Statement',
|
|
109
|
+
'BooleanLiteral': 'Literal',
|
|
110
|
+
'CallExpression': 'Expression',
|
|
111
|
+
'ClassBody': 'Body',
|
|
112
|
+
'ClassDeclaration': 'Declaration',
|
|
113
|
+
'ClassMethod': 'Method',
|
|
114
|
+
'ConditionalExpression': 'Expression',
|
|
115
|
+
'EmptyStatement': 'Statement',
|
|
116
|
+
'ExpressionStatement': 'Statement',
|
|
117
|
+
'ForStatement': 'Statement',
|
|
118
|
+
'File': 'File',
|
|
119
|
+
'FunctionExpression': 'Expression',
|
|
120
|
+
'Identifier': 'Identifier',
|
|
121
|
+
'IfStatement': 'Statement',
|
|
122
|
+
'LogicalExpression': 'Expression',
|
|
123
|
+
'MemberExpression': 'Expression',
|
|
124
|
+
'NullLiteral': 'Literal',
|
|
125
|
+
'NumericLiteral': 'Literal',
|
|
126
|
+
'NewExpression': 'Expression',
|
|
127
|
+
'ObjectExpression': 'Expression',
|
|
128
|
+
'ObjectMethod': 'Method',
|
|
129
|
+
'ObjectPattern': 'Pattern',
|
|
130
|
+
'ObjectProperty': 'Property',
|
|
131
|
+
'Program': 'Program',
|
|
132
|
+
'ReturnStatement': 'Statement',
|
|
133
|
+
'StringLiteral': 'Literal',
|
|
134
|
+
'Super': 'Super',
|
|
135
|
+
'ThisExpression': 'Expression',
|
|
136
|
+
'ThrowStatement': 'Statement',
|
|
137
|
+
'UnaryExpression': 'Expression',
|
|
138
|
+
'UpdateExpression': 'Expression',
|
|
139
|
+
'VariableDeclaration': 'Declaration',
|
|
140
|
+
'VariableDeclarator': 'Declarator',
|
|
141
|
+
'WhileStatement': 'Statement'
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
module.exports = {
|
|
145
|
+
type_abbreviations: type_abbreviations,
|
|
146
|
+
map_expression_categories: map_expression_categories,
|
|
147
|
+
map_literal_categories: map_literal_categories,
|
|
148
|
+
map_categories: map_categories,
|
|
149
|
+
map_statement_categories: map_statement_categories
|
|
150
|
+
}
|