mockaton 10.3.5 → 10.3.7
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 +3 -3
- package/package.json +2 -2
- package/src/Dashboard.css +20 -14
- package/src/Dashboard.js +43 -35
package/README.md
CHANGED
|
@@ -60,9 +60,9 @@ Nonetheless, there’s a programmatic API, which is handy
|
|
|
60
60
|
for setting up tests (see **Commander API** section below).
|
|
61
61
|
|
|
62
62
|
<picture>
|
|
63
|
-
<source media="(prefers-color-scheme: light)" srcset="pixaton-tests/macos/pic-for-readme.
|
|
64
|
-
<source media="(prefers-color-scheme: dark)" srcset="pixaton-tests/macos/pic-for-readme.
|
|
65
|
-
<img alt="Mockaton Dashboard" src="pixaton-tests/macos/pic-for-readme.
|
|
63
|
+
<source media="(prefers-color-scheme: light)" srcset="pixaton-tests/macos/pic-for-readme.vp761x720.light.gold.png">
|
|
64
|
+
<source media="(prefers-color-scheme: dark)" srcset="pixaton-tests/macos/pic-for-readme.vp761x720.dark.gold.png">
|
|
65
|
+
<img alt="Mockaton Dashboard" src="pixaton-tests/macos/pic-for-readme.vp761x720.light.gold.png">
|
|
66
66
|
</picture>
|
|
67
67
|
|
|
68
68
|
|
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.
|
|
5
|
+
"version": "10.3.7",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"types": "index.d.ts",
|
|
8
8
|
"license": "MIT",
|
|
@@ -27,6 +27,6 @@
|
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"pixaton": "1.1.3",
|
|
30
|
-
"puppeteer": "24.
|
|
30
|
+
"puppeteer": "24.23.0"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/Dashboard.css
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
--colorComboBoxBackground: #2a2a2a;
|
|
44
44
|
--colorSecondaryButtonBackground: #2a2a2a;
|
|
45
45
|
--colorSecondaryActionBorder: #333;
|
|
46
|
-
--colorSecondaryAction: #
|
|
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 {
|
|
@@ -250,6 +250,7 @@ header {
|
|
|
250
250
|
|
|
251
251
|
input + span {
|
|
252
252
|
margin: 0;
|
|
253
|
+
margin-right: 4px;
|
|
253
254
|
}
|
|
254
255
|
input:disabled + span {
|
|
255
256
|
opacity: 0.8;
|
|
@@ -346,7 +347,6 @@ main {
|
|
|
346
347
|
.leftSide {
|
|
347
348
|
width: 50%;
|
|
348
349
|
padding: 16px;
|
|
349
|
-
padding-bottom: 0;
|
|
350
350
|
border-right: 1px solid var(--colorSecondaryActionBorder);
|
|
351
351
|
user-select: none;
|
|
352
352
|
overflow-y: auto;
|
|
@@ -382,11 +382,12 @@ table {
|
|
|
382
382
|
th {
|
|
383
383
|
padding-bottom: 2px;
|
|
384
384
|
padding-left: 4px;
|
|
385
|
+
border-top: 20px solid transparent;
|
|
385
386
|
text-align: left;
|
|
386
387
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
border-
|
|
388
|
+
|
|
389
|
+
> tr:first-child > th {
|
|
390
|
+
border-top: 0;
|
|
390
391
|
}
|
|
391
392
|
}
|
|
392
393
|
|
|
@@ -394,12 +395,19 @@ table {
|
|
|
394
395
|
margin-top: 80px;
|
|
395
396
|
}
|
|
396
397
|
|
|
398
|
+
.Method {
|
|
399
|
+
padding-right: 8px;
|
|
400
|
+
color: var(--colorSecondaryAction);
|
|
401
|
+
text-align: center;
|
|
402
|
+
font-size: 11px;
|
|
403
|
+
}
|
|
397
404
|
|
|
398
405
|
.PreviewLink {
|
|
399
406
|
position: relative;
|
|
400
407
|
left: -8px;
|
|
401
408
|
display: inline-block;
|
|
402
409
|
width: 100%;
|
|
410
|
+
min-width: 140px;
|
|
403
411
|
padding: 6px 8px;
|
|
404
412
|
margin-left: 4px;
|
|
405
413
|
border-radius: var(--radius);
|
|
@@ -580,14 +588,12 @@ table {
|
|
|
580
588
|
}
|
|
581
589
|
|
|
582
590
|
|
|
583
|
-
.
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
color: var(--colorAccent);
|
|
590
|
-
}
|
|
591
|
+
.StaticFileLink {
|
|
592
|
+
display: inline-block;
|
|
593
|
+
padding: 6px 0;
|
|
594
|
+
margin-left: 4px;
|
|
595
|
+
border-radius: var(--radius);
|
|
596
|
+
color: var(--colorAccent);
|
|
591
597
|
}
|
|
592
598
|
|
|
593
599
|
|
package/src/Dashboard.js
CHANGED
|
@@ -15,7 +15,7 @@ const Strings = {
|
|
|
15
15
|
empty_response_body: '/* Empty Response Body */',
|
|
16
16
|
fallback_server: 'Fallback',
|
|
17
17
|
fallback_server_error: '⛔ Fallback Backend Error',
|
|
18
|
-
fallback_server_placeholder: 'Type
|
|
18
|
+
fallback_server_placeholder: 'Type backend address',
|
|
19
19
|
fetching: 'Fetching…',
|
|
20
20
|
got: 'Got',
|
|
21
21
|
group_by_method: 'Group by Method',
|
|
@@ -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
|
-
|
|
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
|
-
|
|
146
|
-
|
|
146
|
+
r('table', null,
|
|
147
|
+
MockList(),
|
|
148
|
+
StaticFilesList())),
|
|
147
149
|
r('div', { className: CSS.rightSide },
|
|
148
150
|
Resizer(),
|
|
149
151
|
PayloadViewer()))
|
|
@@ -363,28 +365,24 @@ function MockList() {
|
|
|
363
365
|
Strings.no_mocks_found))
|
|
364
366
|
|
|
365
367
|
if (groupByMethod)
|
|
366
|
-
return (
|
|
367
|
-
r('
|
|
368
|
-
r('
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
r('th', { colspan: 2 + Number(canProxy) }),
|
|
372
|
-
r('th', null, method)),
|
|
373
|
-
rowsFor(method).map(Row))))))
|
|
368
|
+
return Object.keys(brokersByMethod).map((method) => Fragment(
|
|
369
|
+
r('tr', null,
|
|
370
|
+
r('th', { colspan: 2 + Number(canProxy) }),
|
|
371
|
+
r('th', null, method)),
|
|
372
|
+
rowsFor(method).map(Row)))
|
|
374
373
|
|
|
375
|
-
return (
|
|
376
|
-
r('div', null,
|
|
377
|
-
r('table', null,
|
|
378
|
-
r('tbody', null, rowsFor('*').map(Row)))))
|
|
374
|
+
return rowsFor('*').map(Row)
|
|
379
375
|
}
|
|
380
376
|
|
|
377
|
+
|
|
381
378
|
function Row({ method, urlMask, urlMaskDittoed, broker }) {
|
|
382
|
-
const { canProxy } = state
|
|
379
|
+
const { canProxy, groupByMethod } = state
|
|
383
380
|
return (
|
|
384
381
|
r('tr', { 'data-method': method, 'data-urlMask': urlMask },
|
|
385
382
|
canProxy && r('td', null, ProxyToggler(broker)),
|
|
386
383
|
r('td', null, DelayRouteToggler(broker)),
|
|
387
384
|
r('td', null, InternalServerErrorToggler(broker)),
|
|
385
|
+
!groupByMethod && r('td', className(CSS.Method), method),
|
|
388
386
|
r('td', null, PreviewLink(method, urlMask, urlMaskDittoed)),
|
|
389
387
|
r('td', null, MockSelector(broker))))
|
|
390
388
|
}
|
|
@@ -434,8 +432,6 @@ function PreviewLink(method, urlMask, urlMaskDittoed) {
|
|
|
434
432
|
|
|
435
433
|
/** @param {ClientMockBroker} broker */
|
|
436
434
|
function MockSelector(broker) {
|
|
437
|
-
const { groupByMethod } = state
|
|
438
|
-
|
|
439
435
|
function onChange() {
|
|
440
436
|
const { urlMask, method } = parseFilename(this.value)
|
|
441
437
|
mockaton.select(this.value)
|
|
@@ -462,7 +458,6 @@ function MockSelector(broker) {
|
|
|
462
458
|
const comments = extractComments(file)
|
|
463
459
|
const isAutogen500 = comments.includes(AUTOGENERATED_500_COMMENT)
|
|
464
460
|
return [
|
|
465
|
-
groupByMethod ? '' : method,
|
|
466
461
|
isAutogen500 ? '' : status,
|
|
467
462
|
ext === 'empty' || ext === 'unknown' ? '' : ext,
|
|
468
463
|
isAutogen500 ? Strings.auto500 : comments.join(' ')
|
|
@@ -553,26 +548,29 @@ function ProxyToggler(broker) {
|
|
|
553
548
|
/** # StaticFilesList */
|
|
554
549
|
|
|
555
550
|
function StaticFilesList() {
|
|
556
|
-
const { staticBrokers, canProxy } = state
|
|
551
|
+
const { staticBrokers, canProxy, groupByMethod } = state
|
|
557
552
|
if (!Object.keys(staticBrokers).length)
|
|
558
553
|
return null
|
|
559
554
|
const dp = dittoSplitPaths(Object.keys(staticBrokers)).map(([ditto, tail]) => ditto
|
|
560
555
|
? [r('span', className(CSS.dittoDir), ditto), tail]
|
|
561
556
|
: tail)
|
|
562
557
|
return (
|
|
563
|
-
|
|
564
|
-
r('
|
|
558
|
+
Fragment(
|
|
559
|
+
r('tr', null,
|
|
560
|
+
r('th', { colspan: (2 + Number(!groupByMethod)) + Number(canProxy) }),
|
|
561
|
+
r('th', null, Strings.static_get)),
|
|
562
|
+
Object.values(staticBrokers).map((broker, i) =>
|
|
565
563
|
r('tr', null,
|
|
566
|
-
r('
|
|
567
|
-
r('
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
r('
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
564
|
+
canProxy && r('td', null, ProxyStaticToggler()),
|
|
565
|
+
r('td', null, DelayStaticRouteToggler(broker)),
|
|
566
|
+
r('td', null, NotFoundToggler(broker)),
|
|
567
|
+
!groupByMethod && r('td', className(CSS.Method), 'GET'),
|
|
568
|
+
r('td', null, r('a', {
|
|
569
|
+
href: broker.route,
|
|
570
|
+
target: '_blank',
|
|
571
|
+
className: CSS.StaticFileLink
|
|
572
|
+
}, dp[i]))
|
|
573
|
+
))))
|
|
576
574
|
}
|
|
577
575
|
|
|
578
576
|
/** @param {ClientStaticBroker} broker */
|
|
@@ -934,6 +932,16 @@ function useRef() {
|
|
|
934
932
|
return { current: null }
|
|
935
933
|
}
|
|
936
934
|
|
|
935
|
+
function Fragment(...args) {
|
|
936
|
+
const frag = new DocumentFragment()
|
|
937
|
+
for (const arg of args)
|
|
938
|
+
if (Array.isArray(arg))
|
|
939
|
+
frag.append(...arg)
|
|
940
|
+
else
|
|
941
|
+
frag.appendChild(arg)
|
|
942
|
+
return frag
|
|
943
|
+
}
|
|
944
|
+
|
|
937
945
|
|
|
938
946
|
/**
|
|
939
947
|
* Think of this as a way of printing a directory tree in which
|
|
@@ -994,7 +1002,7 @@ function dittoSplitPaths(paths) {
|
|
|
994
1002
|
function syntaxJSON(json) {
|
|
995
1003
|
const MAX_NODES = 50_000
|
|
996
1004
|
let nNodes = 0
|
|
997
|
-
const frag =
|
|
1005
|
+
const frag = new DocumentFragment()
|
|
998
1006
|
|
|
999
1007
|
function span(className, textContent) {
|
|
1000
1008
|
nNodes++
|
|
@@ -1042,7 +1050,7 @@ syntaxJSON.regex = /("(?:\\u[a-fA-F0-9]{4}|\\[^u]|[^\\"])*")(\s*:)?|([{}\[\],:\s
|
|
|
1042
1050
|
function syntaxXML(xml) {
|
|
1043
1051
|
const MAX_NODES = 50_000
|
|
1044
1052
|
let nNodes = 0
|
|
1045
|
-
const frag =
|
|
1053
|
+
const frag = new DocumentFragment()
|
|
1046
1054
|
|
|
1047
1055
|
function span(className, textContent) {
|
|
1048
1056
|
nNodes++
|