mockaton 10.3.6 → 10.4.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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mockaton",
3
3
  "description": "HTTP Mock Server",
4
4
  "type": "module",
5
- "version": "10.3.6",
5
+ "version": "10.4.0",
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
8
8
  "license": "MIT",
package/src/Dashboard.css CHANGED
@@ -43,7 +43,7 @@
43
43
  --colorComboBoxBackground: #2a2a2a;
44
44
  --colorSecondaryButtonBackground: #2a2a2a;
45
45
  --colorSecondaryActionBorder: #333;
46
- --colorSecondaryAction: #999;
46
+ --colorSecondaryAction: #aaa;
47
47
  --colorComboBoxHeaderBackground: #222;
48
48
  --colorDisabledMockSelector: #b9b9b9;
49
49
  --colorHover: #023661;
@@ -168,7 +168,7 @@ header {
168
168
  width: 100px;
169
169
  align-self: center;
170
170
  }
171
-
171
+
172
172
  > div {
173
173
  width: 400px;
174
174
  .MenuTrigger {
@@ -347,7 +347,6 @@ main {
347
347
  .leftSide {
348
348
  width: 50%;
349
349
  padding: 16px;
350
- padding-bottom: 0;
351
350
  border-right: 1px solid var(--colorSecondaryActionBorder);
352
351
  user-select: none;
353
352
  overflow-y: auto;
@@ -383,11 +382,12 @@ table {
383
382
  th {
384
383
  padding-bottom: 2px;
385
384
  padding-left: 4px;
385
+ border-top: 20px solid transparent;
386
386
  text-align: left;
387
387
  }
388
-
389
- tbody {
390
- border-bottom: 20px solid transparent;
388
+
389
+ > tr:first-child > th {
390
+ border-top: 0;
391
391
  }
392
392
  }
393
393
 
@@ -395,12 +395,19 @@ table {
395
395
  margin-top: 80px;
396
396
  }
397
397
 
398
+ .Method {
399
+ padding-right: 8px;
400
+ color: var(--colorSecondaryAction);
401
+ text-align: center;
402
+ font-size: 11px;
403
+ }
398
404
 
399
405
  .PreviewLink {
400
406
  position: relative;
401
407
  left: -8px;
402
408
  display: inline-block;
403
409
  width: 100%;
410
+ min-width: 140px;
404
411
  padding: 6px 8px;
405
412
  margin-left: 4px;
406
413
  border-radius: var(--radius);
@@ -581,14 +588,12 @@ table {
581
588
  }
582
589
 
583
590
 
584
- .StaticFilesList {
585
- a {
586
- display: inline-block;
587
- padding: 6px 0;
588
- margin-left: 4px;
589
- border-radius: var(--radius);
590
- color: var(--colorAccent);
591
- }
591
+ .StaticFileLink {
592
+ display: inline-block;
593
+ padding: 6px 0;
594
+ margin-left: 4px;
595
+ border-radius: var(--radius);
596
+ color: var(--colorAccent);
592
597
  }
593
598
 
594
599
 
package/src/Dashboard.js CHANGED
@@ -46,6 +46,7 @@ const CSS = {
46
46
  GroupByMethod: null,
47
47
  InternalServerErrorToggler: null,
48
48
  MenuTrigger: null,
49
+ Method: null,
49
50
  MockList: null,
50
51
  MockSelector: null,
51
52
  NotFoundToggler: null,
@@ -57,7 +58,7 @@ const CSS = {
57
58
  Resizer: null,
58
59
  SaveProxiedCheckbox: null,
59
60
  SettingsMenu: null,
60
- StaticFilesList: null,
61
+ StaticFileLink: null,
61
62
 
62
63
  chosen: null,
63
64
  dittoDir: null,
@@ -142,8 +143,9 @@ function App() {
142
143
  style: { width: leftSideWidth + 'px' },
143
144
  className: CSS.leftSide
144
145
  },
145
- MockList(),
146
- StaticFilesList()),
146
+ r('table', null,
147
+ MockList(),
148
+ StaticFilesList())),
147
149
  r('div', { className: CSS.rightSide },
148
150
  Resizer(),
149
151
  PayloadViewer()))
@@ -275,6 +277,12 @@ function GlobalDelayField() {
275
277
  .then(parseError)
276
278
  .catch(onError)
277
279
  }
280
+ function onWheel(event) {
281
+ const val = this.valueAsNumber - event.deltaY * 10
282
+ this.valueAsNumber = Math.max(val, 0)
283
+ clearTimeout(onWheel.timer)
284
+ onWheel.timer = setTimeout(onChange.bind(this), 300)
285
+ }
278
286
  return (
279
287
  r('label', className(CSS.Field, CSS.GlobalDelayField),
280
288
  r('span', null, Strings.delay_ms),
@@ -284,7 +292,8 @@ function GlobalDelayField() {
284
292
  step: 100,
285
293
  autocomplete: 'none',
286
294
  value: delay,
287
- onChange
295
+ onChange,
296
+ onWheel
288
297
  })))
289
298
  }
290
299
 
@@ -363,28 +372,24 @@ function MockList() {
363
372
  Strings.no_mocks_found))
364
373
 
365
374
  if (groupByMethod)
366
- return (
367
- r('div', null,
368
- r('table', null, Object.keys(brokersByMethod).map(method =>
369
- r('tbody', null,
370
- r('tr', null,
371
- r('th', { colspan: 2 + Number(canProxy) }),
372
- r('th', null, method)),
373
- rowsFor(method).map(Row))))))
375
+ return Object.keys(brokersByMethod).map((method) => Fragment(
376
+ r('tr', null,
377
+ r('th', { colspan: 2 + Number(canProxy) }),
378
+ r('th', null, method)),
379
+ rowsFor(method).map(Row)))
374
380
 
375
- return (
376
- r('div', null,
377
- r('table', null,
378
- r('tbody', null, rowsFor('*').map(Row)))))
381
+ return rowsFor('*').map(Row)
379
382
  }
380
383
 
384
+
381
385
  function Row({ method, urlMask, urlMaskDittoed, broker }) {
382
- const { canProxy } = state
386
+ const { canProxy, groupByMethod } = state
383
387
  return (
384
388
  r('tr', { 'data-method': method, 'data-urlMask': urlMask },
385
389
  canProxy && r('td', null, ProxyToggler(broker)),
386
390
  r('td', null, DelayRouteToggler(broker)),
387
391
  r('td', null, InternalServerErrorToggler(broker)),
392
+ !groupByMethod && r('td', className(CSS.Method), method),
388
393
  r('td', null, PreviewLink(method, urlMask, urlMaskDittoed)),
389
394
  r('td', null, MockSelector(broker))))
390
395
  }
@@ -434,8 +439,6 @@ function PreviewLink(method, urlMask, urlMaskDittoed) {
434
439
 
435
440
  /** @param {ClientMockBroker} broker */
436
441
  function MockSelector(broker) {
437
- const { groupByMethod } = state
438
-
439
442
  function onChange() {
440
443
  const { urlMask, method } = parseFilename(this.value)
441
444
  mockaton.select(this.value)
@@ -462,7 +465,6 @@ function MockSelector(broker) {
462
465
  const comments = extractComments(file)
463
466
  const isAutogen500 = comments.includes(AUTOGENERATED_500_COMMENT)
464
467
  return [
465
- groupByMethod ? '' : method,
466
468
  isAutogen500 ? '' : status,
467
469
  ext === 'empty' || ext === 'unknown' ? '' : ext,
468
470
  isAutogen500 ? Strings.auto500 : comments.join(' ')
@@ -553,26 +555,29 @@ function ProxyToggler(broker) {
553
555
  /** # StaticFilesList */
554
556
 
555
557
  function StaticFilesList() {
556
- const { staticBrokers, canProxy } = state
558
+ const { staticBrokers, canProxy, groupByMethod } = state
557
559
  if (!Object.keys(staticBrokers).length)
558
560
  return null
559
561
  const dp = dittoSplitPaths(Object.keys(staticBrokers)).map(([ditto, tail]) => ditto
560
562
  ? [r('span', className(CSS.dittoDir), ditto), tail]
561
563
  : tail)
562
564
  return (
563
- r('table', className(CSS.StaticFilesList),
564
- r('thead', null,
565
+ Fragment(
566
+ r('tr', null,
567
+ r('th', { colspan: (2 + Number(!groupByMethod)) + Number(canProxy) }),
568
+ r('th', null, Strings.static_get)),
569
+ Object.values(staticBrokers).map((broker, i) =>
565
570
  r('tr', null,
566
- r('th', { colspan: 2 + Number(canProxy) }),
567
- r('th', null, Strings.static_get))),
568
- r('tbody', null,
569
- Object.values(staticBrokers).map((broker, i) =>
570
- r('tr', null,
571
- canProxy && r('td', null, ProxyStaticToggler()),
572
- r('td', null, DelayStaticRouteToggler(broker)),
573
- r('td', null, NotFoundToggler(broker)),
574
- r('td', null, r('a', { href: broker.route, target: '_blank' }, dp[i]))
575
- )))))
571
+ canProxy && r('td', null, ProxyStaticToggler()),
572
+ r('td', null, DelayStaticRouteToggler(broker)),
573
+ r('td', null, NotFoundToggler(broker)),
574
+ !groupByMethod && r('td', className(CSS.Method), 'GET'),
575
+ r('td', null, r('a', {
576
+ href: broker.route,
577
+ target: '_blank',
578
+ className: CSS.StaticFileLink
579
+ }, dp[i]))
580
+ ))))
576
581
  }
577
582
 
578
583
  /** @param {ClientStaticBroker} broker */
@@ -934,6 +939,16 @@ function useRef() {
934
939
  return { current: null }
935
940
  }
936
941
 
942
+ function Fragment(...args) {
943
+ const frag = new DocumentFragment()
944
+ for (const arg of args)
945
+ if (Array.isArray(arg))
946
+ frag.append(...arg)
947
+ else
948
+ frag.appendChild(arg)
949
+ return frag
950
+ }
951
+
937
952
 
938
953
  /**
939
954
  * Think of this as a way of printing a directory tree in which
@@ -994,7 +1009,7 @@ function dittoSplitPaths(paths) {
994
1009
  function syntaxJSON(json) {
995
1010
  const MAX_NODES = 50_000
996
1011
  let nNodes = 0
997
- const frag = document.createDocumentFragment()
1012
+ const frag = new DocumentFragment()
998
1013
 
999
1014
  function span(className, textContent) {
1000
1015
  nNodes++
@@ -1042,7 +1057,7 @@ syntaxJSON.regex = /("(?:\\u[a-fA-F0-9]{4}|\\[^u]|[^\\"])*")(\s*:)?|([{}\[\],:\s
1042
1057
  function syntaxXML(xml) {
1043
1058
  const MAX_NODES = 50_000
1044
1059
  let nNodes = 0
1045
- const frag = document.createDocumentFragment()
1060
+ const frag = new DocumentFragment()
1046
1061
 
1047
1062
  function span(className, textContent) {
1048
1063
  nNodes++