mockaton 10.6.7 → 10.6.8
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 +1 -1
- package/src/Dashboard.css +3 -1
- package/src/Dashboard.js +6 -5
- package/src/DashboardStore.js +20 -23
package/package.json
CHANGED
package/src/Dashboard.css
CHANGED
|
@@ -78,7 +78,7 @@ body {
|
|
|
78
78
|
|
|
79
79
|
select, a, input, button {
|
|
80
80
|
cursor: pointer;
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
&:focus-visible {
|
|
83
83
|
outline: 2px solid var(--colorAccent);
|
|
84
84
|
}
|
|
@@ -628,6 +628,8 @@ table {
|
|
|
628
628
|
background: var(--colorAccent);
|
|
629
629
|
animation-name: _kfProgress;
|
|
630
630
|
animation-timing-function: linear;
|
|
631
|
+
animation-iteration-count: infinite;
|
|
632
|
+
animation-direction: alternate;
|
|
631
633
|
/* duration in JavaScript */
|
|
632
634
|
}
|
|
633
635
|
}
|
package/src/Dashboard.js
CHANGED
|
@@ -65,7 +65,7 @@ initKeyboardNavigation()
|
|
|
65
65
|
function render() {
|
|
66
66
|
restoreFocus(() => document.body.replaceChildren(...App()))
|
|
67
67
|
if (store.hasChosenLink)
|
|
68
|
-
previewMock(
|
|
68
|
+
previewMock()
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
const t = translation => translation[0]
|
|
@@ -317,7 +317,7 @@ function renderRow(method, urlMask) {
|
|
|
317
317
|
unChooseOld()
|
|
318
318
|
trFor(Row.key(method, urlMask))
|
|
319
319
|
.replaceWith(Row(store.brokerAsRow(method, urlMask)))
|
|
320
|
-
previewMock(
|
|
320
|
+
previewMock()
|
|
321
321
|
})
|
|
322
322
|
|
|
323
323
|
function trFor(key) {
|
|
@@ -362,7 +362,7 @@ function MockSelector(row) {
|
|
|
362
362
|
CSS.MockSelector,
|
|
363
363
|
row.selectedIdx > 0 && CSS.nonDefault,
|
|
364
364
|
row.selectedFileIs4xx && CSS.status4xx)
|
|
365
|
-
}, row.opts.map(([value, label, selected]) =>
|
|
365
|
+
}, row.opts.map(([value, label, selected]) =>
|
|
366
366
|
r('option', { value, selected }, label))))
|
|
367
367
|
}
|
|
368
368
|
|
|
@@ -586,7 +586,6 @@ function PayloadViewerTitleWhenProxied({ mime, status, statusText, gatewayIsBad
|
|
|
586
586
|
' ' + mime))
|
|
587
587
|
}
|
|
588
588
|
|
|
589
|
-
// TODO indeterminate when there's store.delayJitter
|
|
590
589
|
const SPINNER_DELAY = 80
|
|
591
590
|
function PayloadViewerProgressBar() {
|
|
592
591
|
return (
|
|
@@ -594,7 +593,9 @@ function PayloadViewerProgressBar() {
|
|
|
594
593
|
r('div', { style: { animationDuration: store.delay - SPINNER_DELAY + 'ms' } })))
|
|
595
594
|
}
|
|
596
595
|
|
|
597
|
-
async function previewMock(
|
|
596
|
+
async function previewMock() {
|
|
597
|
+
const { method, urlMask } = store.chosenLink
|
|
598
|
+
|
|
598
599
|
previewMock.controller?.abort()
|
|
599
600
|
previewMock.controller = new AbortController
|
|
600
601
|
|
package/src/DashboardStore.js
CHANGED
|
@@ -12,11 +12,8 @@ export const store = {
|
|
|
12
12
|
render() {},
|
|
13
13
|
renderRow(method, urlMask) {},
|
|
14
14
|
|
|
15
|
-
/** @type {State.brokersByMethod} */
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/** @type {State.staticBrokers} */
|
|
19
|
-
staticBrokers: {},
|
|
15
|
+
brokersByMethod: /** @type {State.brokersByMethod} */ {},
|
|
16
|
+
staticBrokers: /** @type {State.staticBrokers} */ {},
|
|
20
17
|
|
|
21
18
|
cookies: [],
|
|
22
19
|
comments: [],
|
|
@@ -62,6 +59,7 @@ export const store = {
|
|
|
62
59
|
setChosenLink(method, urlMask) {
|
|
63
60
|
store.chosenLink = { method, urlMask }
|
|
64
61
|
},
|
|
62
|
+
|
|
65
63
|
|
|
66
64
|
async reset() {
|
|
67
65
|
try {
|
|
@@ -82,6 +80,7 @@ export const store = {
|
|
|
82
80
|
catch (error) { store.onError(error) }
|
|
83
81
|
},
|
|
84
82
|
|
|
83
|
+
|
|
85
84
|
async setGlobalDelay(value) {
|
|
86
85
|
try {
|
|
87
86
|
const response = await mockaton.setGlobalDelay(value)
|
|
@@ -126,35 +125,33 @@ export const store = {
|
|
|
126
125
|
|
|
127
126
|
_dittoCache: new Map(),
|
|
128
127
|
|
|
129
|
-
dittoedUrlFor(method, urlMask) {
|
|
130
|
-
return store._dittoCache.get(method + '::' + urlMask)
|
|
131
|
-
},
|
|
132
|
-
|
|
133
128
|
brokersAsRowsByMethod(method) {
|
|
134
129
|
const rows = store._brokersAsArray(method)
|
|
130
|
+
.map(b => new BrokerRowModel(b, store.canProxy))
|
|
131
|
+
.sort((a, b) => a.urlMask.localeCompare(b.urlMask))
|
|
135
132
|
const urlMasksDittoed = dittoSplitPaths(rows.map(r => r.urlMask))
|
|
136
|
-
|
|
137
|
-
|
|
133
|
+
rows.forEach((r, i) => {
|
|
134
|
+
store._dittoCache.set(r.method + '::' + r.urlMask, urlMasksDittoed[i])
|
|
138
135
|
r.setUrlMaskDittoed(urlMasksDittoed[i])
|
|
139
|
-
|
|
140
|
-
}
|
|
136
|
+
})
|
|
141
137
|
return rows
|
|
142
138
|
},
|
|
143
139
|
|
|
140
|
+
brokerAsRow(method, urlMask) {
|
|
141
|
+
const r = new BrokerRowModel(store.brokerFor(method, urlMask), store.canProxy)
|
|
142
|
+
r.setUrlMaskDittoed(store._dittoCache.get(r.method + '::' + r.urlMask))
|
|
143
|
+
return r
|
|
144
|
+
},
|
|
145
|
+
|
|
144
146
|
_brokersAsArray(byMethod = '*') {
|
|
145
|
-
const
|
|
147
|
+
const arr = []
|
|
146
148
|
for (const [method, brokers] of Object.entries(store.brokersByMethod))
|
|
147
149
|
if (byMethod === '*' || byMethod === method)
|
|
148
150
|
for (const broker of Object.values(brokers))
|
|
149
|
-
|
|
150
|
-
return
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
brokerAsRow(method, urlMask) {
|
|
154
|
-
const row = new BrokerRowModel(store.brokerFor(method, urlMask), store.canProxy)
|
|
155
|
-
row.setUrlMaskDittoed(store.dittoedUrlFor(method, urlMask))
|
|
156
|
-
return row
|
|
151
|
+
arr.push(broker)
|
|
152
|
+
return arr
|
|
157
153
|
},
|
|
154
|
+
|
|
158
155
|
|
|
159
156
|
previewLink(method, urlMask) {
|
|
160
157
|
store.setChosenLink(method, urlMask)
|
|
@@ -333,7 +330,7 @@ export class BrokerRowModel {
|
|
|
333
330
|
this.urlMask = urlMask
|
|
334
331
|
this.opts = this.#makeOptions()
|
|
335
332
|
}
|
|
336
|
-
|
|
333
|
+
|
|
337
334
|
setUrlMaskDittoed(urlMaskDittoed) {
|
|
338
335
|
this.urlMaskDittoed = urlMaskDittoed
|
|
339
336
|
}
|