mockaton 7.4.1 → 7.5.1

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
@@ -360,4 +360,3 @@ await mockaton.reset()
360
360
  ## TODO
361
361
  - Refactor Tests
362
362
  - Dashboard. List `staticDir` and indicate if it’s overriding some mock.
363
- - Dashboard. Handle non-json Mock Preview (such as images)
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mockaton",
3
3
  "description": "A deterministic server-side for developing and testing frontend clients",
4
4
  "type": "module",
5
- "version": "7.4.1",
5
+ "version": "7.5.1",
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
8
8
  "license": "MIT",
@@ -1 +1,3 @@
1
- "This is an exact path (i.e. /api/user/friends)"
1
+ {
2
+ "_": "This is an exact path (i.e. /api/user/friends)"
3
+ }
@@ -1 +1,4 @@
1
- "This mock is for /api/user"
1
+ {
2
+ "_": "This mock is for /api/user",
3
+ "name": "John"
4
+ }
@@ -1 +1,3 @@
1
- "Two Dynamic Params. i.e. /api/video/stat/VIEWS/123"
1
+ {
2
+ "_": "Two Dynamic Params. i.e. /api/video/stat/VIEWS/123"
3
+ }
package/src/Dashboard.css CHANGED
@@ -7,10 +7,10 @@
7
7
  --color4xxBackground: #ffedd1;
8
8
  --colorAccent: #1e88e5;
9
9
  --colorBackground: #fff;
10
+ --colorHeaderBackground: #eee;
10
11
  --colorComboBoxBackground: #fafafa;
11
12
  --colorComboBoxHeaderBackground: #fff;
12
13
  --colorDisabled: #222;
13
- --colorHeaderBackground: #fff;
14
14
  --colorHover: #dfefff;
15
15
  --colorLabel: #666;
16
16
  --colorLightRed: #ffe4ee;
@@ -23,11 +23,11 @@
23
23
  :root {
24
24
  --color4xxBackground: #403630;
25
25
  --colorAccent: #1f91ff;
26
- --colorBackground: #141414;
26
+ --colorBackground: #161616;
27
+ --colorHeaderBackground: #090909;
27
28
  --colorComboBoxBackground: #252525;
28
29
  --colorComboBoxHeaderBackground: #222;
29
30
  --colorDisabled: #aaa;
30
- --colorHeaderBackground: #141414;
31
31
  --colorHover: #023661;
32
32
  --colorLabel: #aaa;
33
33
  --colorLightRed: #ffe4ee;
@@ -55,6 +55,7 @@ body {
55
55
  }
56
56
 
57
57
  select {
58
+ font-size: 100%;
58
59
  background: var(--colorComboBoxBackground);
59
60
  color: var(--colorText);
60
61
  cursor: pointer;
@@ -83,12 +84,14 @@ menu {
83
84
  display: flex;
84
85
  width: 100%;
85
86
  align-items: flex-end;
86
- padding: 16px 16px;
87
+ padding: 20px 16px;
87
88
  background: var(--colorHeaderBackground);
89
+ box-shadow: var(--boxShadow1);
88
90
  gap: 16px;
89
91
 
90
92
  img {
91
93
  width: 140px;
94
+ align-self: center;
92
95
  margin-right: 75px;
93
96
  }
94
97
 
@@ -135,7 +138,7 @@ menu {
135
138
  main {
136
139
  display: flex;
137
140
  align-items: flex-start;
138
- margin-top: 56px;
141
+ margin-top: 64px;
139
142
 
140
143
  > table {
141
144
  border-collapse: collapse;
@@ -155,7 +158,7 @@ main {
155
158
 
156
159
  .PayloadViewer {
157
160
  position: sticky;
158
- top: 80px;
161
+ top: 72px;
159
162
  width: 50%;
160
163
  margin-left: 20px;
161
164
 
@@ -165,16 +168,17 @@ main {
165
168
 
166
169
  pre {
167
170
  overflow: auto;
168
- max-height: calc(100vh - 160px);
169
- padding: 12px;
170
- padding-left: 0;
171
- margin-top: 6px;
172
- border-radius: 4px;
173
- white-space: pre;
174
- tab-size: 2;
175
-
176
- code * {
171
+ max-height: calc(100vh - 72px);
172
+ padding-top: 12px;
173
+
174
+ code {
175
+ white-space: pre;
176
+ tab-size: 2;
177
177
  font-family: monospace;
178
+
179
+ * {
180
+ font-family: monospace;
181
+ }
178
182
  }
179
183
  }
180
184
  }
@@ -307,6 +311,7 @@ main {
307
311
  * Prism
308
312
  */
309
313
 
314
+
310
315
  @media (prefers-color-scheme: dark) {
311
316
  .token.cdata, .token.comment, .token.doctype, .token.prolog {
312
317
  color: #8292a2
package/src/Dashboard.js CHANGED
@@ -172,9 +172,11 @@ function PreviewLink({ method, urlMask }) {
172
172
  document.querySelector(`.${CSS.PreviewLink}.${CSS.chosen}`)?.classList.remove(CSS.chosen)
173
173
  this.classList.add(CSS.chosen)
174
174
  clearTimeout(spinner)
175
- updatePayloadViewer(
176
- await res.text() || Strings.empty_response_body,
177
- res.headers.get('content-type'))
175
+ const mime = res.headers.get('content-type')
176
+ if (mime.startsWith('image/')) // naively assumes GET.200
177
+ renderPayloadImage(this.href)
178
+ else
179
+ updatePayloadViewer(await res.text() || Strings.empty_response_body, mime)
178
180
  refPayloadFile.current.innerText = this.closest('tr').querySelector('select').value
179
181
  }
180
182
  catch (error) {
@@ -190,8 +192,13 @@ function ProgressBar() {
190
192
  r('div', { style: { animationDuration: '1000ms' } }))) // TODO from Config.delay - 180
191
193
  }
192
194
 
195
+ function renderPayloadImage(href) {
196
+ empty(refPayloadViewer.current)
197
+ refPayloadViewer.current.append(r('img', { src: href }))
198
+ }
199
+
193
200
  function updatePayloadViewer(body, mime) {
194
- if (mime === 'application/json' && window.Prism)
201
+ if (mime === 'application/json' && window?.Prism.languages)
195
202
  refPayloadViewer.current.innerHTML = window.Prism.highlight(body, window.Prism.languages.json, 'json')
196
203
  else
197
204
  refPayloadViewer.current.innerText = body