mockaton 10.4.1 → 10.4.2

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
@@ -431,8 +431,12 @@ config.plugins = [
431
431
  // IOW, your plugins array overwrites the default list. This way you can remove it.
432
432
  [/\.(js|ts)$/, jsToJsonPlugin],
433
433
 
434
+
434
435
  [/\.yml$/, yamlToJsonPlugin],
435
- [/foo\.GET\.200\.txt$/, capitalizePlugin], // e.g. GET /api/foo would be capitalized
436
+
437
+
438
+ // e.g. GET /api/foo would be capitalized
439
+ [/foo\.GET\.200\.txt$/, capitalizePlugin]
436
440
  ]
437
441
 
438
442
  function yamlToJsonPlugin(filePath) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mockaton",
3
3
  "description": "HTTP Mock Server",
4
4
  "type": "module",
5
- "version": "10.4.1",
5
+ "version": "10.4.2",
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
8
8
  "license": "MIT",
package/src/Dashboard.css CHANGED
@@ -385,7 +385,7 @@ table {
385
385
  border-top: 20px solid transparent;
386
386
  text-align: left;
387
387
  }
388
-
388
+
389
389
  > tr:first-child > th {
390
390
  border-top: 0;
391
391
  }
@@ -633,7 +633,7 @@ table {
633
633
  height: 2px;
634
634
  background: var(--colorComboBoxHeaderBackground);
635
635
 
636
- div {
636
+ > div {
637
637
  position: absolute;
638
638
  top: 0;
639
639
  left: 0;
package/src/Dashboard.js CHANGED
@@ -13,6 +13,8 @@ const Strings = {
13
13
  delay: 'Delay',
14
14
  delay_ms: 'Delay (ms)',
15
15
  empty_response_body: '/* Empty Response Body */',
16
+ error_server_down: 'Looks like the Mockaton server is not running',
17
+ error_unexpected_error: 'Unexpected Error',
16
18
  fallback_server: 'Fallback',
17
19
  fallback_server_error: '⛔ Fallback Backend Error',
18
20
  fallback_server_placeholder: 'Type backend address',
@@ -111,7 +113,7 @@ const state = {
111
113
  leftSideWidth: undefined
112
114
  }
113
115
 
114
- const mockaton = new Commander(window.location.origin)
116
+ const mockaton = new Commander(location.origin)
115
117
  updateState()
116
118
  initLongPoll()
117
119
 
@@ -124,7 +126,7 @@ async function updateState() {
124
126
  document.body.replaceChildren(...App())
125
127
  }
126
128
  catch (error) {
127
- onError(parseError(error))
129
+ onError(error)
128
130
  }
129
131
  }
130
132
 
@@ -449,7 +451,7 @@ function MockSelector(broker) {
449
451
  }
450
452
 
451
453
  let selected = broker.currentMock.file
452
- const { status, urlMask } = parseFilename(selected)
454
+ const { status } = parseFilename(selected)
453
455
  const files = broker.mocks.filter(item =>
454
456
  status === 500 ||
455
457
  !item.includes(AUTOGENERATED_500_COMMENT))
@@ -461,7 +463,7 @@ function MockSelector(broker) {
461
463
  function nameFor(file) {
462
464
  if (file === Strings.proxied)
463
465
  return Strings.proxied
464
- const { status, ext, method } = parseFilename(file)
466
+ const { status, ext } = parseFilename(file)
465
467
  const comments = extractComments(file)
466
468
  const isAutogen500 = comments.includes(AUTOGENERATED_500_COMMENT)
467
469
  return [
@@ -716,12 +718,7 @@ function PayloadViewer() {
716
718
  function PayloadViewerProgressBar() {
717
719
  return (
718
720
  r('div', className(CSS.ProgressBar),
719
- r('div', {
720
- style: {
721
- animationDelay: 80 + 'ms',
722
- animationDuration: -80 + state.delay + 'ms'
723
- }
724
- })))
721
+ r('div', { style: { animationDuration: state.delay + 'ms' } })))
725
722
  }
726
723
 
727
724
  function PayloadViewerTitle({ file, statusText }) {
@@ -750,14 +747,17 @@ async function previewMock(method, urlMask, href) {
750
747
  previewMock.controller?.abort()
751
748
  previewMock.controller = new AbortController
752
749
 
753
- payloadViewerTitleRef.current.replaceChildren(r('span', null, Strings.fetching))
754
- payloadViewerRef.current.replaceChildren(PayloadViewerProgressBar())
750
+ const spinnerTimer = setTimeout(() => {
751
+ payloadViewerTitleRef.current.replaceChildren(Strings.fetching)
752
+ payloadViewerRef.current.replaceChildren(PayloadViewerProgressBar())
753
+ }, 80)
755
754
 
756
755
  try {
757
756
  const response = await fetch(href, {
758
757
  method,
759
758
  signal: previewMock.controller.signal
760
759
  })
760
+ clearTimeout(spinnerTimer)
761
761
  await updatePayloadViewer(method, urlMask, response)
762
762
  }
763
763
  catch (err) {
@@ -834,9 +834,9 @@ function onError(error) {
834
834
  if (error?.name === 'AbortError')
835
835
  return
836
836
  if (error?.message === 'Failed to fetch')
837
- showErrorToast('Looks like the Mockaton server is not running')
837
+ showErrorToast(Strings.error_server_down)
838
838
  else
839
- showErrorToast(error || 'Unexpected Error')
839
+ showErrorToast(error || Strings.error_unexpected_error)
840
840
  console.error(error)
841
841
  }
842
842