alchemymvc 1.3.16 → 1.3.17

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/lib/core/base.js CHANGED
@@ -35,7 +35,7 @@ __Protoblast.getGroup = function getGroup(name) {
35
35
  *
36
36
  * @author Jelle De Loecker <jelle@develry.be>
37
37
  * @since 0.3.0
38
- * @version 1.2.6
38
+ * @version 1.3.17
39
39
  */
40
40
  Base.constitute(function setBasicBehaviour() {
41
41
 
@@ -134,6 +134,28 @@ Base.constitute(function setBasicBehaviour() {
134
134
  this.setStatic('title', this.createClassTitle(name), false);
135
135
  }
136
136
 
137
+ // And also set the type path
138
+ if (!this.hasOwnProperty('type_path')) {
139
+ let namespace = this.namespace;
140
+ let parent_namespace = this.super?.namespace;
141
+ let type_path = this.type_name;
142
+
143
+ // Add extra identifier info if this child comes from another namespace
144
+ if (namespace && namespace != parent_namespace) {
145
+ if (parent_namespace && namespace.startsWith(parent_namespace)) {
146
+ namespace = namespace.after(parent_namespace);
147
+
148
+ if (namespace[0] == '.') {
149
+ namespace = namespace.slice(1);
150
+ }
151
+ }
152
+
153
+ type_path = Blast.Bound.String.underscore(Blast.Bound.String.slug(namespace)) + '.' + type_path;
154
+ }
155
+
156
+ this.setStatic('type_path', type_path, false);
157
+ }
158
+
137
159
  // Add this class to the shared group
138
160
  shared_group[this.type_name] = this;
139
161
  });
@@ -311,7 +311,7 @@ Alchemy.setMethod(function sourcemapMiddleware(req, res, nextMiddleware) {
311
311
  *
312
312
  * @author Jelle De Loecker <jelle@develry.be>
313
313
  * @since 0.2.0
314
- * @version 1.3.4
314
+ * @version 1.3.17
315
315
  *
316
316
  * @param {String} path
317
317
  * @param {Object} options
@@ -418,7 +418,7 @@ Alchemy.setMethod(function minifyScript(path, options, callback) {
418
418
  }
419
419
  }
420
420
 
421
- if (should_minify) {
421
+ if (should_minify && typeof Terser?.minify == 'function') {
422
422
 
423
423
  // Force Blast.isNode & Blast.isBrowser to be replaced later
424
424
  data = data.replaceAll('Blast.isNode', '__BLAST_IS_NODE');
@@ -135,7 +135,11 @@ global.Alchemy = Function.inherits('Informer', 'Alchemy', function Alchemy() {
135
135
  this.startJaneway();
136
136
  }
137
137
  } catch (err) {
138
- log.warn('Failed to start Janeway:', err);
138
+ if (typeof log != 'undefined') {
139
+ log.warn('Failed to start Janeway:', err);
140
+ } else {
141
+ console.warn('Failed to start Janeway:', err);
142
+ }
139
143
  }
140
144
  });
141
145
 
@@ -357,6 +361,61 @@ Alchemy.setMethod(function isTooBusyForAjax() {
357
361
  return false;
358
362
  });
359
363
 
364
+ /**
365
+ * Called after the server has started
366
+ *
367
+ * @author Jelle De Loecker <jelle@elevenways.be>
368
+ * @since 1.3.17
369
+ * @version 1.3.17
370
+ */
371
+ Alchemy.setMethod(function afterStart() {
372
+ this.startTaskService();
373
+ });
374
+
375
+ let task_service_has_started = false;
376
+
377
+ /**
378
+ * Start the task service
379
+ *
380
+ * @author Jelle De Loecker <jelle@elevenways.be>
381
+ * @since 1.3.17
382
+ * @version 1.3.17
383
+ */
384
+ Alchemy.setMethod(function startTaskService() {
385
+
386
+ if (task_service_has_started) {
387
+ return;
388
+ }
389
+
390
+ task_service_has_started = true;
391
+
392
+ this.task_service = new Classes.Alchemy.Task.TaskService();
393
+ });
394
+
395
+ /**
396
+ * Is the given PID running?
397
+ *
398
+ * @author Jelle De Loecker <jelle@elevenways.be>
399
+ * @since 1.3.17
400
+ * @version 1.3.17
401
+ *
402
+ * @param {Number} pid
403
+ *
404
+ * @return {Boolean}
405
+ */
406
+ Alchemy.setMethod(function isProcessRunning(pid) {
407
+
408
+ if (!pid) {
409
+ return false;
410
+ }
411
+
412
+ try {
413
+ return process.kill(pid, 0);
414
+ } catch (e) {
415
+ return e.code === 'EPERM'
416
+ }
417
+ });
418
+
360
419
  /**
361
420
  * Start janeway
362
421
  *
@@ -441,6 +500,13 @@ Alchemy.setMethod(function startJaneway(options) {
441
500
  return session_menu.remove();
442
501
  }
443
502
 
503
+ session_menu.addItem({
504
+ title : 'Current active browser sessions:',
505
+ weight : Infinity,
506
+ }, () => {
507
+ console.log('All sessions:', alchemy.sessions);
508
+ });
509
+
444
510
  this.Janeway.session_menu = session_menu;
445
511
  }
446
512
 
@@ -1051,7 +1117,7 @@ Alchemy.setMethod(function searchModule(startPath, moduleName, recurse) {
1051
1117
  *
1052
1118
  * @author Jelle De Loecker <jelle@develry.be>
1053
1119
  * @since 0.0.1
1054
- * @version 1.3.16
1120
+ * @version 1.3.17
1055
1121
  *
1056
1122
  * @param {String} moduleName
1057
1123
  * @param {Object} options
@@ -1183,10 +1249,22 @@ Alchemy.setMethod(function findModule(moduleName, options) {
1183
1249
  // Make sure this does not support CJS.
1184
1250
  // Some packages have the `module` type, but do have CJS exports too
1185
1251
  if (!supports_cjs) {
1186
- let exports = package_json.exports?.['.'];
1187
1252
 
1188
- if (exports?.require) {
1253
+ if (package_json.module && package_json.main) {
1189
1254
  supports_cjs = true;
1255
+ } else {
1256
+
1257
+ let exports = package_json.exports?.['.'];
1258
+
1259
+ if (Array.isArray(exports)) {
1260
+ for (let entry of exports) {
1261
+ if (entry && typeof entry == 'object' && entry.require) {
1262
+ supports_cjs = true;
1263
+ }
1264
+ }
1265
+ } else if (exports?.require) {
1266
+ supports_cjs = true;
1267
+ }
1190
1268
  }
1191
1269
  }
1192
1270
 
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.16",
4
+ "version": "1.3.17",
5
5
  "author": "Jelle De Loecker <jelle@elevenways.be>",
6
6
  "keywords": [
7
7
  "alchemy",
@@ -45,7 +45,7 @@
45
45
  "index.js"
46
46
  ],
47
47
  "optionalDependencies": {
48
- "janeway" : "~0.4.0",
48
+ "janeway" : "~0.4.2",
49
49
  "less" : "~4.2.0",
50
50
  "sass" : "~1.68.0",
51
51
  "sass-embedded" : "~1.67.0",