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
@@ -1,105 +1,105 @@
1
-
2
- var path = require('path'),
3
- fs = require('fs'),
4
- url = require('url'),
5
- jsgui = require('jsgui3-html'),
6
- os = require('os'),
7
- http = require('http'),
8
- libUrl = require('url'),
9
- Resource = jsgui.Resource,
10
- Cookies = require('cookies'),
11
- fs2 = require('../fs2');
12
-
13
-
14
-
15
- var stringify = jsgui.stringify,
16
- each = jsgui.each,
17
- arrayify = jsgui.arrayify,
18
- tof = jsgui.tof;
19
- var filter_map_by_regex = jsgui.filter_map_by_regex;
20
- var Class = jsgui.Class,
21
- Data_Object = jsgui.Data_Object,
22
- Enhanced_Data_Object = jsgui.Enhanced_Data_Object;
23
- var fp = jsgui.fp,
24
- is_defined = jsgui.is_defined;
25
- var Collection = jsgui.Collection;
26
-
27
- // Extends AutoStart_Resource?
28
-
29
- // May need to change around a fair few references to make it workable.
30
- // May need some more complicated logic to change it to the path for service.
31
-
32
- // Possibly Data_Resource could provide images which go alongside the data.
33
- // Icons to represent data.
34
- // Could make use of the image resource in order to do this.
35
- // An image resource could use / be a data resource that provides access to images.
36
-
37
- // Ideally want it like image keys, then options for max size and also quality.
38
- //
39
-
40
-
41
- class Data_Resource extends Resource {
42
-
43
- constructor(spec) {
44
- super(spec);
45
- //this.meta.set('custom_paths', new Data_Object({}));
46
- this.custom_paths = new Data_Object({});
47
- this.data = {};
48
- // want to be able to set specific pieces of data to be available.
49
- // This won't be a full DB API, but a starting point for the client-side app to communicate with the server.
50
- // It will interact with a data model through this.
51
- }
52
- 'start'(callback) {
53
- callback(null, true);
54
- }
55
- 'process'(req, res) {
56
- console.log('Data_Resource processing HTTP request');
57
- var remoteAddress = req.connection.remoteAddress;
58
- var custom_paths = this.custom_paths;
59
- var rurl = req.url;
60
- var pool = this.pool;
61
- // should have a bunch of resources from the pool.
62
-
63
- //var pool_resources = pool.resources();
64
- //console.log('pool_resources ' + stringify(pool_resources));
65
- var url_parts = url.parse(req.url, true);
66
- //console.log('url_parts ' + stringify(url_parts));
67
- var splitPath = url_parts.path.substr(1).split('/');
68
- //console.log('resource site data splitPath ' + stringify(splitPath));
69
- if (rurl.substr(0, 1) == '/') rurl = rurl.substr(1);
70
- rurl = rurl.replace(/\./g, '☺');
71
- //console.log('rurl ' + rurl);
72
-
73
- if (splitPath.length === 2) {
74
- if (splitPath[0] === 'data') {
75
- let key = splitPath[1], value = this.data[key], t_val = tof(value);
76
- //console.log('t_val', t_val);
77
- // Other types of data?
78
- if (t_val === 'buffer') {
79
- // Encode it as hex / baase64?
80
-
81
- // Client was expecting text I think.
82
- // We'll get the data to the client, and have a relatively easy way of making server-side data available to the client.
83
-
84
- // probably best to send back binary data?
85
-
86
- var mime_type = 'application/octet-stream';
87
- //console.log('mime_type ' + mime_type);
88
- res.writeHead(200, {
89
- 'Content-Type': mime_type
90
- });
91
- res.end(value);
92
- }
93
- }
94
- }
95
- // Could consult a map of values to send back.
96
- // A prefixed map would be fine for some applications.
97
- }
98
- }
99
-
100
-
101
- //return Site_CSS;
102
-
103
-
104
- //});
1
+
2
+ var path = require('path'),
3
+ fs = require('fs'),
4
+ url = require('url'),
5
+ jsgui = require('jsgui3-html'),
6
+ os = require('os'),
7
+ http = require('http'),
8
+ libUrl = require('url'),
9
+ Resource = jsgui.Resource,
10
+ Cookies = require('cookies'),
11
+ fs2 = require('../fs2');
12
+
13
+
14
+
15
+ var stringify = jsgui.stringify,
16
+ each = jsgui.each,
17
+ arrayify = jsgui.arrayify,
18
+ tof = jsgui.tof;
19
+ var filter_map_by_regex = jsgui.filter_map_by_regex;
20
+ var Class = jsgui.Class,
21
+ Data_Object = jsgui.Data_Object,
22
+ Enhanced_Data_Object = jsgui.Enhanced_Data_Object;
23
+ var fp = jsgui.fp,
24
+ is_defined = jsgui.is_defined;
25
+ var Collection = jsgui.Collection;
26
+
27
+ // Extends AutoStart_Resource?
28
+
29
+ // May need to change around a fair few references to make it workable.
30
+ // May need some more complicated logic to change it to the path for service.
31
+
32
+ // Possibly Data_Resource could provide images which go alongside the data.
33
+ // Icons to represent data.
34
+ // Could make use of the image resource in order to do this.
35
+ // An image resource could use / be a data resource that provides access to images.
36
+
37
+ // Ideally want it like image keys, then options for max size and also quality.
38
+ //
39
+
40
+
41
+ class Data_Resource extends Resource {
42
+
43
+ constructor(spec) {
44
+ super(spec);
45
+ //this.meta.set('custom_paths', new Data_Object({}));
46
+ this.custom_paths = new Data_Object({});
47
+ this.data = {};
48
+ // want to be able to set specific pieces of data to be available.
49
+ // This won't be a full DB API, but a starting point for the client-side app to communicate with the server.
50
+ // It will interact with a data model through this.
51
+ }
52
+ 'start'(callback) {
53
+ callback(null, true);
54
+ }
55
+ 'process'(req, res) {
56
+ console.log('Data_Resource processing HTTP request');
57
+ var remoteAddress = req.connection.remoteAddress;
58
+ var custom_paths = this.custom_paths;
59
+ var rurl = req.url;
60
+ var pool = this.pool;
61
+ // should have a bunch of resources from the pool.
62
+
63
+ //var pool_resources = pool.resources();
64
+ //console.log('pool_resources ' + stringify(pool_resources));
65
+ var url_parts = url.parse(req.url, true);
66
+ //console.log('url_parts ' + stringify(url_parts));
67
+ var splitPath = url_parts.path.substr(1).split('/');
68
+ //console.log('resource site data splitPath ' + stringify(splitPath));
69
+ if (rurl.substr(0, 1) == '/') rurl = rurl.substr(1);
70
+ rurl = rurl.replace(/\./g, '☺');
71
+ //console.log('rurl ' + rurl);
72
+
73
+ if (splitPath.length === 2) {
74
+ if (splitPath[0] === 'data') {
75
+ let key = splitPath[1], value = this.data[key], t_val = tof(value);
76
+ //console.log('t_val', t_val);
77
+ // Other types of data?
78
+ if (t_val === 'buffer') {
79
+ // Encode it as hex / baase64?
80
+
81
+ // Client was expecting text I think.
82
+ // We'll get the data to the client, and have a relatively easy way of making server-side data available to the client.
83
+
84
+ // probably best to send back binary data?
85
+
86
+ var mime_type = 'application/octet-stream';
87
+ //console.log('mime_type ' + mime_type);
88
+ res.writeHead(200, {
89
+ 'Content-Type': mime_type
90
+ });
91
+ res.end(value);
92
+ }
93
+ }
94
+ }
95
+ // Could consult a map of values to send back.
96
+ // A prefixed map would be fine for some applications.
97
+ }
98
+ }
99
+
100
+
101
+ //return Site_CSS;
102
+
103
+
104
+ //});
105
105
  module.exports = Data_Resource;
@@ -1,149 +1,149 @@
1
- /*
2
- if (typeof define !== 'function') {
3
- var define = require('amdefine')(module);
4
- }
5
-
6
- define(['module', 'path', 'fs', 'url', '../../web/jsgui-html', 'os', 'http', 'url', './resource',
7
- '../../web/jsgui-je-suis-xml', 'cookies', '../../fs/jsgui-node-fs2-core'],
8
-
9
- function(module, path, fs, url, jsgui, os, http, libUrl,
10
- Resource, JeSuisXML, Cookies, fs2) {
11
- */
12
-
13
- var libpath = require('path'),
14
- fs = require('fs'),
15
- url = require('url'),
16
- //jsgui = require('jsgui3-html'),
17
- os = require('os'),
18
- http = require('http'),
19
- libUrl = require('url'),
20
- jsgui = require('jsgui3-html')
21
- Resource = jsgui.Resource,
22
- Cookies = require('cookies'),
23
- fs2 = require('../fs2');
24
-
25
-
26
- /*
27
-
28
- var stringify = jsgui.stringify,
29
- each = jsgui.each,
30
- arrayify = jsgui.arrayify,
31
- tof = jsgui.tof;
32
- var filter_map_by_regex = jsgui.filter_map_by_regex;
33
- var Class = jsgui.Class,
34
- Data_Object = jsgui.Data_Object,
35
- Enhanced_Data_Object = jsgui.Enhanced_Data_Object;
36
- var fp = jsgui.fp,
37
- is_defined = jsgui.is_defined;
38
- var Collection = jsgui.Collection;
39
- */
40
- // Extends AutoStart_Resource?
41
-
42
- // May need to change around a fair few references to make it workable.
43
- // May need some more complicated logic to change it to the path for service.
44
-
45
- const fnl = require('fnl');
46
- const obs_or_cb = fnl.obs_or_cb;
47
-
48
- const fnlfs = require('fnlfs');
49
-
50
- // Cloud_FS_Resource
51
- // SFTP_FS_Resource
52
-
53
-
54
- // Publishing an FS resource would enable a directory browsing app.
55
- // File_Tree, and connect to the client-side Data_Resource.
56
-
57
-
58
-
59
- const {
60
- is_directory, dir_contents
61
- } = fnlfs;
62
-
63
- // This Resource looks to be in a RESTful paradigm. Consider how it would work with GraphQL.
64
-
65
- class FS_Resource extends Resource {
66
-
67
- constructor(spec) {
68
- super(spec);
69
- //this.meta.set('custom_paths', new Data_Object({}));
70
- //this.custom_paths = new Data_Object({});
71
-
72
-
73
- //this.data = {};
74
-
75
- // want to be able to set specific pieces of data to be available.
76
- // This won't be a full DB API, but a starting point for the client-side app to communicate with the server.
77
- // It will interact with a data model through this.
78
-
79
-
80
- // Could have different types of caching modes too.
81
- // Using fnlfs would be useful too.
82
- // mmfs as a pluggable substitute
83
-
84
- // fnlfs-pro
85
-
86
- this.root_path = spec.root_path || spec.root;
87
-
88
- // can't go below the root path.
89
- // Disallow .. in the given paths.
90
-
91
-
92
- }
93
- // need to promisify this.
94
- 'start' (callback) {
95
- if (callback) {
96
- callback(null, true);
97
- } else {
98
- return true;
99
- }
100
-
101
- }
102
-
103
- 'get' (path, callback) {
104
- return obs_or_cb((next, complete, error) => {
105
-
106
- (async() => {
107
- if (await is_directory(path)) {
108
-
109
- let full_path = libpath.join(this.root_path, path);
110
- console.log('full_path', full_path);
111
-
112
- let contents = await dir_contents(full_path);
113
- // however, those are File objects.
114
-
115
- // try just stringifying them now.
116
- // No need to handle stringifying here.
117
- complete(contents);
118
- } else {
119
- // It's a file.
120
- }
121
- })();
122
- });
123
-
124
- // path is a directory, then return a list of the files there (maybe with metadata)
125
- // nice if we can optionally turn on mmfs but not include it in jsgui itself because it requires ffmpeg / ffprobe.
126
- // Could upgrade the FS resource's fs lib.
127
- // dir or file
128
- // is_directory(path)
129
-
130
- // If it's a file, then it would return a read stream.
131
-
132
-
133
- }
134
- 'set' (path, value, callback) {
135
- // Overwrite files
136
- }
137
-
138
- // Delete
139
-
140
-
141
-
142
- /*
143
- Does not process HTTP requests itself. Has a Resource_Publisher which contains / refers to this and does the publishing.
144
- */
145
-
146
-
147
- }
148
-
1
+ /*
2
+ if (typeof define !== 'function') {
3
+ var define = require('amdefine')(module);
4
+ }
5
+
6
+ define(['module', 'path', 'fs', 'url', '../../web/jsgui-html', 'os', 'http', 'url', './resource',
7
+ '../../web/jsgui-je-suis-xml', 'cookies', '../../fs/jsgui-node-fs2-core'],
8
+
9
+ function(module, path, fs, url, jsgui, os, http, libUrl,
10
+ Resource, JeSuisXML, Cookies, fs2) {
11
+ */
12
+
13
+ var libpath = require('path'),
14
+ fs = require('fs'),
15
+ url = require('url'),
16
+ //jsgui = require('jsgui3-html'),
17
+ os = require('os'),
18
+ http = require('http'),
19
+ libUrl = require('url'),
20
+ jsgui = require('jsgui3-html')
21
+ Resource = jsgui.Resource,
22
+ Cookies = require('cookies'),
23
+ fs2 = require('../fs2');
24
+
25
+
26
+ /*
27
+
28
+ var stringify = jsgui.stringify,
29
+ each = jsgui.each,
30
+ arrayify = jsgui.arrayify,
31
+ tof = jsgui.tof;
32
+ var filter_map_by_regex = jsgui.filter_map_by_regex;
33
+ var Class = jsgui.Class,
34
+ Data_Object = jsgui.Data_Object,
35
+ Enhanced_Data_Object = jsgui.Enhanced_Data_Object;
36
+ var fp = jsgui.fp,
37
+ is_defined = jsgui.is_defined;
38
+ var Collection = jsgui.Collection;
39
+ */
40
+ // Extends AutoStart_Resource?
41
+
42
+ // May need to change around a fair few references to make it workable.
43
+ // May need some more complicated logic to change it to the path for service.
44
+
45
+ const fnl = require('fnl');
46
+ const obs_or_cb = fnl.obs_or_cb;
47
+
48
+ const fnlfs = require('fnlfs');
49
+
50
+ // Cloud_FS_Resource
51
+ // SFTP_FS_Resource
52
+
53
+
54
+ // Publishing an FS resource would enable a directory browsing app.
55
+ // File_Tree, and connect to the client-side Data_Resource.
56
+
57
+
58
+
59
+ const {
60
+ is_directory, dir_contents
61
+ } = fnlfs;
62
+
63
+ // This Resource looks to be in a RESTful paradigm. Consider how it would work with GraphQL.
64
+
65
+ class FS_Resource extends Resource {
66
+
67
+ constructor(spec) {
68
+ super(spec);
69
+ //this.meta.set('custom_paths', new Data_Object({}));
70
+ //this.custom_paths = new Data_Object({});
71
+
72
+
73
+ //this.data = {};
74
+
75
+ // want to be able to set specific pieces of data to be available.
76
+ // This won't be a full DB API, but a starting point for the client-side app to communicate with the server.
77
+ // It will interact with a data model through this.
78
+
79
+
80
+ // Could have different types of caching modes too.
81
+ // Using fnlfs would be useful too.
82
+ // mmfs as a pluggable substitute
83
+
84
+ // fnlfs-pro
85
+
86
+ this.root_path = spec.root_path || spec.root;
87
+
88
+ // can't go below the root path.
89
+ // Disallow .. in the given paths.
90
+
91
+
92
+ }
93
+ // need to promisify this.
94
+ 'start' (callback) {
95
+ if (callback) {
96
+ callback(null, true);
97
+ } else {
98
+ return true;
99
+ }
100
+
101
+ }
102
+
103
+ 'get' (path, callback) {
104
+ return obs_or_cb((next, complete, error) => {
105
+
106
+ (async() => {
107
+ if (await is_directory(path)) {
108
+
109
+ let full_path = libpath.join(this.root_path, path);
110
+ console.log('full_path', full_path);
111
+
112
+ let contents = await dir_contents(full_path);
113
+ // however, those are File objects.
114
+
115
+ // try just stringifying them now.
116
+ // No need to handle stringifying here.
117
+ complete(contents);
118
+ } else {
119
+ // It's a file.
120
+ }
121
+ })();
122
+ });
123
+
124
+ // path is a directory, then return a list of the files there (maybe with metadata)
125
+ // nice if we can optionally turn on mmfs but not include it in jsgui itself because it requires ffmpeg / ffprobe.
126
+ // Could upgrade the FS resource's fs lib.
127
+ // dir or file
128
+ // is_directory(path)
129
+
130
+ // If it's a file, then it would return a read stream.
131
+
132
+
133
+ }
134
+ 'set' (path, value, callback) {
135
+ // Overwrite files
136
+ }
137
+
138
+ // Delete
139
+
140
+
141
+
142
+ /*
143
+ Does not process HTTP requests itself. Has a Resource_Publisher which contains / refers to this and does the publishing.
144
+ */
145
+
146
+
147
+ }
148
+
149
149
  module.exports = FS_Resource;
@@ -0,0 +1,105 @@
1
+ // Defines a single constant, which is also functionality to be built.
2
+
3
+
4
+ const {each, Evented_Class} = require('lang-mini');
5
+
6
+ // Is this necessary, is it worth going further than Babel AST?
7
+ // Or JS_AST_Node?
8
+ // of the kind declaration.
9
+
10
+ // May be worth doing more work on platform or builder.
11
+
12
+
13
+ // Maybe this would provide a nice separate API.
14
+
15
+ // Name property.
16
+ // ast_node_count property
17
+ // is_inline property
18
+ // external_reference_names property
19
+ // .refs too?
20
+
21
+ // In declaration form, will be able to then make a new AST that has got changed variable names.
22
+ // Could use a Variable_Name_Provider
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+ // Variable_Declaration
37
+ // Class_Declaration
38
+
39
+ // Kind of the same really.
40
+ // A class is a type of variable.
41
+
42
+ // Want to define all the declarations in a JS file.
43
+
44
+ // Maybe rename this... it's not just the Declaration object from Babel, but more like the relevant programming chunk to be moved around.
45
+
46
+ // Named_Object_Declaration?
47
+
48
+ // Declaration_Code_Block?
49
+ // Basic_Declaration_Code_Pattern
50
+
51
+ // May be better if it extends JS_AST_Node
52
+
53
+ class Declaration extends Evented_Class {
54
+ constructor(spec) {
55
+ super(spec);
56
+
57
+ // name, type, value (which could have its own inner scope)
58
+ // kind?
59
+ // may correspond with babel.
60
+
61
+
62
+
63
+ let name;
64
+
65
+ if (spec.name) name = spec.name;
66
+
67
+ Object.defineProperty(this, 'name', {
68
+ get() { return name; },
69
+ enumerable: true,
70
+ configurable: false
71
+ });
72
+
73
+
74
+
75
+ // Of either a class or another variable.
76
+
77
+ // name
78
+ // type ( class, function, object etc, function call result?)
79
+
80
+ // One single thing being declared.
81
+
82
+ // variable name
83
+
84
+ // name and value?
85
+
86
+ // Can have some helpful info such as
87
+ // is everything inline.
88
+ // what variables it refers to that are outside of it's own internal scope?
89
+
90
+ // .has_internal_scope
91
+ // .is_literal
92
+
93
+ // a few ways to get some information in a simple way about the declaration block would be of use.
94
+
95
+
96
+
97
+
98
+
99
+ }
100
+ }
101
+
102
+ module.exports = Declaration;
103
+
104
+ // Loading a declaration out of a file, so it fits within a declaration object.
105
+
@@ -0,0 +1,43 @@
1
+
2
+
3
+ // lang-mini, for example, would be represented with this. It's a module that reveals a number of declarations.
4
+ // Internally, it operates in a sequence (kind of).
5
+
6
+
7
+ const {each, Evented_Class} = require('lang-mini');
8
+
9
+ class Declaration_Sequence extends Evented_Class {
10
+ constructor(spec = {}) {
11
+ super();
12
+
13
+
14
+ // A double linked list could be better though.
15
+
16
+ const arr = [];
17
+
18
+ this.push = (declaration) => {
19
+ arr.push(declaration);
20
+ };
21
+
22
+ Object.defineProperty(this, 'arr', {
23
+ get() { return arr; },
24
+ enumerable: false,
25
+ configurable: false
26
+ });
27
+
28
+ }
29
+
30
+ *iterator() {
31
+ for (let key in this.arr) {
32
+ const value = arr[key];
33
+ yield value;
34
+ }
35
+ }
36
+
37
+ // Implement "iterable protocol"
38
+ [Symbol.iterator]() {
39
+ return this.iterator();
40
+ }
41
+ }
42
+
43
+ module.exports = Declaration_Sequence;