mockaton 7.4.1 → 7.5.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
@@ -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.0",
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
@@ -23,7 +23,7 @@
23
23
  :root {
24
24
  --color4xxBackground: #403630;
25
25
  --colorAccent: #1f91ff;
26
- --colorBackground: #141414;
26
+ --colorBackground: #161616;
27
27
  --colorComboBoxBackground: #252525;
28
28
  --colorComboBoxHeaderBackground: #222;
29
29
  --colorDisabled: #aaa;
@@ -155,7 +155,7 @@ main {
155
155
 
156
156
  .PayloadViewer {
157
157
  position: sticky;
158
- top: 80px;
158
+ top: 60px;
159
159
  width: 50%;
160
160
  margin-left: 20px;
161
161
 
@@ -168,13 +168,15 @@ main {
168
168
  max-height: calc(100vh - 160px);
169
169
  padding: 12px;
170
170
  padding-left: 0;
171
- margin-top: 6px;
172
- border-radius: 4px;
173
- white-space: pre;
174
- tab-size: 2;
175
171
 
176
- code * {
172
+ code {
173
+ white-space: pre;
174
+ tab-size: 2;
177
175
  font-family: monospace;
176
+
177
+ * {
178
+ font-family: monospace;
179
+ }
178
180
  }
179
181
  }
180
182
  }
@@ -307,6 +309,7 @@ main {
307
309
  * Prism
308
310
  */
309
311
 
312
+
310
313
  @media (prefers-color-scheme: dark) {
311
314
  .token.cdata, .token.comment, .token.doctype, .token.prolog {
312
315
  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