alchemymvc 1.2.4 → 1.2.6

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 (86) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +0 -0
  3. package/lib/app/assets/scripts/.gitkeep +0 -0
  4. package/lib/app/assets/stylesheets/alchemy-info.less +0 -0
  5. package/lib/app/behaviour/publishable_behaviour.js +0 -0
  6. package/lib/app/behaviour/revision_behaviour.js +0 -0
  7. package/lib/app/behaviour/sluggable_behaviour.js +0 -0
  8. package/lib/app/component/.gitkeep +0 -0
  9. package/lib/app/conduit/electron_conduit.js +0 -0
  10. package/lib/app/conduit/http_conduit.js +173 -173
  11. package/lib/app/conduit/socket_conduit.js +620 -620
  12. package/lib/app/controller/alchemy_info_controller.js +0 -0
  13. package/lib/app/datasource/mongo_datasource.js +0 -0
  14. package/lib/app/helper/client_collection.js +0 -0
  15. package/lib/app/helper/pagination_helper.js +0 -0
  16. package/lib/app/helper/router_helper.js +135 -3
  17. package/lib/app/helper/socket_helper.js +613 -613
  18. package/lib/app/helper_component/paginate_component.js +3 -1
  19. package/lib/app/helper_controller/component.js +0 -0
  20. package/lib/app/helper_controller/conduit.js +20 -0
  21. package/lib/app/helper_controller/controller.js +0 -0
  22. package/lib/app/helper_datasource/00-nosql_datasource.js +0 -0
  23. package/lib/app/helper_datasource/05-fallback_datasource.js +0 -0
  24. package/lib/app/helper_datasource/idb_datasource.js +0 -0
  25. package/lib/app/helper_datasource/indexed_db.js +0 -0
  26. package/lib/app/helper_field/00-objectid_field.js +0 -0
  27. package/lib/app/helper_field/06-text_field.js +0 -0
  28. package/lib/app/helper_field/10-number_field.js +0 -0
  29. package/lib/app/helper_field/boolean_field.js +0 -0
  30. package/lib/app/helper_field/date_field.js +0 -0
  31. package/lib/app/helper_field/datetime_field.js +0 -0
  32. package/lib/app/helper_field/enum_field.js +0 -0
  33. package/lib/app/helper_field/geopoint_field.js +0 -0
  34. package/lib/app/helper_field/habtm_field.js +0 -0
  35. package/lib/app/helper_field/hasoneparent_field.js +0 -0
  36. package/lib/app/helper_field/html_field.js +0 -0
  37. package/lib/app/helper_field/integer_field.js +0 -0
  38. package/lib/app/helper_field/object_field.js +0 -0
  39. package/lib/app/helper_field/regexp_field.js +0 -0
  40. package/lib/app/helper_field/schema_field.js +23 -2
  41. package/lib/app/helper_field/time_field.js +0 -0
  42. package/lib/app/helper_field/url_field.js +0 -0
  43. package/lib/app/helper_model/criteria.js +26 -1
  44. package/lib/app/helper_model/db_query.js +0 -0
  45. package/lib/app/helper_model/document.js +20 -12
  46. package/lib/app/helper_model/document_list.js +0 -0
  47. package/lib/app/helper_model/field_config.js +25 -12
  48. package/lib/app/helper_model/field_set.js +22 -1
  49. package/lib/app/helper_model/model.js +22 -10
  50. package/lib/app/model/alchemy_task_model.js +0 -0
  51. package/lib/app/routes.js +0 -0
  52. package/lib/app/view/alchemy/info.ejs +0 -0
  53. package/lib/app/view/error/unknown.ejs +0 -0
  54. package/lib/app/view/paginate/navlist.ejs +0 -0
  55. package/lib/bootstrap.js +0 -0
  56. package/lib/class/behaviour.js +0 -0
  57. package/lib/class/component.js +0 -0
  58. package/lib/class/conduit.js +2555 -2474
  59. package/lib/class/controller.js +4 -1
  60. package/lib/class/document_list.js +0 -0
  61. package/lib/class/element.js +2 -11
  62. package/lib/class/field.js +7 -1
  63. package/lib/class/helper.js +0 -0
  64. package/lib/class/inode.js +0 -0
  65. package/lib/class/inode_dir.js +0 -0
  66. package/lib/class/inode_file.js +112 -112
  67. package/lib/class/inode_list.js +0 -0
  68. package/lib/class/model.js +1772 -1761
  69. package/lib/class/path_definition.js +0 -0
  70. package/lib/class/route.js +92 -61
  71. package/lib/class/router.js +80 -3
  72. package/lib/class/schema_client.js +7 -2
  73. package/lib/class/session.js +0 -0
  74. package/lib/class/task.js +0 -0
  75. package/lib/core/base.js +50 -9
  76. package/lib/core/client_alchemy.js +48 -43
  77. package/lib/core/discovery.js +0 -0
  78. package/lib/core/middleware.js +72 -7
  79. package/lib/core/routing.js +0 -0
  80. package/lib/core/socket.js +159 -159
  81. package/lib/init/alchemy.js +1823 -1823
  82. package/lib/init/constants.js +0 -0
  83. package/lib/init/functions.js +8 -4
  84. package/lib/init/load_functions.js +0 -0
  85. package/lib/init/requirements.js +101 -101
  86. package/package.json +74 -73
@@ -15,6 +15,7 @@ var publicDirs = alchemy.shared('public.directories', new Deck()),
15
15
  libpath = alchemy.use('path'),
16
16
  nodent_compiler,
17
17
  regenerator_runtime,
18
+ sass_functions,
18
19
  babel_polyfill,
19
20
  babel_preset,
20
21
  babel_async,
@@ -30,7 +31,61 @@ if (alchemy.settings.css_less !== false) {
30
31
  }
31
32
 
32
33
  if (alchemy.settings.css_sass) {
33
- sass = alchemy.use('sass');
34
+
35
+ // Try to use the embedded DART sass
36
+ sass = alchemy.use('sass-embedded');
37
+
38
+ if (!sass) {
39
+ sass = alchemy.use('sass');
40
+ }
41
+
42
+ sass_functions = {
43
+ 'alchemy_settings($name)': function(name) {
44
+
45
+ if (!(name instanceof sass.types.String)) {
46
+ return sass.types.Null.NULL;
47
+ }
48
+
49
+ name = name.getValue();
50
+
51
+ let value = Object.path(alchemy.settings, name);
52
+
53
+ if (value == null) {
54
+ value = Object.path(alchemy.plugins, name);
55
+ }
56
+
57
+ let type = typeof value,
58
+ result;
59
+
60
+ switch (type) {
61
+ case 'string':
62
+ if (value) {
63
+ result = new sass.types.String(value);
64
+ } else {
65
+ result = sass.types.Null.NULL;
66
+ }
67
+ break;
68
+
69
+ case 'number':
70
+ result = new sass.types.Number(value);
71
+ break;
72
+
73
+ case 'boolean':
74
+ result = new sass.types.Boolean(value);
75
+ break;
76
+
77
+ default:
78
+ if (value == null) {
79
+ result = sass.types.Null.NULL;
80
+ } else {
81
+ result = new sass.types.String(''+value);
82
+ }
83
+ break;
84
+ }
85
+
86
+ return result;
87
+ }
88
+ };
34
89
  }
35
90
 
36
91
  if (alchemy.settings.css_post !== false) {
@@ -945,7 +1000,7 @@ Alchemy.setMethod(function getCompiledLessPath(lessPath, options, callback) {
945
1000
  *
946
1001
  * @author Jelle De Loecker <jelle@develry.be>
947
1002
  * @since 0.2.0
948
- * @version 1.1.0
1003
+ * @version 1.2.5
949
1004
  */
950
1005
  Alchemy.setMethod(function getCompiledSassPath(sassPath, options, callback) {
951
1006
 
@@ -969,12 +1024,22 @@ Alchemy.setMethod(function getCompiledSassPath(sassPath, options, callback) {
969
1024
  return writeToTemp(source);
970
1025
  }
971
1026
 
972
- sass.render({
973
- data : source,
1027
+ const render_options = {
974
1028
  includePaths : ['.'].concat(styleDirs.getSorted()).concat(libpath.dirname(sassPath)),
975
- sourceMapEmbed : alchemy.settings.debug,
976
- sourceMapRoot : '/_sourcemaps/'
977
- }, function gotCss(err, result) {
1029
+ functions : sass_functions,
1030
+ };
1031
+
1032
+ if (alchemy.settings.debug) {
1033
+ render_options.file = sassPath;
1034
+ render_options.sourceMap = 'out.css.map';
1035
+ render_options.sourceMapContents = true;
1036
+ render_options.sourceMapEmbed = true;
1037
+ render_options.sourceMapRoot = '/_sourcemaps/';
1038
+ } else {
1039
+ render_options.data = source;
1040
+ }
1041
+
1042
+ sass.render(render_options, function gotCss(err, result) {
978
1043
 
979
1044
  if (err) {
980
1045
  console.log(''+err, err);
File without changes
@@ -1,160 +1,160 @@
1
- 'use strict';
2
-
3
- var types = alchemy.shared('Socket.types'),
4
- iostream,
5
- path = alchemy.use('path'),
6
- fs = alchemy.use('fs');
7
-
8
- /**
9
- * The "socket" stage:
10
- *
11
- * Create the socket.io listener
12
- *
13
- * @author Jelle De Loecker <jelle@develry.be>
14
- * @since 0.1.0
15
- * @version 1.1.3
16
- */
17
- alchemy.sputnik.add(function socket() {
18
-
19
- var clientPath,
20
- streamPath,
21
- io;
22
-
23
- if (!alchemy.settings.websockets) {
24
- log.info('Websockets have been disabled');
25
- return;
26
- } else {
27
- if (alchemy.settings.websockets == 'optional') {
28
- log.info('Websockets have been enabled optionally');
29
- } else {
30
- log.info('Websockets have been enabled, clients will automatically connect');
31
- }
32
- }
33
-
34
- io = alchemy.use('socket.io');
35
-
36
- if (!io) {
37
- return log.error('Could not load socket.io!');
38
- }
39
-
40
- iostream = alchemy.use('socket.io-stream');
41
-
42
- // Create the Socket.io listener
43
- alchemy.io = io.listen(alchemy.server, {serveClient: false});
44
-
45
- // Get the core client path
46
- clientPath = path.dirname(alchemy.findModule('socket.io-client').module_path);
47
- clientPath = path.resolve(clientPath, '..', 'dist', 'socket.io.slim.js');
48
-
49
- // Get the stream client path
50
- streamPath = path.dirname(alchemy.findModule('@11ways/socket.io-stream').module_path);
51
- streamPath = path.resolve(streamPath, 'socket.io-stream.js');
52
-
53
- // Serve the socket io core file
54
- Router.use('/scripts/socket.io.js', function getSocketIo(req, res, next) {
55
- alchemy.minifyScript(clientPath, function gotMinifiedPath(err, mpath) {
56
- req.conduit.serveFile(mpath || clientPath);
57
- });
58
- });
59
-
60
- // Serve the socket io stream file
61
- Router.use('/scripts/socket.io-stream.js', function getSocketStream(req, res, next) {
62
- alchemy.minifyScript(streamPath, function gotMinifiedPath(err, mpath) {
63
- req.conduit.serveFile(mpath || streamPath);
64
- });
65
- });
66
-
67
- /**
68
- * Handle connections
69
- *
70
- * @author Jelle De Loecker <jelle@develry.be>
71
- * @since 0.0.1
72
- * @version 0.2.0
73
- */
74
- alchemy.io.sockets.on('connection', function onConnect(socket){
75
-
76
- var syncs = {},
77
- latencies = [],
78
- latency_avg = 2,
79
- offset = 0;
80
-
81
- socket.on('timesync', function gotTimesyncRequest(data) {
82
-
83
- var received = Date.now(),
84
- latency;
85
-
86
- // This is the initial request
87
- if (data.count == null) {
88
- data.count = 0;
89
- data.latency_trip = 0;
90
-
91
- // Reset the latencies array
92
- latencies.length = 0;
93
- }
94
-
95
- // Do 8 round trips to determine latency
96
- if (data.latency_trip <= 8) {
97
-
98
- if (data.last_sent) {
99
-
100
- // Latency is the timestamp when we received the response
101
- // minus the timestamp when we sent the request
102
- latency = received - data.last_sent;
103
- latencies.push(latency);
104
- }
105
-
106
- // Wait before responding
107
- setTimeout(function waitForLatency() {
108
- data.last_sent = Date.now();
109
- socket.emit('timesync', data);
110
- }, 100 + (data.latency_trip * 150));
111
-
112
- data.latency_trip++;
113
- } else if (data.latency_trip) {
114
-
115
- latency_avg = ~~(Math.median(latencies) / 2);
116
- offset = (received - latency_avg) - data.client_time;
117
-
118
- socket.emit('timesync', {offset: offset, latency: latency_avg});
119
- }
120
- });
121
-
122
- // Wait for the announcement
123
- socket.once('announce', function gotAnnouncement(data) {
124
-
125
- var SocketClass,
126
- class_name;
127
-
128
- // Try getting the socket class of this type
129
- if (typeof data.type == 'string') {
130
- class_name = data.type.classify();
131
- SocketClass = Classes.Alchemy.Conduit[class_name + 'Socket'];
132
- }
133
-
134
- // If no socket class was found get the regular class
135
- if (!SocketClass) {
136
- SocketClass = Classes.Alchemy.Conduit.Socket;
137
- }
138
-
139
- new SocketClass(socket, data);
140
- });
141
- });
142
- });
143
-
144
- /**
145
- * Connect to another alchemy instance
146
- *
147
- * @author Jelle De Loecker <jelle@develry.be>
148
- * @since 0.1.0
149
- * @version 0.4.0
150
- */
151
- Alchemy.setMethod(function callServer(address, data, callback) {
152
-
153
- var server = new Classes.ClientSocket();
154
-
155
- server.reconnect = false;
156
-
157
- server.connect(address, data, callback);
158
-
159
- return server;
1
+ 'use strict';
2
+
3
+ var types = alchemy.shared('Socket.types'),
4
+ iostream,
5
+ path = alchemy.use('path'),
6
+ fs = alchemy.use('fs');
7
+
8
+ /**
9
+ * The "socket" stage:
10
+ *
11
+ * Create the socket.io listener
12
+ *
13
+ * @author Jelle De Loecker <jelle@develry.be>
14
+ * @since 0.1.0
15
+ * @version 1.1.3
16
+ */
17
+ alchemy.sputnik.add(function socket() {
18
+
19
+ var clientPath,
20
+ streamPath,
21
+ io;
22
+
23
+ if (!alchemy.settings.websockets) {
24
+ log.info('Websockets have been disabled');
25
+ return;
26
+ } else {
27
+ if (alchemy.settings.websockets == 'optional') {
28
+ log.info('Websockets have been enabled optionally');
29
+ } else {
30
+ log.info('Websockets have been enabled, clients will automatically connect');
31
+ }
32
+ }
33
+
34
+ io = alchemy.use('socket.io');
35
+
36
+ if (!io) {
37
+ return log.error('Could not load socket.io!');
38
+ }
39
+
40
+ iostream = alchemy.use('socket.io-stream');
41
+
42
+ // Create the Socket.io listener
43
+ alchemy.io = io.listen(alchemy.server, {serveClient: false});
44
+
45
+ // Get the core client path
46
+ clientPath = path.dirname(alchemy.findModule('socket.io-client').module_path);
47
+ clientPath = path.resolve(clientPath, '..', 'dist', 'socket.io.slim.js');
48
+
49
+ // Get the stream client path
50
+ streamPath = path.dirname(alchemy.findModule('@11ways/socket.io-stream').module_path);
51
+ streamPath = path.resolve(streamPath, 'socket.io-stream.js');
52
+
53
+ // Serve the socket io core file
54
+ Router.use('/scripts/socket.io.js', function getSocketIo(req, res, next) {
55
+ alchemy.minifyScript(clientPath, function gotMinifiedPath(err, mpath) {
56
+ req.conduit.serveFile(mpath || clientPath);
57
+ });
58
+ });
59
+
60
+ // Serve the socket io stream file
61
+ Router.use('/scripts/socket.io-stream.js', function getSocketStream(req, res, next) {
62
+ alchemy.minifyScript(streamPath, function gotMinifiedPath(err, mpath) {
63
+ req.conduit.serveFile(mpath || streamPath);
64
+ });
65
+ });
66
+
67
+ /**
68
+ * Handle connections
69
+ *
70
+ * @author Jelle De Loecker <jelle@develry.be>
71
+ * @since 0.0.1
72
+ * @version 0.2.0
73
+ */
74
+ alchemy.io.sockets.on('connection', function onConnect(socket){
75
+
76
+ var syncs = {},
77
+ latencies = [],
78
+ latency_avg = 2,
79
+ offset = 0;
80
+
81
+ socket.on('timesync', function gotTimesyncRequest(data) {
82
+
83
+ var received = Date.now(),
84
+ latency;
85
+
86
+ // This is the initial request
87
+ if (data.count == null) {
88
+ data.count = 0;
89
+ data.latency_trip = 0;
90
+
91
+ // Reset the latencies array
92
+ latencies.length = 0;
93
+ }
94
+
95
+ // Do 8 round trips to determine latency
96
+ if (data.latency_trip <= 8) {
97
+
98
+ if (data.last_sent) {
99
+
100
+ // Latency is the timestamp when we received the response
101
+ // minus the timestamp when we sent the request
102
+ latency = received - data.last_sent;
103
+ latencies.push(latency);
104
+ }
105
+
106
+ // Wait before responding
107
+ setTimeout(function waitForLatency() {
108
+ data.last_sent = Date.now();
109
+ socket.emit('timesync', data);
110
+ }, 100 + (data.latency_trip * 150));
111
+
112
+ data.latency_trip++;
113
+ } else if (data.latency_trip) {
114
+
115
+ latency_avg = ~~(Math.median(latencies) / 2);
116
+ offset = (received - latency_avg) - data.client_time;
117
+
118
+ socket.emit('timesync', {offset: offset, latency: latency_avg});
119
+ }
120
+ });
121
+
122
+ // Wait for the announcement
123
+ socket.once('announce', function gotAnnouncement(data) {
124
+
125
+ var SocketClass,
126
+ class_name;
127
+
128
+ // Try getting the socket class of this type
129
+ if (typeof data.type == 'string') {
130
+ class_name = data.type.classify();
131
+ SocketClass = Classes.Alchemy.Conduit[class_name + 'Socket'];
132
+ }
133
+
134
+ // If no socket class was found get the regular class
135
+ if (!SocketClass) {
136
+ SocketClass = Classes.Alchemy.Conduit.Socket;
137
+ }
138
+
139
+ new SocketClass(socket, data);
140
+ });
141
+ });
142
+ });
143
+
144
+ /**
145
+ * Connect to another alchemy instance
146
+ *
147
+ * @author Jelle De Loecker <jelle@develry.be>
148
+ * @since 0.1.0
149
+ * @version 0.4.0
150
+ */
151
+ Alchemy.setMethod(function callServer(address, data, callback) {
152
+
153
+ var server = new Classes.ClientSocket();
154
+
155
+ server.reconnect = false;
156
+
157
+ server.connect(address, data, callback);
158
+
159
+ return server;
160
160
  });