@mobilewright/inspector 0.0.59 → 0.0.60
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/dist/lib/locator-derivation.d.ts +7 -5
- package/dist/lib/locator-derivation.d.ts.map +1 -1
- package/dist/lib/locator-derivation.js +43 -1
- package/dist/lib/locator-derivation.js.map +1 -1
- package/package.json +4 -4
- package/public/css/app.css +26 -6
- package/public/favicon.ico +0 -0
- package/public/index.html +2 -0
- package/public/js/app.js +62 -8
|
@@ -14,6 +14,11 @@ export type Locator = {
|
|
|
14
14
|
kind: 'text';
|
|
15
15
|
value: string;
|
|
16
16
|
};
|
|
17
|
+
interface ElementEntry {
|
|
18
|
+
node: ViewNode;
|
|
19
|
+
locator: Locator | null;
|
|
20
|
+
locators: Locator[];
|
|
21
|
+
}
|
|
17
22
|
/**
|
|
18
23
|
* Derive all matching mobilewright locators for a single ViewNode.
|
|
19
24
|
* Returns array ordered by priority: testId > role > label > text.
|
|
@@ -26,9 +31,6 @@ export declare function deriveLocator(node: ViewNode): Locator | null;
|
|
|
26
31
|
* Flatten a ViewNode tree depth-first and annotate each node with its locators.
|
|
27
32
|
* Nodes with no locatable field are included with locators: [].
|
|
28
33
|
*/
|
|
29
|
-
export declare function deriveElementList(roots: ViewNode[]):
|
|
30
|
-
|
|
31
|
-
locator: Locator | null;
|
|
32
|
-
locators: Locator[];
|
|
33
|
-
}>;
|
|
34
|
+
export declare function deriveElementList(roots: ViewNode[]): ElementEntry[];
|
|
35
|
+
export {};
|
|
34
36
|
//# sourceMappingURL=locator-derivation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locator-derivation.d.ts","sourceRoot":"","sources":["../../src/lib/locator-derivation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAavD,gFAAgF;AAChF,MAAM,MAAM,OAAO,GACf;IAAE,IAAI,EAAE,QAAQ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AE,CAanE"}
|
|
@@ -55,6 +55,48 @@ export function deriveLocators(node) {
|
|
|
55
55
|
export function deriveLocator(node) {
|
|
56
56
|
return deriveLocators(node)[0] ?? null;
|
|
57
57
|
}
|
|
58
|
+
function roleKey(role) {
|
|
59
|
+
return `${role.value}:${role.name ?? ''}`;
|
|
60
|
+
}
|
|
61
|
+
function roleLocatorOf(locators) {
|
|
62
|
+
return locators.find((l) => l.kind === 'role');
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* When several elements share a test ID, getByTestId cannot tell them apart.
|
|
66
|
+
* If every element of such a group has a role locator that matches nothing else
|
|
67
|
+
* in the tree, promote role to the primary locator for the whole group.
|
|
68
|
+
*/
|
|
69
|
+
function preferUniqueRolesOverDuplicateTestIds(entries) {
|
|
70
|
+
const testIdCounts = new Map();
|
|
71
|
+
const roleCounts = new Map();
|
|
72
|
+
const groupCanUseRoles = new Map();
|
|
73
|
+
for (const { locator, locators } of entries) {
|
|
74
|
+
if (locator?.kind === 'testId') {
|
|
75
|
+
testIdCounts.set(locator.value, (testIdCounts.get(locator.value) ?? 0) + 1);
|
|
76
|
+
}
|
|
77
|
+
const role = roleLocatorOf(locators);
|
|
78
|
+
if (role) {
|
|
79
|
+
roleCounts.set(roleKey(role), (roleCounts.get(roleKey(role)) ?? 0) + 1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
for (const { locator, locators } of entries) {
|
|
83
|
+
if (locator?.kind !== 'testId') {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const role = roleLocatorOf(locators);
|
|
87
|
+
const hasUniqueRole = role !== undefined && roleCounts.get(roleKey(role)) === 1;
|
|
88
|
+
groupCanUseRoles.set(locator.value, (groupCanUseRoles.get(locator.value) ?? true) && hasUniqueRole);
|
|
89
|
+
}
|
|
90
|
+
return entries.map(entry => {
|
|
91
|
+
const { locator, locators } = entry;
|
|
92
|
+
const role = roleLocatorOf(locators);
|
|
93
|
+
const isDuplicateTestId = locator?.kind === 'testId' && (testIdCounts.get(locator.value) ?? 0) > 1;
|
|
94
|
+
if (!isDuplicateTestId || !role || !groupCanUseRoles.get(locator.value)) {
|
|
95
|
+
return entry;
|
|
96
|
+
}
|
|
97
|
+
return { ...entry, locator: role, locators: [role, ...locators.filter(l => l !== role)] };
|
|
98
|
+
});
|
|
99
|
+
}
|
|
58
100
|
/**
|
|
59
101
|
* Flatten a ViewNode tree depth-first and annotate each node with its locators.
|
|
60
102
|
* Nodes with no locatable field are included with locators: [].
|
|
@@ -70,6 +112,6 @@ export function deriveElementList(roots) {
|
|
|
70
112
|
}
|
|
71
113
|
}
|
|
72
114
|
walk(roots);
|
|
73
|
-
return result;
|
|
115
|
+
return preferUniqueRolesOverDuplicateTestIds(result);
|
|
74
116
|
}
|
|
75
117
|
//# sourceMappingURL=locator-derivation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locator-derivation.js","sourceRoot":"","sources":["../../src/lib/locator-derivation.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,uFAAuF;AACvF,mFAAmF;AAGnF,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEjE,+EAA+E;AAC/E,kFAAkF;AAClF,kCAAkC;AAClC,MAAM,UAAU,GAAkC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AAEhF,gFAAgF;AAChF,+EAA+E;AAC/E,oEAAoE;AACpE,MAAM,4BAA4B,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"locator-derivation.js","sourceRoot":"","sources":["../../src/lib/locator-derivation.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,uFAAuF;AACvF,mFAAmF;AAGnF,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEjE,+EAA+E;AAC/E,kFAAkF;AAClF,kCAAkC;AAClC,MAAM,UAAU,GAAk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 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mobilewright/inspector",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.60",
|
|
4
4
|
"description": "Browser-based element inspector for Mobilewright",
|
|
5
5
|
"homepage": "https://mobilewright.dev",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": ">=
|
|
8
|
+
"node": ">=22.12.0"
|
|
9
9
|
},
|
|
10
10
|
"type": "module",
|
|
11
11
|
"main": "./dist/index.js",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"public"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@mobilewright/core": "^0.0.
|
|
35
|
-
"@mobilewright/protocol": "^0.0.
|
|
34
|
+
"@mobilewright/core": "^0.0.60",
|
|
35
|
+
"@mobilewright/protocol": "^0.0.60",
|
|
36
36
|
"express": "^5.2.1",
|
|
37
37
|
"open": "^10.2.0"
|
|
38
38
|
},
|
package/public/css/app.css
CHANGED
|
@@ -256,15 +256,33 @@ main {
|
|
|
256
256
|
overflow: hidden;
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
+
/* ---- Splitters ---- */
|
|
260
|
+
|
|
261
|
+
.splitter {
|
|
262
|
+
flex: 0 0 7px;
|
|
263
|
+
cursor: col-resize;
|
|
264
|
+
touch-action: none;
|
|
265
|
+
background: linear-gradient(var(--c-border), var(--c-border)) center / 1px 100% no-repeat;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.splitter:hover,
|
|
269
|
+
.splitter:focus-visible,
|
|
270
|
+
.splitter.dragging {
|
|
271
|
+
outline: none;
|
|
272
|
+
background: linear-gradient(var(--c-accent), var(--c-accent)) center / 3px 100% no-repeat;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.splitter:has(+ [hidden]) { display: none; }
|
|
276
|
+
|
|
259
277
|
/* ---- Screenshot pane ---- */
|
|
260
278
|
|
|
261
279
|
#screenshot-pane {
|
|
262
280
|
flex: 0 0 auto;
|
|
281
|
+
width: var(--screenshot-width, auto);
|
|
263
282
|
min-width: 300px;
|
|
264
283
|
max-width: 50%;
|
|
265
284
|
position: relative;
|
|
266
285
|
overflow: hidden;
|
|
267
|
-
border-right: 1px solid var(--c-border);
|
|
268
286
|
background: var(--c-pane-bg);
|
|
269
287
|
display: flex;
|
|
270
288
|
align-items: flex-start;
|
|
@@ -468,10 +486,11 @@ main {
|
|
|
468
486
|
/* ---- Detail pane ---- */
|
|
469
487
|
|
|
470
488
|
#detail-pane {
|
|
471
|
-
flex: 0 0 320px;
|
|
489
|
+
flex: 0 0 var(--detail-width, 320px);
|
|
490
|
+
min-width: 240px;
|
|
491
|
+
max-width: 60%;
|
|
472
492
|
overflow-y: auto;
|
|
473
493
|
background: var(--c-surface);
|
|
474
|
-
border-left: 1px solid var(--c-border);
|
|
475
494
|
display: flex;
|
|
476
495
|
flex-direction: column;
|
|
477
496
|
animation: slide-in 0.15s ease-out;
|
|
@@ -479,7 +498,7 @@ main {
|
|
|
479
498
|
|
|
480
499
|
@keyframes slide-in {
|
|
481
500
|
from { flex-basis: 0; opacity: 0; }
|
|
482
|
-
to { flex-basis: 320px; opacity: 1; }
|
|
501
|
+
to { flex-basis: var(--detail-width, 320px); opacity: 1; }
|
|
483
502
|
}
|
|
484
503
|
|
|
485
504
|
#detail-header {
|
|
@@ -674,15 +693,16 @@ main {
|
|
|
674
693
|
main {
|
|
675
694
|
flex-direction: column;
|
|
676
695
|
}
|
|
696
|
+
.splitter { display: none; }
|
|
677
697
|
#screenshot-pane {
|
|
698
|
+
width: auto;
|
|
678
699
|
max-width: 100%;
|
|
679
|
-
border-right: none;
|
|
680
700
|
border-bottom: 1px solid var(--c-border);
|
|
681
701
|
}
|
|
682
702
|
#detail-pane {
|
|
683
703
|
flex: 1;
|
|
684
704
|
width: 100%;
|
|
685
|
-
|
|
705
|
+
max-width: 100%;
|
|
686
706
|
border-top: 1px solid var(--c-border);
|
|
687
707
|
}
|
|
688
708
|
}
|
|
Binary file
|
package/public/index.html
CHANGED
|
@@ -57,9 +57,11 @@
|
|
|
57
57
|
<svg id="highlight-overlay" hidden></svg>
|
|
58
58
|
</div>
|
|
59
59
|
</section>
|
|
60
|
+
<div class="splitter" id="screenshot-splitter" role="separator" aria-orientation="vertical" aria-label="Resize device pane" tabindex="0"></div>
|
|
60
61
|
<section id="elements-pane">
|
|
61
62
|
<div id="elements-list"></div>
|
|
62
63
|
</section>
|
|
64
|
+
<div class="splitter" id="detail-splitter" role="separator" aria-orientation="vertical" aria-label="Resize inspector pane" tabindex="0"></div>
|
|
63
65
|
<section id="detail-pane" hidden>
|
|
64
66
|
<div id="detail-header">
|
|
65
67
|
<span id="detail-type"></span>
|
package/public/js/app.js
CHANGED
|
@@ -69,7 +69,7 @@ class ScreenshotPane {
|
|
|
69
69
|
this.#placeholderTitle = document.getElementById('placeholder-title')
|
|
70
70
|
this.#placeholderSub = document.getElementById('placeholder-sub')
|
|
71
71
|
this.#screenshotPane = document.getElementById('screenshot-pane')
|
|
72
|
-
|
|
72
|
+
new ResizeObserver(() => this.#constrainSize()).observe(this.#screenshotPane)
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
onElementClick(cb) { this.#onClickCb = cb }
|
|
@@ -162,6 +162,7 @@ class DetailPane {
|
|
|
162
162
|
#locatorsEl
|
|
163
163
|
#propsEl
|
|
164
164
|
#rawEl
|
|
165
|
+
#isRawExpanded = false // survives re-renders, so the section stays open across row clicks
|
|
165
166
|
#closeBtn
|
|
166
167
|
#onCloseCb = null
|
|
167
168
|
|
|
@@ -289,20 +290,21 @@ class DetailPane {
|
|
|
289
290
|
|
|
290
291
|
const toggle = document.createElement('button')
|
|
291
292
|
toggle.className = 'detail-raw-toggle'
|
|
292
|
-
toggle.textContent = `▶ Raw Attributes (${Object.keys(el.raw).length})`
|
|
293
293
|
this.#rawEl.appendChild(toggle)
|
|
294
294
|
|
|
295
295
|
const content = document.createElement('div')
|
|
296
296
|
content.className = 'detail-raw-content'
|
|
297
|
-
content.hidden = true
|
|
298
297
|
content.textContent = JSON.stringify(el.raw, null, 2)
|
|
299
298
|
|
|
299
|
+
const renderExpanded = () => {
|
|
300
|
+
content.hidden = !this.#isRawExpanded
|
|
301
|
+
toggle.textContent = `${this.#isRawExpanded ? '▼' : '▶'} Raw Attributes (${Object.keys(el.raw).length})`
|
|
302
|
+
}
|
|
303
|
+
renderExpanded()
|
|
304
|
+
|
|
300
305
|
toggle.addEventListener('click', () => {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
toggle.textContent = isHidden
|
|
304
|
-
? `▼ Raw Attributes (${Object.keys(el.raw).length})`
|
|
305
|
-
: `▶ Raw Attributes (${Object.keys(el.raw).length})`
|
|
306
|
+
this.#isRawExpanded = !this.#isRawExpanded
|
|
307
|
+
renderExpanded()
|
|
306
308
|
})
|
|
307
309
|
|
|
308
310
|
this.#rawEl.appendChild(content)
|
|
@@ -363,6 +365,8 @@ class ElementsPane {
|
|
|
363
365
|
if (this.#selectedRow) {
|
|
364
366
|
this.#selectedRow.classList.add('selected')
|
|
365
367
|
this.#selectedRow.scrollIntoView({ block: 'nearest' })
|
|
368
|
+
// Focus follows selection so arrow keys work after clicking the screenshot too.
|
|
369
|
+
this.#selectedRow.focus({ preventScroll: true })
|
|
366
370
|
}
|
|
367
371
|
}
|
|
368
372
|
|
|
@@ -440,6 +444,11 @@ class ElementsPane {
|
|
|
440
444
|
e.preventDefault()
|
|
441
445
|
this.#onClickCb?.(el.index)
|
|
442
446
|
}
|
|
447
|
+
const neighbour = { ArrowUp: row.previousElementSibling, ArrowDown: row.nextElementSibling }[e.key]
|
|
448
|
+
if (neighbour) {
|
|
449
|
+
e.preventDefault()
|
|
450
|
+
this.#onClickCb?.(Number(neighbour.dataset.index))
|
|
451
|
+
}
|
|
443
452
|
})
|
|
444
453
|
return row
|
|
445
454
|
}
|
|
@@ -744,6 +753,51 @@ function applyTheme(name) {
|
|
|
744
753
|
|
|
745
754
|
document.getElementById('theme-select')?.addEventListener('change', e => applyTheme(e.target.value))
|
|
746
755
|
|
|
756
|
+
// ---- Resizable panes ----
|
|
757
|
+
|
|
758
|
+
const KEYBOARD_RESIZE_STEP = 16
|
|
759
|
+
|
|
760
|
+
// direction: 1 when the pane is left of its splitter, -1 when right of it.
|
|
761
|
+
// CSS min/max-width on the pane does the clamping.
|
|
762
|
+
function makeResizable(splitter, pane, cssVar, direction) {
|
|
763
|
+
const main = splitter.parentElement
|
|
764
|
+
const storageKey = 'mobilewright-inspector' + cssVar
|
|
765
|
+
const setWidth = px => {
|
|
766
|
+
main.style.setProperty(cssVar, px + 'px')
|
|
767
|
+
localStorage.setItem(storageKey, pane.offsetWidth)
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
const saved = localStorage.getItem(storageKey)
|
|
771
|
+
if (saved) {
|
|
772
|
+
main.style.setProperty(cssVar, saved + 'px')
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
splitter.addEventListener('pointerdown', e => {
|
|
776
|
+
e.preventDefault()
|
|
777
|
+
splitter.setPointerCapture(e.pointerId)
|
|
778
|
+
splitter.classList.add('dragging')
|
|
779
|
+
const startX = e.clientX
|
|
780
|
+
const startWidth = pane.offsetWidth
|
|
781
|
+
const onMove = ev => setWidth(startWidth + (ev.clientX - startX) * direction)
|
|
782
|
+
splitter.addEventListener('pointermove', onMove)
|
|
783
|
+
splitter.addEventListener('lostpointercapture', () => {
|
|
784
|
+
splitter.removeEventListener('pointermove', onMove)
|
|
785
|
+
splitter.classList.remove('dragging')
|
|
786
|
+
}, { once: true })
|
|
787
|
+
})
|
|
788
|
+
|
|
789
|
+
splitter.addEventListener('keydown', e => {
|
|
790
|
+
const step = { ArrowLeft: -KEYBOARD_RESIZE_STEP, ArrowRight: KEYBOARD_RESIZE_STEP }[e.key]
|
|
791
|
+
if (step) {
|
|
792
|
+
e.preventDefault()
|
|
793
|
+
setWidth(pane.offsetWidth + step * direction)
|
|
794
|
+
}
|
|
795
|
+
})
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
makeResizable(document.getElementById('screenshot-splitter'), document.getElementById('screenshot-pane'), '--screenshot-width', 1)
|
|
799
|
+
makeResizable(document.getElementById('detail-splitter'), document.getElementById('detail-pane'), '--detail-width', -1)
|
|
800
|
+
|
|
747
801
|
// ---- Bootstrap ----
|
|
748
802
|
|
|
749
803
|
applyTheme(localStorage.getItem('mobilewright-inspector-theme') || 'void')
|