boomack 0.10.0-dev → 0.11.0

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 (186) hide show
  1. package/LICENSE.md +22 -0
  2. package/client/public/js/client.js +143 -46
  3. package/default-config.yaml +40 -49
  4. package/package.json +22 -20
  5. package/server-build/cli.js +0 -1
  6. package/server-build/index.js +20 -4
  7. package/server-build/middleware/basic-auth.js +0 -1
  8. package/server-build/middleware/data-parser.js +0 -1
  9. package/server-build/middleware/standard-auth.js +0 -1
  10. package/server-build/middleware/token-auth.js +0 -1
  11. package/server-build/model/action.js +0 -1
  12. package/server-build/model/action.test.js +0 -1
  13. package/server-build/model/display-request.js +0 -1
  14. package/server-build/model/display-request.test.js +0 -1
  15. package/server-build/model/layout.js +0 -1
  16. package/server-build/model/layout.test.js +0 -1
  17. package/server-build/pipeline/format.js +0 -1
  18. package/server-build/pipeline/format.test.js +0 -1
  19. package/server-build/pipeline/load.js +0 -1
  20. package/server-build/pipeline/load.test.js +0 -1
  21. package/server-build/pipeline/render.js +1 -2
  22. package/server-build/pipeline/render.test.js +0 -2
  23. package/server-build/pipeline/store.js +0 -1
  24. package/server-build/pipeline/store.test.js +0 -1
  25. package/server-build/pipeline/transform.js +1 -2
  26. package/server-build/pipeline/transform.test.js +0 -1
  27. package/server-build/pipeline.js +4 -5
  28. package/server-build/pipeline.test.js +0 -1
  29. package/server-build/plugins/client-resources/tablesort.js +0 -1
  30. package/server-build/plugins/csv.js +10 -2
  31. package/server-build/plugins/generic.js +0 -1
  32. package/server-build/plugins/highlight.js +31 -1
  33. package/server-build/plugins/markdown.js +9 -1
  34. package/server-build/plugins/media.js +0 -1
  35. package/server-build/plugins/text.js +0 -1
  36. package/server-build/routes/actions.js +0 -1
  37. package/server-build/routes/display-requests.js +10 -3
  38. package/server-build/routes/eval-requests.js +1 -6
  39. package/server-build/routes/export.js +0 -1
  40. package/server-build/routes/media-types.js +0 -1
  41. package/server-build/routes/panels.js +13 -3
  42. package/server-build/routes/presets.js +0 -1
  43. package/server-build/routes/resources.js +20 -8
  44. package/server-build/routes/web-client.js +14 -6
  45. package/server-build/service/actions.js +0 -1
  46. package/server-build/service/actions.test.js +0 -1
  47. package/server-build/service/char-encoding.js +0 -1
  48. package/server-build/service/char-encoding.test.js +0 -1
  49. package/server-build/service/cli-args.js +0 -1
  50. package/server-build/service/cli-args.test.js +0 -1
  51. package/server-build/service/client-resources.js +0 -1
  52. package/server-build/service/config-check.js +4 -4
  53. package/server-build/service/config.js +35 -1
  54. package/server-build/service/config.test.js +0 -1
  55. package/server-build/service/display-task-helper.js +0 -1
  56. package/server-build/service/highlight.js +0 -1
  57. package/server-build/service/html.js +0 -1
  58. package/server-build/service/html.test.js +0 -1
  59. package/server-build/service/logging.js +0 -1
  60. package/server-build/service/media-types.js +0 -1
  61. package/server-build/service/media-types.test.js +0 -1
  62. package/server-build/service/micro-markdown.js +0 -1
  63. package/server-build/service/micro-markdown.test.js +0 -1
  64. package/server-build/service/mime-type.js +0 -1
  65. package/server-build/service/mime-type.test.js +0 -1
  66. package/server-build/service/panels.js +20 -17
  67. package/server-build/service/{displays.test.js → panels.test.js} +2 -2
  68. package/server-build/service/persistence.js +0 -1
  69. package/server-build/service/plugins.js +0 -1
  70. package/server-build/service/plugins.test.js +0 -1
  71. package/server-build/service/presets.js +0 -1
  72. package/server-build/service/presets.test.js +0 -1
  73. package/server-build/service/rbac.js +0 -1
  74. package/server-build/service/render.js +0 -1
  75. package/server-build/service/render.test.js +0 -1
  76. package/server-build/service/resources.js +1 -2
  77. package/server-build/service/resources.test.js +0 -1
  78. package/server-build/service/response-messages.js +0 -1
  79. package/server-build/service/themes.js +0 -1
  80. package/server-build/service/transform.js +0 -1
  81. package/server-build/service/transform.test.js +0 -1
  82. package/server-build/service/web-ui-paths.js +0 -1
  83. package/server-build/service/web-user.js +0 -1
  84. package/server-build/typedefs.js +6 -1
  85. package/server-build/utils.js +0 -1
  86. package/server-build/utils.test.js +0 -1
  87. package/server-build/cli.js.map +0 -1
  88. package/server-build/index.js.map +0 -1
  89. package/server-build/middleware/basic-auth.js.map +0 -1
  90. package/server-build/middleware/data-parser.js.map +0 -1
  91. package/server-build/middleware/standard-auth.js.map +0 -1
  92. package/server-build/middleware/token-auth.js.map +0 -1
  93. package/server-build/model/action.js.map +0 -1
  94. package/server-build/model/action.test.js.map +0 -1
  95. package/server-build/model/display-request.js.map +0 -1
  96. package/server-build/model/display-request.test.js.map +0 -1
  97. package/server-build/model/layout.js.map +0 -1
  98. package/server-build/model/layout.test.js.map +0 -1
  99. package/server-build/pipeline/format.js.map +0 -1
  100. package/server-build/pipeline/format.test.js.map +0 -1
  101. package/server-build/pipeline/load.js.map +0 -1
  102. package/server-build/pipeline/load.test.js.map +0 -1
  103. package/server-build/pipeline/render.js.map +0 -1
  104. package/server-build/pipeline/render.test.js.map +0 -1
  105. package/server-build/pipeline/store.js.map +0 -1
  106. package/server-build/pipeline/store.test.js.map +0 -1
  107. package/server-build/pipeline/transform.js.map +0 -1
  108. package/server-build/pipeline/transform.test.js.map +0 -1
  109. package/server-build/pipeline.js.map +0 -1
  110. package/server-build/pipeline.test.js.map +0 -1
  111. package/server-build/plugins/client-resources/tablesort.js.map +0 -1
  112. package/server-build/plugins/csv.js.map +0 -1
  113. package/server-build/plugins/generic.js.map +0 -1
  114. package/server-build/plugins/highlight.js.map +0 -1
  115. package/server-build/plugins/markdown.js.map +0 -1
  116. package/server-build/plugins/media copy.js +0 -85
  117. package/server-build/plugins/media copy.js.map +0 -1
  118. package/server-build/plugins/media.js.map +0 -1
  119. package/server-build/plugins/text.js.map +0 -1
  120. package/server-build/routes/actions.js.map +0 -1
  121. package/server-build/routes/display-requests.js.map +0 -1
  122. package/server-build/routes/eval-request.js +0 -134
  123. package/server-build/routes/eval-request.js.map +0 -1
  124. package/server-build/routes/eval-requests.js.map +0 -1
  125. package/server-build/routes/export.js.map +0 -1
  126. package/server-build/routes/media-types.js.map +0 -1
  127. package/server-build/routes/option-sets.js +0 -90
  128. package/server-build/routes/option-sets.js.map +0 -1
  129. package/server-build/routes/panels.js.map +0 -1
  130. package/server-build/routes/presets.js.map +0 -1
  131. package/server-build/routes/resources.js.map +0 -1
  132. package/server-build/routes/web-client.js.map +0 -1
  133. package/server-build/service/actions.js.map +0 -1
  134. package/server-build/service/actions.test.js.map +0 -1
  135. package/server-build/service/brand.js +0 -9
  136. package/server-build/service/brand.js.map +0 -1
  137. package/server-build/service/char-encoding.js.map +0 -1
  138. package/server-build/service/char-encoding.test.js.map +0 -1
  139. package/server-build/service/cli-args.js.map +0 -1
  140. package/server-build/service/cli-args.test.js.map +0 -1
  141. package/server-build/service/client-resources.js.map +0 -1
  142. package/server-build/service/config-check.js.map +0 -1
  143. package/server-build/service/config.js.map +0 -1
  144. package/server-build/service/config.test.js.map +0 -1
  145. package/server-build/service/display-task-helper.js.map +0 -1
  146. package/server-build/service/displays.test.js.map +0 -1
  147. package/server-build/service/highlight.js.map +0 -1
  148. package/server-build/service/html.js.map +0 -1
  149. package/server-build/service/html.test.js.map +0 -1
  150. package/server-build/service/logging.js.map +0 -1
  151. package/server-build/service/media-types.js.map +0 -1
  152. package/server-build/service/media-types.test.js.map +0 -1
  153. package/server-build/service/micro-markdown.js.map +0 -1
  154. package/server-build/service/micro-markdown.test.js.map +0 -1
  155. package/server-build/service/mime-type.js.map +0 -1
  156. package/server-build/service/mime-type.test.js.map +0 -1
  157. package/server-build/service/option-sets.js +0 -123
  158. package/server-build/service/option-sets.js.map +0 -1
  159. package/server-build/service/option-sets.test.js +0 -130
  160. package/server-build/service/option-sets.test.js.map +0 -1
  161. package/server-build/service/panels.js.map +0 -1
  162. package/server-build/service/pdf-export.js +0 -73
  163. package/server-build/service/pdf-export.js.map +0 -1
  164. package/server-build/service/persistence.js.map +0 -1
  165. package/server-build/service/plugins.js.map +0 -1
  166. package/server-build/service/plugins.test.js.map +0 -1
  167. package/server-build/service/presets.js.map +0 -1
  168. package/server-build/service/presets.test.js.map +0 -1
  169. package/server-build/service/rbac.js.map +0 -1
  170. package/server-build/service/render.js.map +0 -1
  171. package/server-build/service/render.test.js.map +0 -1
  172. package/server-build/service/resources.js.map +0 -1
  173. package/server-build/service/resources.test.js.map +0 -1
  174. package/server-build/service/response-messages.js.map +0 -1
  175. package/server-build/service/themes.js.map +0 -1
  176. package/server-build/service/transform.js.map +0 -1
  177. package/server-build/service/transform.test.js.map +0 -1
  178. package/server-build/service/type-mappings.js +0 -39
  179. package/server-build/service/type-mappings.js.map +0 -1
  180. package/server-build/service/web-ui-paths.js.map +0 -1
  181. package/server-build/service/web-user.js.map +0 -1
  182. package/server-build/text-types.js +0 -12
  183. package/server-build/text-types.js.map +0 -1
  184. package/server-build/typedefs.js.map +0 -1
  185. package/server-build/utils.js.map +0 -1
  186. package/server-build/utils.test.js.map +0 -1
package/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+ =====================
3
+
4
+ **Copyright (c) 2022 Tobias Kiertscher <dev@mastersign.de>**
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
@@ -120,7 +120,7 @@ window.boomack = window.boomack || {};
120
120
 
121
121
  function ensureSlotResizeSensor(slotId) {
122
122
  if (_.has(slotResizeSensors, slotId)) return;
123
- var slotE = findSlot(slotId);
123
+ var slotE = getSlot(slotId);
124
124
  if (!slotE.length) {
125
125
  console.log("Could not find the slot '" + slotId + "' for registering a slot resize handler.");
126
126
  return;
@@ -198,11 +198,25 @@ window.boomack = window.boomack || {};
198
198
  });
199
199
  }
200
200
 
201
+ ctx.findSlot = function(slotHint) {
202
+ var slotE = typeof slotHint === 'string' ? getSlot(slotHint) : {};
203
+ if (!slotE.length) {
204
+ // try to use slotHint as selector for slot content element
205
+ // and search parents for slot
206
+ slotE = $(slotHint).closest('.slot');
207
+ }
208
+ return slotE.length === 1 ? slotE[0] : null;
209
+ };
210
+
211
+ ctx.getSlotId = function(slot) {
212
+ return slot ? slot.getAttribute('data-slot-id') : null;
213
+ };
214
+
201
215
  ctx.registerSlotResizeHandler = function (slotHint, handler, callImmediately) {
202
216
  var slotId = null;
203
217
  var slotE = null;
204
218
  // try to use slotHint as slot ID
205
- slotE = findSlot(slotHint);
219
+ slotE = getSlot(slotHint);
206
220
  if (!slotE.length) {
207
221
  // try to use slotHint as selector for slot content element
208
222
  // and search parents for slot
@@ -228,7 +242,7 @@ window.boomack = window.boomack || {};
228
242
  ctx.registerPersistentSlotResizeHandler = function(slotId, handler) {
229
243
  ensureSlotResizeSensor(slotId);
230
244
  persistentSlotResizeHandlers[slotId].push(handler);
231
- var slotE = findSlot(slotId);
245
+ var slotE = getSlot(slotId);
232
246
  var size = getSlotInnerSize(slotE);
233
247
  var zoomedSize = getZoomedSlotInnerSize(slotE, size);
234
248
  handler(size, zoomedSize);
@@ -250,15 +264,15 @@ window.boomack = window.boomack || {};
250
264
  $('#panel').html(layoutHtml);
251
265
  }
252
266
 
253
- function findAllSlots() {
267
+ function getAllSlots() {
254
268
  return $('.slot');
255
269
  }
256
270
 
257
- function findSlot(slotId) {
271
+ function getSlot(slotId) {
258
272
  return $(`#slot-${slotId}`);
259
273
  }
260
274
 
261
- function findAllButSlot(slotId) {
275
+ function getAllButSlot(slotId) {
262
276
  return $(`.slot:not(#slot-${slotId})`);
263
277
  }
264
278
 
@@ -392,6 +406,14 @@ window.boomack = window.boomack || {};
392
406
  classes.forEach(cls => { slotE.removeClass(cls); });
393
407
  slotE.find('.cmd-zoom-in').removeClass('disabled');
394
408
  slotE.find('.cmd-zoom-out').removeClass('disabled');
409
+ // make sure to reset styles of all content related elements,
410
+ // in case some JavaScript attached styles during display
411
+ slotE.find('.slot-content-box')
412
+ .each(function () { this.style = {}; })
413
+ .find('.slot-content-wrapper')
414
+ .each(function () { this.style = {}; })
415
+ .find('.slot-content')
416
+ .each(function () { this.style = {}; });
395
417
  }
396
418
 
397
419
  const imgPattern = /^\s*<img\s+src=\"([^\"]*)\"\s*\/?>/;
@@ -442,7 +464,6 @@ window.boomack = window.boomack || {};
442
464
  }
443
465
 
444
466
  let socket = null;
445
- let actionCallback = null;
446
467
  let scrollTimeout = null;
447
468
 
448
469
  function scrollToSlot(slotId) {
@@ -451,7 +472,7 @@ window.boomack = window.boomack || {};
451
472
  }
452
473
  scrollTimeout = window.setTimeout(() => {
453
474
  scrollTimeout = null;
454
- const slotE = findSlot(slotId);
475
+ const slotE = getSlot(slotId);
455
476
  if (slotE) {
456
477
  window.scrollTo({
457
478
  top: slotE.offset().top - 10,
@@ -493,7 +514,7 @@ window.boomack = window.boomack || {};
493
514
  } else if (envelope.command) {
494
515
  const cmd = envelope.command;
495
516
  if (cmd.panel != ctx.panelId) return;
496
- const slotE = findSlot(cmd.slot);
517
+ const slotE = getSlot(cmd.slot);
497
518
  const contentE = slotE.find('.slot-content');
498
519
  if (!contentE) return;
499
520
  const empty = contentE.is(':empty');
@@ -550,6 +571,83 @@ window.boomack = window.boomack || {};
550
571
  ctx.run(function () { eval(cmd.script); });
551
572
  }
552
573
 
574
+ const pendingActionCalls = {};
575
+
576
+ function cleanUpPendingActionCalls() {
577
+ var now = new Date().getTime();
578
+ for (const callId in pendingActionCalls) {
579
+ const ar = pendingActionCalls[callId];
580
+ if (now > ar.ts + ar.timeout) {
581
+ delete pendingActionCalls[callId]
582
+ }
583
+ }
584
+ }
585
+
586
+ function padLeft(pad, x) {
587
+ return (pad + x).slice(-pad.length);
588
+ }
589
+
590
+ function newCallId(ts) {
591
+ const r = Math.floor(Math.random() * 1000);
592
+ return padLeft("00000000000000", ts) + "_" + padLeft("000", r);
593
+ }
594
+
595
+ function uniqueCallId(ts) {
596
+ let callId = newCallId(ts);
597
+ while (pendingActionCalls[callId]) {
598
+ callId = newCallId(ts);
599
+ }
600
+ return callId;
601
+ }
602
+
603
+ function beginActionCall(actionId, payload, cb, options = {
604
+ timeout: 10000,
605
+ }) {
606
+ cleanUpPendingActionCalls();
607
+ const ts = new Date().getTime();
608
+ const callId = uniqueCallId(ts);
609
+ const call = {
610
+ id: callId,
611
+ ts: ts,
612
+ timeout: options.timeout,
613
+ resolve: null,
614
+ reject: null,
615
+ };
616
+ const promise = new Promise((resolve, reject) => {
617
+ call.resolve = response => {
618
+ delete pendingActionCalls[callId];
619
+ resolve(response);
620
+ if (typeof cb === 'function') {
621
+ try {
622
+ cb(null, response);
623
+ } catch (err) {
624
+ console.error("Callback for action " + actionId + " has thrown an error:", err);
625
+ }
626
+ }
627
+ };
628
+ call.reject = reason => {
629
+ delete pendingActionCalls[callId];
630
+ reject(reason);
631
+ if (typeof cb === 'function') {
632
+ try {
633
+ cb(reason);
634
+ } catch (err) {
635
+ console.error("Callback for action " + actionId + " has thrown an error:", err);
636
+ }
637
+ }
638
+ };
639
+ });
640
+ pendingActionCalls[callId] = call;
641
+ socket.emit('action', {
642
+ action: actionId,
643
+ panel: ctx.panelId,
644
+ payload: payload,
645
+ token: callId,
646
+ });
647
+
648
+ return promise;
649
+ }
650
+
553
651
  $(function () {
554
652
  // run when page is ready
555
653
 
@@ -584,11 +682,11 @@ window.boomack = window.boomack || {};
584
682
 
585
683
  socket.on('clear', cmd => {
586
684
  if (cmd.slot) {
587
- const slotE = findSlot(cmd.slot);
685
+ const slotE = getSlot(cmd.slot);
588
686
  slotE.find('.slot-content').html('');
589
687
  notifySlotEmpty(cmd.slot, slotE);
590
688
  } else {
591
- const slotEs = findAllSlots();
689
+ const slotEs = getAllSlots();
592
690
  slotEs.each(function () {
593
691
  const slotE = $(this);
594
692
  slotE.find('.slot-content').html('');
@@ -609,24 +707,28 @@ window.boomack = window.boomack || {};
609
707
  }, 'html');
610
708
  });
611
709
 
612
- socket.on('action-error', err => {
613
- if (actionCallback) {
614
- actionCallback(err);
615
- actionCallback = null;
710
+ socket.on('action-error', response => {
711
+ const ar = pendingActionCalls[response.token];
712
+ if (ar) {
713
+ ar.reject(response.error);
714
+ } else {
715
+ console.warn("Response for action " + response.action + " without handler:", response.token);
616
716
  }
617
717
  });
618
- socket.on('action-success', result => {
619
- if (actionCallback) {
620
- actionCallback(null, result);
621
- actionCallback = null;
718
+ socket.on('action-success', response => {
719
+ const ar = pendingActionCalls[response.token];
720
+ if (ar) {
721
+ ar.resolve(response.payload);
722
+ } else {
723
+ console.warn("Response for action " + response.action + " without handler:", response.token);
622
724
  }
623
725
  });
624
726
  });
625
727
 
626
728
  ctx.cmdToggleMaximize = function (slotId) {
627
- const slotE = findSlot(slotId);
729
+ const slotE = getSlot(slotId);
628
730
  if (!slotE) return;
629
- const otherSlotE = findAllButSlot(slotId);
731
+ const otherSlotE = getAllButSlot(slotId);
630
732
  const cmdMaximize = slotE.find('.slot-toolbar .cmd-maximize i.icon');
631
733
  if (slotE.hasClass('maximized')) {
632
734
  slotE.removeClass('maximized');
@@ -646,7 +748,7 @@ window.boomack = window.boomack || {};
646
748
 
647
749
  ctx.cmdHistoryBackward = function (slotId) {
648
750
  if (ctx.offline) return;
649
- const slotE = findSlot(slotId);
751
+ const slotE = getSlot(slotId);
650
752
  if (!slotE) return;
651
753
  const no = Number.parseInt(slotE.data('sequence-no')) - 1;
652
754
  if (!isValidHistoryNo(slotE, no)) return;
@@ -665,7 +767,7 @@ window.boomack = window.boomack || {};
665
767
 
666
768
  ctx.cmdHistoryForward = function (slotId) {
667
769
  if (ctx.offline) return;
668
- const slotE = findSlot(slotId);
770
+ const slotE = getSlot(slotId);
669
771
  if (!slotE) return;
670
772
  const no = Number.parseInt(slotE.data('sequence-no')) + 1;
671
773
  if (!isValidHistoryNo(slotE, no)) return;
@@ -684,7 +786,7 @@ window.boomack = window.boomack || {};
684
786
 
685
787
  ctx.cmdTogglePause = function (slotId) {
686
788
  if (ctx.offline) return;
687
- const slotE = findSlot(slotId);
789
+ const slotE = getSlot(slotId);
688
790
  if (!slotE) return;
689
791
  const cmdPause = slotE.find('.slot-toolbar .cmd-pause i.icon');
690
792
  if (slotE.hasClass('paused')) {
@@ -741,7 +843,7 @@ window.boomack = window.boomack || {};
741
843
  }
742
844
 
743
845
  ctx.cmdSlotZoomOut = function (slotId) {
744
- const slotE = findSlot(slotId);
846
+ const slotE = getSlot(slotId);
745
847
  const zoom = getSlotZoom(slotE);
746
848
  const newZoom = zoomFromBase(baseFromZoom(zoom) - 1);
747
849
  setData(slotE, 'zoom', newZoom);
@@ -749,7 +851,7 @@ window.boomack = window.boomack || {};
749
851
  };
750
852
 
751
853
  ctx.cmdSlotZoomIn = function (slotId) {
752
- const slotE = findSlot(slotId);
854
+ const slotE = getSlot(slotId);
753
855
  const zoom = getSlotZoom(slotE);
754
856
  const newZoom = zoomFromBase(baseFromZoom(zoom) + 1);
755
857
  setData(slotE, 'zoom', newZoom);
@@ -774,31 +876,26 @@ window.boomack = window.boomack || {};
774
876
  return replaceThemeProps(o);
775
877
  };
776
878
 
777
- ctx.arang = function (actionId, payload, cb) {
778
- if (ctx.offline) {
779
- console.warn('Can not trigger action, if in print or exported mode.', 'Action', actionId);
780
- return;
879
+ ctx.action = function (
880
+ actionId,
881
+ payload = null,
882
+ cb = null,
883
+ options = {
884
+ timeout: 10000,
781
885
  }
782
- actionCallback = cb;
783
- socket.emit('action', {
784
- action: actionId,
785
- panel: ctx.panelId,
786
- payload: payload,
787
- });
788
- };
789
-
790
- ctx.boom = function (displayRequest, cb) {
886
+ ) {
791
887
  if (ctx.offline) {
792
- console.warn('Can not send display request, if in print or exported mode.');
888
+ console.warn('Can not call action, if in print or exported mode.', 'Action', actionId);
793
889
  return;
794
890
  }
795
- // TODO implement boom for client code
796
- // possibly in an extra web client library
797
- alert('Not implemented');
891
+ return beginActionCall(actionId, payload, cb, options);
798
892
  };
799
893
 
800
- // export some functions to global scope
801
- window.arang = ctx.arang;
802
- window.boom = ctx.boom;
894
+ // deprecated
895
+ ctx.arang = function () {
896
+ console.warn('The arang function is deprecated. Please use boomack.action().');
897
+ return ctx.action.apply(ctx, arguments);
898
+ };
899
+ window.arang = ctx.arang; // deprecated
803
900
 
804
901
  })();
@@ -227,31 +227,45 @@ export:
227
227
  resourceSizeLimit: 1536 MB
228
228
 
229
229
  init:
230
- # initial panels with their layout
230
+ # A map with initial panels
231
231
  panels:
232
- # one panel must have the ID default
233
- default:
234
- layout:
235
- # the initial default panel has a minimal grid layout
236
- grid:
237
- columns: 1
238
- rows: 1
239
- slots:
240
- # one slot in each panel must have the ID default
241
- default:
242
- history: 10
243
- border: true
244
- toobar: true
245
- showId: true
246
- column: 0
247
- row: 0
248
- columnSpan: 1
249
- rowSpan: 1
232
+ # one panel must have the ID "default"
233
+ "default":
250
234
  # show or hide the header above the slots
251
235
  header: true
236
+ # the size of the header, if visible: mini, tiny, small, medium, large, huge, massive
237
+ headerSize: medium
252
238
  # select a theme for this panel: default, dark
253
239
  theme: default
254
- # initial actions, none by default
240
+ # CSS code to be included in the HTML head of the panel
241
+ style: null
242
+ # JavaScript code to be executed when the panel was loaded
243
+ script: null
244
+ # the ID of the default slot (optional)
245
+ defaultSlot: null
246
+ # the initial default panel has a minimal grid layout
247
+ grid:
248
+ columns: 1
249
+ rows: 1
250
+ slots:
251
+ # if not explicitly defined, first slot is the default slot
252
+ "default":
253
+ history: 10
254
+ extensions: 100
255
+ border: true
256
+ toobar: true
257
+ noZoom: false
258
+ noClear: false
259
+ noMaximize: false
260
+ noSingleOut: false
261
+ showId: true
262
+ colorFilter: null
263
+ column: 0
264
+ row: 0
265
+ columnSpan: 1
266
+ rowSpan: 1
267
+
268
+ # A map with initial actions
255
269
  actions: { }
256
270
  # action-id:
257
271
  # type: shell
@@ -270,32 +284,9 @@ init:
270
284
  # background: #FFC080
271
285
 
272
286
  # A map with initial MIME types
273
- types:
274
- "text/markdown":
275
- options:
276
- transformation: markdown
277
- "text/csv":
278
- options:
279
- transformation: csv-table
280
- "text/xml":
281
- options:
282
- syntax: xml
283
- "application/xml":
284
- text: true # indicate that this non-text MIME type can be treated as text
285
- options:
286
- syntax: xml
287
- "text/yaml":
288
- options:
289
- syntax: yaml
290
- "application/x-yaml":
291
- text: true
292
- options:
293
- syntax: yaml
294
- "application/javascript":
295
- text: true
296
- options:
297
- syntax: js
298
- "application/json":
299
- text: true
300
- options:
301
- syntax: json
287
+ types: { }
288
+ # example type for a syntax highlighted text file
289
+ # "text/css":
290
+ # presets: []
291
+ # options:
292
+ # syntax: css
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boomack",
3
- "version": "0.10.0-dev",
3
+ "version": "0.11.0",
4
4
  "description": "web app for displaying hyper-media items in concert with e.g. an IDE",
5
5
  "author": "Tobias Kiertscher <dev@mastersign.de>",
6
6
  "license": "MIT",
@@ -8,9 +8,10 @@
8
8
  "boomack": "./server-build/cli.js"
9
9
  },
10
10
  "files": [
11
+ "LICENSE.md",
11
12
  "server-build",
12
- "client",
13
- "default-config.yaml"
13
+ "default-config.yaml",
14
+ "client"
14
15
  ],
15
16
  "scripts": {
16
17
  "build": "tsc",
@@ -28,21 +29,21 @@
28
29
  "node": ">= 10.0.0"
29
30
  },
30
31
  "dependencies": {
31
- "archiver": "^5.2.0",
32
+ "archiver": "^5.3.0",
32
33
  "async": "^3.2.0",
33
34
  "chalk": "^4.1.0",
34
- "chardet": "^0.8.0",
35
+ "chardet": "^1.4.0",
35
36
  "commonmark": "^0.30.0",
36
37
  "cookie-parser": "^1.4.5",
37
38
  "cors": "^2.8.5",
38
39
  "csv-parse": "^4.15.1",
39
- "ejs": "^2.7.4",
40
- "express": "^4.17.1",
40
+ "ejs": "^3.1.8",
41
+ "express": "^4.18.0",
41
42
  "express-basic-auth": "^1.2.0",
42
- "got": "^10.7.0",
43
- "iconv-lite": "^0.5.2",
44
- "lodash": "^4.17.20",
45
- "markdown-it": "^12.3.2",
43
+ "got": "^11.8.5",
44
+ "iconv-lite": "^0.6.0",
45
+ "lodash": "^4.17.21",
46
+ "markdown-it": "^13.0.0",
46
47
  "markdown-it-container": "^3.0.0",
47
48
  "markdown-it-emoji": "^2.0.0",
48
49
  "markdown-it-ins": "^3.0.1",
@@ -51,21 +52,22 @@
51
52
  "markdown-it-sup": "^1.0.0",
52
53
  "moment": "^2.29.1",
53
54
  "ncp": "^2.0.0",
54
- "nocache": "^2.1.0",
55
- "open": "^7.4.2",
56
- "prismjs": "^1.23.0",
57
- "raw-body": "^2.4.1",
55
+ "nocache": "^3.0.4",
56
+ "on-finished": "^2.4.1",
57
+ "open": "^8.4.0",
58
+ "prismjs": "^1.28.0",
59
+ "raw-body": "^2.5.1",
58
60
  "rimraf": "^3.0.2",
59
61
  "secure-random-string": "^1.1.3",
60
- "socket.io": "^4.4.1",
61
- "uuid": "^3.4.0",
62
- "winston": "^3.3.3",
62
+ "socket.io": "^4.5.1",
63
+ "uuid": "^8.3.2",
64
+ "winston": "^3.8.1",
63
65
  "yaml": "^1.10.0",
64
66
  "yargs": "^15.4.1"
65
67
  },
66
68
  "devDependencies": {
67
- "@types/express": "^4.17.11",
68
- "@types/lodash": "^4.14.168",
69
+ "@types/express": "^4.17.13",
70
+ "@types/lodash": "^4.14.182",
69
71
  "@types/rimraf": "^3.0.0",
70
72
  "boomack-theme-blue-night": "https://github.com/boomack/themes/tarball/blue-night/v3",
71
73
  "boomack-theme-dark": "https://github.com/boomack/themes/tarball/dark/v2",
@@ -1,4 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  require('./index');
4
- //# sourceMappingURL=cli.js.map
@@ -8,6 +8,7 @@ const cors = require('cors');
8
8
  const app = express();
9
9
  const http = require('http');
10
10
  const server = http.createServer(app);
11
+ const onFinished = require('on-finished');
11
12
  const socketio = require('socket.io');
12
13
  const io = socketio();
13
14
  const utils = require('./utils');
@@ -23,6 +24,7 @@ const resources = require('./service/resources');
23
24
  const panels = require('./service/panels');
24
25
  const actions = require('./service/actions');
25
26
  const persistence = require('./service/persistence');
27
+ const messages = require('./service/response-messages');
26
28
  const log = logging.log;
27
29
  function showPreamble(cb) {
28
30
  if (!cli.args.logo) {
@@ -304,7 +306,14 @@ function setupApp(cb) {
304
306
  app.use(require('nocache')());
305
307
  // Log all HTTP request URLs
306
308
  app.use((req, res, next) => {
307
- log.http(`${req.method} ${req.url}`);
309
+ onFinished(res, function (err, res) {
310
+ if (err) {
311
+ log.error(err);
312
+ }
313
+ else {
314
+ log.http(`${req.method} ${req.url} ${res.statusCode}`);
315
+ }
316
+ });
308
317
  next();
309
318
  });
310
319
  app.use(cors());
@@ -317,6 +326,13 @@ function setupApp(cb) {
317
326
  require('./routes/display-requests').setup(app, io);
318
327
  require('./routes/eval-requests').setup(app, io);
319
328
  require('./routes/export').setup(app, io);
329
+ app.use((req, res) => {
330
+ messages.error(res, {
331
+ status: 404,
332
+ title: "Resource not found",
333
+ message: `The resource "${req.url}" was not found.`,
334
+ });
335
+ });
320
336
  cb(null);
321
337
  }
322
338
  function startServer(cb) {
@@ -382,13 +398,14 @@ async.waterfall([
382
398
  showPreamble,
383
399
  logging.initialize,
384
400
  cfg.parseArgsAndLoadConfig,
385
- cfgCheck.run,
386
401
  logging.configure,
387
402
  initializeAuthentication,
388
403
  initializeResources,
389
- showConfiguration,
390
404
  loadCorePlugIns,
391
405
  loadPlugIns,
406
+ cfg.plugInInitConfigApplicatorFactory(plugins),
407
+ showConfiguration,
408
+ cfgCheck.run,
392
409
  loadPresets,
393
410
  loadMimeTypes,
394
411
  loadActions,
@@ -404,4 +421,3 @@ async.waterfall([
404
421
  log.error(err.message);
405
422
  }
406
423
  });
407
- //# sourceMappingURL=index.js.map
@@ -12,4 +12,3 @@ exports.webAuthBasic = function (unauthorizedHtml) {
12
12
  };
13
13
  return basicAuth(options);
14
14
  };
15
- //# sourceMappingURL=basic-auth.js.map
@@ -147,4 +147,3 @@ exports.dataBody = function (req, res, next) {
147
147
  });
148
148
  });
149
149
  };
150
- //# sourceMappingURL=data-parser.js.map
@@ -59,4 +59,3 @@ exports.webAuthStandard = function (loginRenderer) {
59
59
  }
60
60
  };
61
61
  };
62
- //# sourceMappingURL=standard-auth.js.map
@@ -48,4 +48,3 @@ exports.apiAuth = function (accessPath) {
48
48
  };
49
49
  };
50
50
  exports.forbiddenMessage = forbiddenMessage;
51
- //# sourceMappingURL=token-auth.js.map
@@ -38,4 +38,3 @@ exports.sanitize = function (request, cb) {
38
38
  }
39
39
  cb(null, action);
40
40
  };
41
- //# sourceMappingURL=action.js.map
@@ -68,4 +68,3 @@ describe('mode/action', function () {
68
68
  });
69
69
  });
70
70
  });
71
- //# sourceMappingURL=action.test.js.map
@@ -122,4 +122,3 @@ exports.sanitize = function (request, cb) {
122
122
  }
123
123
  cb(null, item);
124
124
  };
125
- //# sourceMappingURL=display-request.js.map
@@ -161,4 +161,3 @@ describe('model/display-request', function () {
161
161
  });
162
162
  });
163
163
  });
164
- //# sourceMappingURL=display-request.test.js.map
@@ -226,4 +226,3 @@ exports.sanitize = function (request, cb) {
226
226
  }
227
227
  cb(null, result);
228
228
  };
229
- //# sourceMappingURL=layout.js.map
@@ -322,4 +322,3 @@ describe('model/layout', function () {
322
322
  });
323
323
  });
324
324
  });
325
- //# sourceMappingURL=layout.test.js.map
@@ -134,4 +134,3 @@ const functions = {
134
134
  cb(null, t);
135
135
  },
136
136
  };
137
- //# sourceMappingURL=format.js.map