mockaton 8.25.0 → 8.26.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.
package/README.md CHANGED
@@ -55,9 +55,9 @@ Nonetheless, there’s a programmatic API, which is handy
55
55
  for setting up tests (see **Commander API** section below).
56
56
 
57
57
  <picture>
58
- <source media="(prefers-color-scheme: light)" srcset="pixaton-tests/macos/pic-for-readme.vp880x800.light.gold.png">
59
- <source media="(prefers-color-scheme: dark)" srcset="pixaton-tests/macos/pic-for-readme.vp880x800.dark.gold.png">
60
- <img alt="Mockaton Dashboard" src="pixaton-tests/macos/pic-for-readme.vp880x800.light.gold.png">
58
+ <source media="(prefers-color-scheme: light)" srcset="pixaton-tests/macos/pic-for-readme.vp880x768.light.gold.png">
59
+ <source media="(prefers-color-scheme: dark)" srcset="pixaton-tests/macos/pic-for-readme.vp880x768.dark.gold.png">
60
+ <img alt="Mockaton Dashboard" src="pixaton-tests/macos/pic-for-readme.vp880x768.light.gold.png">
61
61
  </picture>
62
62
 
63
63
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mockaton",
3
3
  "description": "HTTP Mock Server",
4
4
  "type": "module",
5
- "version": "8.25.0",
5
+ "version": "8.26.0",
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
8
8
  "license": "MIT",
@@ -20,7 +20,7 @@
20
20
  "scripts": {
21
21
  "test": "node --test \"src/**/*.test.js\"",
22
22
  "coverage": "node --test --test-reporter=lcov --test-reporter-destination=.coverage/lcov.info --experimental-test-coverage \"src/**/*.test.js\"",
23
- "start": "node --watch src/cli.js -c dev.config.js",
23
+ "start": "node --watch src/cli.js",
24
24
  "pixaton": "node --test --import=./pixaton-tests/_setup.js --experimental-test-isolation=none \"pixaton-tests/**/*.test.js\"",
25
25
  "outdated": "npm outdated --parseable | awk -F: '{ printf \"npm i %-30s ;# %s\\n\", $4, $2 }'"
26
26
  },
package/src/Dashboard.css CHANGED
@@ -305,6 +305,10 @@ main {
305
305
  table {
306
306
  border-collapse: collapse;
307
307
 
308
+ tr {
309
+ border-top: 2px solid transparent;
310
+ }
311
+
308
312
  th {
309
313
  padding-bottom: 2px;
310
314
  padding-left: 4px;
@@ -314,12 +318,6 @@ table {
314
318
  tbody {
315
319
  border-bottom: 20px solid transparent;
316
320
  }
317
-
318
- td:nth-child(3),
319
- td:nth-child(4),
320
- td:nth-child(5) {
321
- max-width: 280px;
322
- }
323
321
  }
324
322
 
325
323
  .empty {
@@ -332,7 +330,7 @@ table {
332
330
  left: -8px;
333
331
  display: inline-block;
334
332
  width: 100%;
335
- padding: 8px;
333
+ padding: 6px 8px;
336
334
  margin-left: 4px;
337
335
  border-radius: var(--radius);
338
336
  color: var(--colorAccent);
@@ -349,9 +347,8 @@ table {
349
347
  }
350
348
 
351
349
  .MockSelector {
352
- width: 100%;
353
350
  height: 26px;
354
- padding-right: 16px;
351
+ padding-right: 20px;
355
352
  padding-left: 8px;
356
353
  text-overflow: ellipsis;
357
354
  font-size: 12px;
package/src/Dashboard.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { DEFAULT_500_COMMENT, HEADER_FOR_502 } from './ApiConstants.js'
2
- import { parseFilename } from './Filename.js'
2
+ import { parseFilename, extractComments } from './Filename.js'
3
3
  import { Commander } from './ApiCommander.js'
4
4
 
5
5
 
@@ -394,11 +394,15 @@ function MockSelector({ broker }) {
394
394
  CSS.MockSelector,
395
395
  selected !== files[0] && CSS.nonDefault,
396
396
  status >= 400 && status < 500 && CSS.status4xx)
397
- }, files.map(file =>
398
- r('option', {
399
- value: file,
400
- selected: file === selected
401
- }, file))))
397
+ }, files.map(file => {
398
+ const { status, ext } = parseFilename(file)
399
+ return (
400
+ r('option', {
401
+ value: file,
402
+ selected: file === selected
403
+ }, `${status} ${ext} ${extractComments(file).join(' ')}`)
404
+ )
405
+ })))
402
406
  }
403
407
 
404
408
  /** @param {{ broker: ClientMockBroker }} props */
@@ -582,7 +586,7 @@ function PayloadViewerTitle({ file, status, statusText }) {
582
586
  const { urlMask, method, ext } = parseFilename(file)
583
587
  return (
584
588
  r('span', null,
585
- urlMask + '.' + method + '.',
589
+ urlMask.replace(/^\//, '') + '.' + method + '.',
586
590
  r('abbr', { title: statusText }, status),
587
591
  '.' + ext))
588
592
  }
@@ -851,9 +855,12 @@ function dittoSplitPaths(paths) {
851
855
 
852
856
 
853
857
  function syntaxJSON(json) {
858
+ const MAX_NODES = 1000
859
+ let nNodes = 0
854
860
  const frag = document.createDocumentFragment()
855
861
 
856
862
  function span(className, textContent) {
863
+ nNodes++
857
864
  const s = document.createElement('span')
858
865
  s.className = className
859
866
  s.textContent = textContent
@@ -861,13 +868,17 @@ function syntaxJSON(json) {
861
868
  }
862
869
 
863
870
  function text(t) {
871
+ nNodes++
864
872
  frag.appendChild(document.createTextNode(t))
865
873
  }
866
874
 
867
875
  let match
868
876
  let lastIndex = 0
869
- syntaxJSON.regex.lastIndex = 0
877
+ syntaxJSON.regex.lastIndex = 0 // resets regex
870
878
  while ((match = syntaxJSON.regex.exec(json)) !== null) {
879
+ if (nNodes > MAX_NODES)
880
+ break
881
+
871
882
  if (match.index > lastIndex)
872
883
  text(json.slice(lastIndex, match.index))
873
884
 
@@ -882,6 +893,7 @@ function syntaxJSON(json) {
882
893
  else if (str) span(CSS.syntaxStr, str)
883
894
  else span(CSS.syntaxVal, full)
884
895
  }
896
+ frag.normalize()
885
897
  text(json.slice(lastIndex))
886
898
  return frag
887
899
  }
@@ -891,9 +903,12 @@ syntaxJSON.regex = /("(?:\\u[a-fA-F0-9]{4}|\\[^u]|[^\\"])*")(\s*:)?|([{}\[\],:\s
891
903
 
892
904
 
893
905
  function syntaxXML(xml) {
906
+ const MAX_NODES = 1000
907
+ let nNodes = 0
894
908
  const frag = document.createDocumentFragment()
895
909
 
896
910
  function span(className, textContent) {
911
+ nNodes++
897
912
  const s = document.createElement('span')
898
913
  s.className = className
899
914
  s.textContent = textContent
@@ -901,6 +916,7 @@ function syntaxXML(xml) {
901
916
  }
902
917
 
903
918
  function text(t) {
919
+ nNodes++
904
920
  frag.appendChild(document.createTextNode(t))
905
921
  }
906
922
 
@@ -908,6 +924,9 @@ function syntaxXML(xml) {
908
924
  let lastIndex = 0
909
925
  syntaxXML.regex.lastIndex = 0
910
926
  while ((match = syntaxXML.regex.exec(xml)) !== null) {
927
+ if (nNodes > MAX_NODES)
928
+ break
929
+
911
930
  if (match.index > lastIndex)
912
931
  text(xml.slice(lastIndex, match.index))
913
932
 
@@ -919,6 +938,7 @@ function syntaxXML(xml) {
919
938
  else if (match[4]) span(CSS.syntaxAttrVal, match[4])
920
939
  }
921
940
  text(xml.slice(lastIndex))
941
+ frag.normalize()
922
942
  return frag
923
943
  }
924
944
  syntaxXML.regex = /(<\/?|\/?>|\?>)|(?<=<\??\/?)([A-Za-z_:][\w:.-]*)|([A-Za-z_:][\w:.-]*)(?==)|("(?:[^"\\]|\\.)*")/g