mockaton 7.4.0 → 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.0",
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
@@ -10,11 +10,10 @@
10
10
  --colorComboBoxBackground: #fafafa;
11
11
  --colorComboBoxHeaderBackground: #fff;
12
12
  --colorDisabled: #222;
13
- --colorHeaderBackground: #f7f7f7;
13
+ --colorHeaderBackground: #fff;
14
14
  --colorHover: #dfefff;
15
15
  --colorLabel: #666;
16
16
  --colorLightRed: #ffe4ee;
17
- --colorMockBodyBackground: #fafafa;
18
17
  --colorRed: #da0f00;
19
18
  --colorSecondaryButtonBackground: #fafafa;
20
19
  --colorText: #000;
@@ -24,15 +23,14 @@
24
23
  :root {
25
24
  --color4xxBackground: #403630;
26
25
  --colorAccent: #1f91ff;
27
- --colorBackground: #141414;
26
+ --colorBackground: #161616;
28
27
  --colorComboBoxBackground: #252525;
29
28
  --colorComboBoxHeaderBackground: #222;
30
29
  --colorDisabled: #aaa;
31
- --colorHeaderBackground: #0b0b0b;
30
+ --colorHeaderBackground: #141414;
32
31
  --colorHover: #023661;
33
32
  --colorLabel: #aaa;
34
33
  --colorLightRed: #ffe4ee;
35
- --colorMockBodyBackground: #333;
36
34
  --colorRed: #f41606;
37
35
  --colorSecondaryButtonBackground: #444;
38
36
  --colorText: #fff;
@@ -85,15 +83,13 @@ menu {
85
83
  display: flex;
86
84
  width: 100%;
87
85
  align-items: flex-end;
88
- padding: 20px 16px;
89
- border-bottom: 1px solid rgba(0, 0, 0, 0.1);
86
+ padding: 16px 16px;
90
87
  background: var(--colorHeaderBackground);
91
88
  gap: 16px;
92
89
 
93
90
  img {
94
91
  width: 140px;
95
- margin-right: 76px;
96
- margin-left: -1px;
92
+ margin-right: 75px;
97
93
  }
98
94
 
99
95
  label {
@@ -139,7 +135,7 @@ menu {
139
135
  main {
140
136
  display: flex;
141
137
  align-items: flex-start;
142
- margin-top: 64px;
138
+ margin-top: 56px;
143
139
 
144
140
  > table {
145
141
  border-collapse: collapse;
@@ -159,9 +155,9 @@ main {
159
155
 
160
156
  .PayloadViewer {
161
157
  position: sticky;
162
- top: 80px;
158
+ top: 60px;
163
159
  width: 50%;
164
- margin-left: 16px;
160
+ margin-left: 20px;
165
161
 
166
162
  h2 {
167
163
  padding-top: 20px;
@@ -171,15 +167,16 @@ main {
171
167
  overflow: auto;
172
168
  max-height: calc(100vh - 160px);
173
169
  padding: 12px;
174
- margin-top: 6px;
175
- box-shadow: var(--boxShadow1);
176
- border-radius: 4px;
177
- background: var(--colorMockBodyBackground);
178
- white-space: pre;
179
- tab-size: 2;
170
+ padding-left: 0;
180
171
 
181
- code * {
172
+ code {
173
+ white-space: pre;
174
+ tab-size: 2;
182
175
  font-family: monospace;
176
+
177
+ * {
178
+ font-family: monospace;
179
+ }
183
180
  }
184
181
  }
185
182
  }
@@ -312,6 +309,7 @@ main {
312
309
  * Prism
313
310
  */
314
311
 
312
+
315
313
  @media (prefers-color-scheme: dark) {
316
314
  .token.cdata, .token.comment, .token.doctype, .token.prolog {
317
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