alchemymvc 1.3.20 → 1.3.21

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.
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * @author Jelle De Loecker <jelle@develry.be>
7
7
  * @since 0.1.0
8
- * @version 1.3.0
8
+ * @version 1.3.21
9
9
  */
10
10
  var Alchemy = Function.inherits('Alchemy.Client.Base', function Alchemy() {
11
11
 
@@ -24,6 +24,9 @@ var Alchemy = Function.inherits('Alchemy.Client.Base', function Alchemy() {
24
24
  this.sent_subscriptions = [];
25
25
 
26
26
  this.distinct_problems = new Map();
27
+
28
+ // Custom handlers
29
+ this.custom_handlers = new Map();
27
30
  });
28
31
 
29
32
  /**
@@ -196,6 +199,79 @@ Alchemy.setMethod(function distinctProblem(id, message, options = {}) {
196
199
  return entry;
197
200
  });
198
201
 
202
+ /**
203
+ * Register a custom handler
204
+ *
205
+ * @author Jelle De Loecker <jelle@elevenways.be>
206
+ * @since 1.3.21
207
+ * @version 1.3.21
208
+ *
209
+ * @param {string|symbol} type
210
+ * @param {Function} callback
211
+ * @param {Number} weight
212
+ */
213
+ Alchemy.setMethod(function registerCustomHandler(type, callback, weight) {
214
+
215
+ if (typeof callback != 'function') {
216
+ throw new Error('Custom handler needs to be a function');
217
+ }
218
+
219
+ let handlers = this.custom_handlers.get(type);
220
+
221
+ if (!handlers) {
222
+ handlers = new Deck();
223
+ this.custom_handlers.set(type, handlers);
224
+ }
225
+
226
+ if (weight == null) {
227
+ weight = 10;
228
+ }
229
+
230
+ handlers.push(callback, weight);
231
+ });
232
+
233
+ /**
234
+ * Get the highest priority custom handler of the given type
235
+ *
236
+ * @author Jelle De Loecker <jelle@elevenways.be>
237
+ * @since 1.3.21
238
+ * @version 1.3.21
239
+ *
240
+ * @param {string|symbol} type
241
+ *
242
+ * @return {Function}
243
+ */
244
+ Alchemy.setMethod(function getCustomHandler(type) {
245
+
246
+ let handlers = this.custom_handlers.get(type);
247
+
248
+ if (handlers) {
249
+ return handlers.first();
250
+ }
251
+ });
252
+
253
+ /**
254
+ * Get all the custom handlers of the given type
255
+ *
256
+ * @author Jelle De Loecker <jelle@elevenways.be>
257
+ * @since 1.3.21
258
+ * @version 1.3.21
259
+ *
260
+ * @param {string|symbol} type
261
+ *
262
+ * @return {Function[]}
263
+ */
264
+ Alchemy.setMethod(function getAllCustomHandlers(type) {
265
+
266
+ let handlers = this.custom_handlers.get(type);
267
+
268
+ if (handlers) {
269
+ return [...handlers];
270
+ }
271
+
272
+ return [];
273
+ });
274
+
199
275
  /**
200
276
  * Actually print a log message
201
277
  *
@@ -426,13 +426,29 @@ Alchemy.setMethod(function minifyScript(path, options, callback) {
426
426
 
427
427
  let minify_options = {
428
428
  compress: {
429
- keep_fargs : true,
430
- keep_fnames : true,
429
+ // Keep all function arguments
430
+ keep_fargs : true,
431
+
432
+ // Keep function names
433
+ keep_fnames : true,
434
+
435
+ // Keep classnames
431
436
  keep_classnames : true,
432
- hoist_funs : false,
433
- drop_console : !alchemy.settings.debug,
434
- dead_code : true,
435
- global_defs : {
437
+
438
+ // Do not hoist function declarations
439
+ hoist_funs : false,
440
+
441
+ // Only drop console calls when not debugging
442
+ drop_console : !alchemy.settings.debug,
443
+
444
+ // Remove dead code
445
+ dead_code : true,
446
+
447
+ // Remove symbol names
448
+ unsafe_symbols : true,
449
+
450
+ // Provide it some info on global definitions
451
+ global_defs : {
436
452
  '__BLAST_IS_NODE' : false,
437
453
  '__BLAST_IS_BROWSER' : true
438
454
  }
@@ -440,7 +456,11 @@ Alchemy.setMethod(function minifyScript(path, options, callback) {
440
456
  mangle: {
441
457
  keep_fnames : true,
442
458
  keep_classnames : true,
443
- }
459
+ },
460
+ output: {
461
+ // Do not wrap functions that are arguments in parenthesis
462
+ wrap_func_args : false,
463
+ },
444
464
  };
445
465
 
446
466
  if (alchemy.settings.debug && alchemy.settings.source_map) {
@@ -19,7 +19,7 @@ var shared_objects = {},
19
19
  *
20
20
  * @author Jelle De Loecker <jelle@elevenways.be>
21
21
  * @since 0.0.1
22
- * @version 1.3.11
22
+ * @version 1.3.21
23
23
  */
24
24
  global.Alchemy = Function.inherits('Informer', 'Alchemy', function Alchemy() {
25
25
 
@@ -105,6 +105,9 @@ global.Alchemy = Function.inherits('Informer', 'Alchemy', function Alchemy() {
105
105
  // Distinct problems
106
106
  this.distinct_problems = new Map();
107
107
 
108
+ // Custom handlers
109
+ this.custom_handlers = new Map();
110
+
108
111
  // Load the settings
109
112
  this.loadSettings();
110
113
 
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.20",
4
+ "version": "1.3.21",
5
5
  "author": "Jelle De Loecker <jelle@elevenways.be>",
6
6
  "keywords": [
7
7
  "alchemy",
@@ -22,7 +22,7 @@
22
22
  "chokidar" : "~3.5.3",
23
23
  "formidable" : "~3.5.1",
24
24
  "graceful-fs" : "~4.2.11",
25
- "hawkejs" : "~2.3.13",
25
+ "hawkejs" : "~2.3.15",
26
26
  "jsondiffpatch" : "~0.5.0",
27
27
  "mime" : "~3.0.0",
28
28
  "minimist" : "~1.2.5",
@@ -31,7 +31,7 @@
31
31
  "mongodb" : "~6.1.0",
32
32
  "ncp" : "~2.0.0",
33
33
  "postcss" : "~8.4.31",
34
- "protoblast" : "~0.8.14",
34
+ "protoblast" : "~0.8.15",
35
35
  "semver" : "~7.5.4",
36
36
  "socket.io" : "~4.7.2",
37
37
  "@11ways/socket.io-stream" : "~0.9.2",