alchemymvc 1.3.4 → 1.3.5
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/LICENSE +1 -1
- package/README.md +5 -62
- package/lib/app/assets/stylesheets/alchemy-info.less +23 -5
- package/lib/app/controller/alchemy_info_controller.js +2 -2
- package/lib/app/helper/socket_helper.js +16 -8
- package/lib/app/view/alchemy/info.hwk +19 -3
- package/lib/core/socket.js +29 -18
- package/lib/stages.js +10 -9
- package/package.json +7 -6
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c) 2013-
|
|
1
|
+
Copyright (c) 2013-2023 Jelle De Loecker <jelle@elevenways.be>
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<h1 align="center">
|
|
2
|
-
<img src="https://protoblast.
|
|
2
|
+
<img src="https://protoblast.elevenways.be/media/static/alchemy-small.png" width=30 alt="Alchemy logo"/>
|
|
3
3
|
<b>Alchemy</b>
|
|
4
4
|
</h1>
|
|
5
5
|
<div align="center">
|
|
@@ -8,24 +8,14 @@
|
|
|
8
8
|
<img src="https://travis-ci.org/11ways/alchemy.svg?branch=master" alt="Mac/Linux Build Status" />
|
|
9
9
|
</a>
|
|
10
10
|
|
|
11
|
-
<!-- CI - AppVeyor -->
|
|
12
|
-
<a href="https://ci.appveyor.com/project/skerit/alchemy">
|
|
13
|
-
<img src="https://img.shields.io/appveyor/ci/skerit/alchemy/master.svg?label=Windows" alt="Windows Build status" />
|
|
14
|
-
</a>
|
|
15
|
-
|
|
16
11
|
<!-- Coverage - Codecov -->
|
|
17
12
|
<a href="https://codecov.io/gh/11ways/alchemy">
|
|
18
13
|
<img src="https://img.shields.io/codecov/c/github/11ways/alchemy/master.svg" alt="Codecov Coverage report" />
|
|
19
14
|
</a>
|
|
20
15
|
|
|
21
16
|
<!-- DM - Snyk -->
|
|
22
|
-
<a href="https://snyk.io/test/github/
|
|
23
|
-
<img src="https://snyk.io/test/github/
|
|
24
|
-
</a>
|
|
25
|
-
|
|
26
|
-
<!-- DM - David -->
|
|
27
|
-
<a href="https://david-dm.org/skerit/alchemy">
|
|
28
|
-
<img src="https://david-dm.org/skerit/alchemy/status.svg" alt="Dependency Status" />
|
|
17
|
+
<a href="https://snyk.io/test/github/11ways/alchemy?targetFile=package.json">
|
|
18
|
+
<img src="https://snyk.io/test/github/11ways/alchemy/badge.svg?targetFile=package.json" alt="Known Vulnerabilities" />
|
|
29
19
|
</a>
|
|
30
20
|
</div>
|
|
31
21
|
|
|
@@ -69,55 +59,8 @@ Just installing the npm package can be done like this:
|
|
|
69
59
|
|
|
70
60
|
# Quick start guide
|
|
71
61
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
You can find extensive documentation on the library here: [https://protoblast.develry.be](https://protoblast.develry.be)
|
|
75
|
-
|
|
76
|
-
## File structure
|
|
77
|
-
|
|
78
|
-
All of your project code should go into an `app` directory.
|
|
79
|
-
That directory can contain many subdirectories. Most of those files are auto-required on boot.
|
|
80
|
-
|
|
81
|
-
The directories (and some of their basic files) are:
|
|
82
|
-
|
|
83
|
-
* **assets**:
|
|
84
|
-
* **images**: Static images
|
|
85
|
-
* **scripts**: Client-side only javascript files. Accessible through `/scripts/` url.
|
|
86
|
-
* **stylesheets**: SCSS and LESS stylesheet files. Accessible through `/stylesheets/` url.
|
|
87
|
-
* **config**:
|
|
88
|
-
* **bootstrap.js**: Place where all plugins should be loaded
|
|
89
|
-
* **default.js**: Default configuration
|
|
90
|
-
* **local.js**: Configuration file that overrides all others. Is required for the `environment` definition. Should not be checked into git.
|
|
91
|
-
* **prefixes.js**: Place to define which prefixes (locales/languages) are used on the site
|
|
92
|
-
* **routes.js**: Routes should be defined here
|
|
93
|
-
* **controller**:
|
|
94
|
-
* **app_controller.js**: Basic controller instance your other controllers should inherit from
|
|
95
|
-
* **element**:
|
|
96
|
-
* **app_element.js**: Basic custom element your other custom elements should inherit from.
|
|
97
|
-
* **helper**:
|
|
98
|
-
* **app_helper.js**: Basic helper your other helpers should inherit from.
|
|
99
|
-
* **lib**:
|
|
100
|
-
* Put classes here that are only needed on the server.
|
|
101
|
-
* **model**:
|
|
102
|
-
* **app_model.js**: Basic model your other models should inherit from.
|
|
103
|
-
* **public**:
|
|
104
|
-
* Files put in here will be publicly available under the `/public/` url.
|
|
105
|
-
* **root**:
|
|
106
|
-
* Files put in here will be publicly available under the root url (So `/`)
|
|
107
|
-
* **view**:
|
|
108
|
-
* Template files go in here, preferably with a `.hwk` extension, though regular `.ejs` files also work.
|
|
109
|
-
|
|
110
|
-
## Code convention
|
|
111
|
-
|
|
112
|
-
### Naming:
|
|
113
|
-
|
|
114
|
-
* Class names are written using upper camel case: **MyClassName**
|
|
115
|
-
* Method names are written using lower camel case: **myMethodName**
|
|
116
|
-
* Property names and variables are written using snake case: **my_property_name**
|
|
117
|
-
|
|
118
|
-
### Whitespaces
|
|
119
|
-
|
|
120
|
-
* Tabs are used for indentations, spaces are used for positioning.
|
|
62
|
+
You can find all the documentation on [https://alchemy.elevenways.be](https://alchemy.elevenways.be)
|
|
63
|
+
|
|
121
64
|
|
|
122
65
|
## Base class
|
|
123
66
|
|
|
@@ -25,6 +25,8 @@ body {
|
|
|
25
25
|
.row {
|
|
26
26
|
display: flex;
|
|
27
27
|
margin-bottom: 2rem;
|
|
28
|
+
flex-flow: wrap;
|
|
29
|
+
gap: 2rem;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
.col {
|
|
@@ -32,10 +34,6 @@ body {
|
|
|
32
34
|
background: #E8F3F8;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
.col:not(:last-child) {
|
|
36
|
-
margin-right: 2rem;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
37
|
.header-image {
|
|
40
38
|
box-shadow: #000 1px 1px 3px;
|
|
41
39
|
background: #0B486B;
|
|
@@ -56,6 +54,17 @@ body {
|
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
56
|
|
|
57
|
+
tr:nth-child(even) {
|
|
58
|
+
td {
|
|
59
|
+
background-color: rgba(100, 100, 100, 0.1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
td {
|
|
64
|
+
vertical-align: top;
|
|
65
|
+
padding: 1rem 0.2rem;
|
|
66
|
+
}
|
|
67
|
+
|
|
59
68
|
.package-description {
|
|
60
69
|
max-width: 350px;
|
|
61
70
|
}
|
|
@@ -72,6 +81,10 @@ body {
|
|
|
72
81
|
margin-top: 0;
|
|
73
82
|
}
|
|
74
83
|
}
|
|
84
|
+
|
|
85
|
+
@media screen and (max-width: 1500px) {
|
|
86
|
+
padding: 2rem 1rem;
|
|
87
|
+
}
|
|
75
88
|
}
|
|
76
89
|
|
|
77
90
|
.engine {
|
|
@@ -129,13 +142,18 @@ li.failed::before {
|
|
|
129
142
|
}
|
|
130
143
|
|
|
131
144
|
.settings {
|
|
132
|
-
max-width: 50%;
|
|
133
145
|
|
|
134
146
|
th {
|
|
135
147
|
text-align: left;
|
|
136
148
|
border-bottom: 1px solid black;
|
|
137
149
|
}
|
|
138
150
|
|
|
151
|
+
table {
|
|
152
|
+
width: 100%;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.table-wrap {
|
|
139
157
|
table {
|
|
140
158
|
width: 100%;
|
|
141
159
|
}
|
|
@@ -17,7 +17,7 @@ var Info = Function.inherits('Alchemy.Controller.App', function AlchemyInfo(cond
|
|
|
17
17
|
*
|
|
18
18
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
19
19
|
* @since 0.2.0
|
|
20
|
-
* @version
|
|
20
|
+
* @version 1.3.5
|
|
21
21
|
*/
|
|
22
22
|
Info.setMethod(function setInfoVariables() {
|
|
23
23
|
|
|
@@ -30,7 +30,7 @@ Info.setMethod(function setInfoVariables() {
|
|
|
30
30
|
Object.each(Datasource.get(), function eachDatasource(datasource, key) {
|
|
31
31
|
data_sources[key] = {
|
|
32
32
|
type: datasource.constructor.name,
|
|
33
|
-
error: datasource.
|
|
33
|
+
error: datasource.connection_error
|
|
34
34
|
};
|
|
35
35
|
});
|
|
36
36
|
|
|
@@ -311,16 +311,16 @@ Client.setMethod(function createStream() {
|
|
|
311
311
|
/**
|
|
312
312
|
* Make the actual connection
|
|
313
313
|
*
|
|
314
|
-
* @author Jelle De Loecker <jelle@
|
|
314
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
315
315
|
* @since 0.2.0
|
|
316
|
-
* @version 1.
|
|
316
|
+
* @version 1.3.5
|
|
317
317
|
*
|
|
318
318
|
* @param {Function} callback
|
|
319
319
|
*/
|
|
320
320
|
Client.setMethod(function connect(address, data, callback) {
|
|
321
321
|
|
|
322
|
-
|
|
323
|
-
|
|
322
|
+
let that = this,
|
|
323
|
+
io_client,
|
|
324
324
|
serverstream,
|
|
325
325
|
config = {},
|
|
326
326
|
server;
|
|
@@ -339,9 +339,9 @@ Client.setMethod(function connect(address, data, callback) {
|
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
if (typeof io != 'undefined') {
|
|
342
|
-
|
|
342
|
+
io_client = io;
|
|
343
343
|
} else if (typeof alchemy != 'undefined') {
|
|
344
|
-
|
|
344
|
+
io_client = alchemy.use('socket.io-client');
|
|
345
345
|
} else {
|
|
346
346
|
return callback(new Error('Could not find socket.io client library'));
|
|
347
347
|
}
|
|
@@ -362,11 +362,19 @@ Client.setMethod(function connect(address, data, callback) {
|
|
|
362
362
|
config.reconnection = false;
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
+
if (Blast.isNode) {
|
|
366
|
+
let msgpack_parser = alchemy.use('socket.io-msgpack-parser');
|
|
367
|
+
|
|
368
|
+
if (msgpack_parser) {
|
|
369
|
+
config.parser = msgpack_parser;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
365
373
|
// Create the connection to the server
|
|
366
374
|
if (address) {
|
|
367
|
-
server =
|
|
375
|
+
server = io_client(address, config);
|
|
368
376
|
} else {
|
|
369
|
-
server =
|
|
377
|
+
server = io_client(config);
|
|
370
378
|
}
|
|
371
379
|
|
|
372
380
|
if (Blast.isNode) {
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
<% set_title('Alchemy Info Page') %>
|
|
6
6
|
<% this.foundation({protoblast: true}) %>
|
|
7
7
|
<% style('alchemy-info') %>
|
|
8
|
+
<meta charset="UTF-8">
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
8
10
|
</head>
|
|
9
11
|
<body>
|
|
10
12
|
|
|
@@ -64,11 +66,25 @@
|
|
|
64
66
|
<div class="row">
|
|
65
67
|
<article class="plugins col">
|
|
66
68
|
<h1>Plugins</h1>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
{% with plugins as plugin %}
|
|
70
|
+
|
|
71
|
+
{% none %}
|
|
72
|
+
<p class="none">No plugins are loaded</p>
|
|
73
|
+
{% /none %}
|
|
74
|
+
|
|
75
|
+
{% all %}
|
|
76
|
+
<ul>
|
|
77
|
+
{% /all %}
|
|
78
|
+
|
|
79
|
+
{% each %}
|
|
69
80
|
<li>{{ plugin }}</li>
|
|
70
81
|
{% /each %}
|
|
71
|
-
|
|
82
|
+
|
|
83
|
+
{% all %}
|
|
84
|
+
</ul>
|
|
85
|
+
{% /all %}
|
|
86
|
+
|
|
87
|
+
{% /with %}
|
|
72
88
|
</article>
|
|
73
89
|
|
|
74
90
|
<article class="settings col">
|
package/lib/core/socket.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
let msgpack_parser,
|
|
4
4
|
iostream,
|
|
5
|
+
types = alchemy.shared('Socket.types'),
|
|
5
6
|
path = alchemy.use('path'),
|
|
6
7
|
fs = alchemy.use('fs');
|
|
7
8
|
|
|
@@ -10,16 +11,12 @@ var types = alchemy.shared('Socket.types'),
|
|
|
10
11
|
*
|
|
11
12
|
* Create the socket.io listener
|
|
12
13
|
*
|
|
13
|
-
* @author Jelle De Loecker <jelle@
|
|
14
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
14
15
|
* @since 0.1.0
|
|
15
|
-
* @version 1.
|
|
16
|
+
* @version 1.3.5
|
|
16
17
|
*/
|
|
17
18
|
alchemy.sputnik.add(function socket() {
|
|
18
19
|
|
|
19
|
-
var clientPath,
|
|
20
|
-
streamPath,
|
|
21
|
-
io;
|
|
22
|
-
|
|
23
20
|
if (!alchemy.settings.websockets) {
|
|
24
21
|
log.info('Websockets have been disabled');
|
|
25
22
|
return;
|
|
@@ -31,36 +28,50 @@ alchemy.sputnik.add(function socket() {
|
|
|
31
28
|
}
|
|
32
29
|
}
|
|
33
30
|
|
|
34
|
-
|
|
31
|
+
const socket_io = alchemy.use('socket.io');
|
|
35
32
|
|
|
36
|
-
if (!
|
|
33
|
+
if (!socket_io) {
|
|
37
34
|
return log.error('Could not load socket.io!');
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
iostream = alchemy.use('socket.io-stream');
|
|
38
|
+
msgpack_parser = alchemy.use('socket.io-msgpack-parser');
|
|
39
|
+
|
|
40
|
+
let socket_io_options = {
|
|
41
|
+
serveClient : false,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
if (msgpack_parser) {
|
|
45
|
+
socket_io_options.parser = msgpack_parser;
|
|
46
|
+
}
|
|
41
47
|
|
|
42
48
|
// Create the Socket.io listener
|
|
43
|
-
alchemy.io =
|
|
49
|
+
alchemy.io = socket_io(alchemy.server, socket_io_options);
|
|
44
50
|
|
|
45
51
|
// Get the core client path
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
let client_path = alchemy.findModule('socket.io-client').module_dir;
|
|
53
|
+
|
|
54
|
+
if (msgpack_parser) {
|
|
55
|
+
client_path = path.join(client_path, 'dist', 'socket.io.msgpack.min.js');
|
|
56
|
+
} else {
|
|
57
|
+
client_path = path.join(client_path, 'dist', 'socket.io.min.js');
|
|
58
|
+
}
|
|
48
59
|
|
|
49
60
|
// Get the stream client path
|
|
50
|
-
|
|
51
|
-
|
|
61
|
+
let stream_path = path.dirname(alchemy.findModule('@11ways/socket.io-stream').module_path);
|
|
62
|
+
stream_path = path.resolve(stream_path, 'socket.io-stream.js');
|
|
52
63
|
|
|
53
64
|
// Serve the socket io core file
|
|
54
65
|
Router.use('/scripts/socket.io.js', function getSocketIo(req, res, next) {
|
|
55
|
-
alchemy.minifyScript(
|
|
56
|
-
req.conduit.serveFile(mpath ||
|
|
66
|
+
alchemy.minifyScript(client_path, function gotMinifiedPath(err, mpath) {
|
|
67
|
+
req.conduit.serveFile(mpath || client_path);
|
|
57
68
|
});
|
|
58
69
|
});
|
|
59
70
|
|
|
60
71
|
// Serve the socket io stream file
|
|
61
72
|
Router.use('/scripts/socket.io-stream.js', function getSocketStream(req, res, next) {
|
|
62
|
-
alchemy.minifyScript(
|
|
63
|
-
req.conduit.serveFile(mpath ||
|
|
73
|
+
alchemy.minifyScript(stream_path, function gotMinifiedPath(err, mpath) {
|
|
74
|
+
req.conduit.serveFile(mpath || stream_path);
|
|
64
75
|
});
|
|
65
76
|
});
|
|
66
77
|
|
package/lib/stages.js
CHANGED
|
@@ -381,7 +381,7 @@ alchemy.sputnik.add(function routes() {
|
|
|
381
381
|
*
|
|
382
382
|
* @author Jelle De Loecker <jelle@develry.be>
|
|
383
383
|
* @since 0.0.1
|
|
384
|
-
* @version 1.
|
|
384
|
+
* @version 1.3.5
|
|
385
385
|
*/
|
|
386
386
|
alchemy.sputnik.add(function start_server() {
|
|
387
387
|
|
|
@@ -429,7 +429,8 @@ alchemy.sputnik.add(function start_server() {
|
|
|
429
429
|
// The actual `requests` listener is defined in the 'http' stage
|
|
430
430
|
alchemy.server.listen(listen_target, function areListening(){
|
|
431
431
|
|
|
432
|
-
|
|
432
|
+
let address = alchemy.server.address();
|
|
433
|
+
let url = alchemy.settings.url;
|
|
433
434
|
|
|
434
435
|
if (typeof address == 'string') {
|
|
435
436
|
settings.socket = address;
|
|
@@ -439,19 +440,19 @@ alchemy.sputnik.add(function start_server() {
|
|
|
439
440
|
if (settings.socketfile_chmod) {
|
|
440
441
|
fs.chmodSync(address, settings.socketfile_chmod);
|
|
441
442
|
}
|
|
442
|
-
|
|
443
443
|
} else {
|
|
444
444
|
// Get the actual server port
|
|
445
445
|
settings.port = address.port;
|
|
446
446
|
log.info('HTTP server listening on port', settings.port);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
if (alchemy.settings.url) {
|
|
450
|
-
let url = alchemy.settings.url;
|
|
451
447
|
|
|
452
|
-
|
|
448
|
+
if (!url) {
|
|
449
|
+
url = 'http://localhost:' + address.port;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
453
452
|
|
|
454
|
-
|
|
453
|
+
if (url) {
|
|
454
|
+
let pretty_url = alchemy.colors.bg.getRgb(1, 0, 1) + alchemy.colors.fg.getRgb(5, 3, 0) + ' ' + url + ' ' + alchemy.colors.reset;
|
|
455
|
+
log.info('Served at »»', pretty_url, '««');
|
|
455
456
|
}
|
|
456
457
|
|
|
457
458
|
// If this process is a child, tell the parent we're ready
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alchemymvc",
|
|
3
3
|
"description": "MVC framework for Node.js",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.5",
|
|
5
5
|
"author": "Jelle De Loecker <jelle@elevenways.be>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"alchemy",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"body-parser" : "~1.19.2",
|
|
21
21
|
"bson" : "~4.6.1",
|
|
22
22
|
"chokidar" : "~3.5.3",
|
|
23
|
-
"formidable" : "~2.
|
|
23
|
+
"formidable" : "~2.1.1",
|
|
24
24
|
"graceful-fs" : "~4.2.9",
|
|
25
25
|
"hawkejs" : "~2.3.4",
|
|
26
26
|
"jsondiffpatch" : "~0.4.1",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"postcss" : "~8.4.6",
|
|
34
34
|
"protoblast" : "~0.8.3",
|
|
35
35
|
"semver" : "~7.3.5",
|
|
36
|
-
"socket.io" : "~
|
|
36
|
+
"socket.io" : "~4.6.0",
|
|
37
37
|
"@11ways/socket.io-stream" : "~0.9.2",
|
|
38
38
|
"sputnik" : "~0.1.0",
|
|
39
|
-
"terser" : "~5.
|
|
39
|
+
"terser" : "~5.16.3",
|
|
40
40
|
"toobusy-js" : "~0.5.1",
|
|
41
41
|
"useragent" : "~2.3.0"
|
|
42
42
|
},
|
|
@@ -50,12 +50,13 @@
|
|
|
50
50
|
"sass" : "~1.53.0",
|
|
51
51
|
"sass-embedded" : "~1.53.0",
|
|
52
52
|
"nodent-compiler" : "~3.2.13",
|
|
53
|
-
"socket.io-client" : "~
|
|
53
|
+
"socket.io-client" : "~4.6.0",
|
|
54
|
+
"socket.io-msgpack-parser": "~3.0.2"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"codecov" : "~3.8.1",
|
|
57
58
|
"istanbul-lib-instrument" : "~4.0.3",
|
|
58
|
-
"mocha" : "~
|
|
59
|
+
"mocha" : "~10.2.0",
|
|
59
60
|
"mongo-unit" : "~3.2.0",
|
|
60
61
|
"nyc" : "^15.1.0",
|
|
61
62
|
"puppeteer" : "~19.0.0",
|