@treelocator/runtime 0.4.1 → 0.4.5
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/_generated_styles.js +115 -15
- package/dist/adapters/getElementInfo.js +3 -17
- package/dist/adapters/getParentsPath.js +3 -33
- package/dist/adapters/getTree.js +3 -33
- package/dist/adapters/jsx/getJSXComponentBoundingBox.js +0 -1
- package/dist/adapters/jsx/jsxAdapter.js +0 -3
- package/dist/adapters/jsx/runtimeStore.js +0 -12
- package/dist/adapters/react/reactAdapter.js +0 -8
- package/dist/adapters/resolveAdapter.d.ts +8 -0
- package/dist/adapters/resolveAdapter.js +28 -0
- package/dist/adapters/vue/vueAdapter.js +0 -14
- package/dist/browserApi.d.ts +1 -1
- package/dist/browserApi.js +8 -10
- package/dist/components/MaybeOutline.d.ts +1 -0
- package/dist/components/MaybeOutline.js +38 -29
- package/dist/components/Outline.d.ts +1 -0
- package/dist/components/Outline.js +20 -16
- package/dist/components/Runtime.js +30 -18
- package/dist/dejitter/recorder.js +0 -1
- package/dist/functions/formatAncestryChain.d.ts +6 -0
- package/dist/functions/formatAncestryChain.js +11 -0
- package/dist/functions/formatAncestryChain.test.js +75 -1
- package/dist/functions/getUsableName.js +0 -21
- package/dist/output.css +10 -40
- package/dist/types/types.d.ts +1 -32
- package/package.json +1 -1
- package/src/_generated_styles.ts +115 -15
- package/src/adapters/getElementInfo.tsx +3 -23
- package/src/adapters/getParentsPath.tsx +3 -42
- package/src/adapters/getTree.tsx +3 -42
- package/src/adapters/jsx/getJSXComponentBoundingBox.ts +0 -1
- package/src/adapters/jsx/jsxAdapter.ts +0 -2
- package/src/adapters/jsx/runtimeStore.ts +0 -11
- package/src/adapters/react/reactAdapter.ts +0 -7
- package/src/adapters/resolveAdapter.ts +38 -0
- package/src/adapters/vue/vueAdapter.ts +0 -14
- package/src/browserApi.ts +9 -12
- package/src/components/MaybeOutline.tsx +4 -2
- package/src/components/Outline.tsx +2 -1
- package/src/components/Runtime.tsx +27 -18
- package/src/dejitter/recorder.ts +43 -44
- package/src/functions/formatAncestryChain.test.ts +47 -0
- package/src/functions/formatAncestryChain.ts +11 -0
- package/src/functions/getUsableName.ts +0 -21
- package/src/types/types.ts +1 -32
- package/src/adapters/react/fiberToSimple.tsx +0 -72
- package/src/adapters/react/gatherFiberRoots.tsx +0 -36
- package/src/adapters/react/makeFiberId.tsx +0 -19
- package/src/adapters/react/searchDevtoolsRenderersForClosestTarget.ts +0 -15
- package/src/components/Button.tsx +0 -14
- package/src/components/ComponentOutline.tsx +0 -98
- package/src/components/SimpleNodeOutline.tsx +0 -27
- package/src/components/Tooltip.tsx +0 -28
- package/src/functions/cropPath.test.ts +0 -18
- package/src/functions/cropPath.ts +0 -12
- package/src/functions/evalTemplate.test.ts +0 -12
- package/src/functions/evalTemplate.ts +0 -8
- package/src/functions/findNames.ts +0 -20
- package/src/functions/getBoundingRect.tsx +0 -11
- package/src/functions/getComposedBoundingBox.tsx +0 -25
- package/src/functions/getIdsOnPathToRoot.tsx +0 -21
- package/src/functions/getMultipleElementsBoundingBox.tsx +0 -25
- package/src/functions/getPathToParent.tsx +0 -17
- package/src/functions/getUsableFileName.test.tsx +0 -24
- package/src/functions/getUsableFileName.tsx +0 -19
- package/src/functions/transformPath.test.ts +0 -28
- package/src/functions/transformPath.ts +0 -7
|
@@ -554,7 +554,7 @@ video {
|
|
|
554
554
|
display: none;
|
|
555
555
|
}
|
|
556
556
|
|
|
557
|
-
[type='text'],input:where(:not([type])),[type='email'],[type='url'],[type='password'],[type='number'],[type='date'],[type='datetime-local'],[type='month'],[type='search'],[type='tel'],[type='time'],[type='week'],[multiple],textarea,select {
|
|
557
|
+
input:where([type='text']),input:where(:not([type])),input:where([type='email']),input:where([type='url']),input:where([type='password']),input:where([type='number']),input:where([type='date']),input:where([type='datetime-local']),input:where([type='month']),input:where([type='search']),input:where([type='tel']),input:where([type='time']),input:where([type='week']),select:where([multiple]),textarea,select {
|
|
558
558
|
-webkit-appearance: none;
|
|
559
559
|
-moz-appearance: none;
|
|
560
560
|
appearance: none;
|
|
@@ -571,7 +571,7 @@ video {
|
|
|
571
571
|
--tw-shadow: 0 0 #0000;
|
|
572
572
|
}
|
|
573
573
|
|
|
574
|
-
[type='text']:focus, input:where(:not([type])):focus, [type='email']:focus, [type='url']:focus, [type='password']:focus, [type='number']:focus, [type='date']:focus, [type='datetime-local']:focus, [type='month']:focus, [type='search']:focus, [type='tel']:focus, [type='time']:focus, [type='week']:focus, [multiple]:focus, textarea:focus, select:focus {
|
|
574
|
+
input:where([type='text']):focus, input:where(:not([type])):focus, input:where([type='email']):focus, input:where([type='url']):focus, input:where([type='password']):focus, input:where([type='number']):focus, input:where([type='date']):focus, input:where([type='datetime-local']):focus, input:where([type='month']):focus, input:where([type='search']):focus, input:where([type='tel']):focus, input:where([type='time']):focus, input:where([type='week']):focus, select:where([multiple]):focus, textarea:focus, select:focus {
|
|
575
575
|
outline: 2px solid transparent;
|
|
576
576
|
outline-offset: 2px;
|
|
577
577
|
--tw-ring-inset: var(--tw-empty,/*!*/ /*!*/);
|
|
@@ -600,6 +600,11 @@ input::placeholder,textarea::placeholder {
|
|
|
600
600
|
|
|
601
601
|
::-webkit-date-and-time-value {
|
|
602
602
|
min-height: 1.5em;
|
|
603
|
+
text-align: inherit;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
::-webkit-datetime-edit {
|
|
607
|
+
display: inline-flex;
|
|
603
608
|
}
|
|
604
609
|
|
|
605
610
|
::-webkit-datetime-edit,::-webkit-datetime-edit-year-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-meridiem-field {
|
|
@@ -617,7 +622,7 @@ select {
|
|
|
617
622
|
print-color-adjust: exact;
|
|
618
623
|
}
|
|
619
624
|
|
|
620
|
-
[multiple],[size]:
|
|
625
|
+
select:where([multiple]),select:where([size]:not([size="1"])) {
|
|
621
626
|
background-image: initial;
|
|
622
627
|
background-position: initial;
|
|
623
628
|
background-repeat: unset;
|
|
@@ -627,7 +632,7 @@ select {
|
|
|
627
632
|
print-color-adjust: unset;
|
|
628
633
|
}
|
|
629
634
|
|
|
630
|
-
[type='checkbox'],[type='radio'] {
|
|
635
|
+
input:where([type='checkbox']),input:where([type='radio']) {
|
|
631
636
|
-webkit-appearance: none;
|
|
632
637
|
-moz-appearance: none;
|
|
633
638
|
appearance: none;
|
|
@@ -650,15 +655,15 @@ select {
|
|
|
650
655
|
--tw-shadow: 0 0 #0000;
|
|
651
656
|
}
|
|
652
657
|
|
|
653
|
-
[type='checkbox'] {
|
|
658
|
+
input:where([type='checkbox']) {
|
|
654
659
|
border-radius: 0px;
|
|
655
660
|
}
|
|
656
661
|
|
|
657
|
-
[type='radio'] {
|
|
662
|
+
input:where([type='radio']) {
|
|
658
663
|
border-radius: 100%;
|
|
659
664
|
}
|
|
660
665
|
|
|
661
|
-
[type='checkbox']:focus,[type='radio']:focus {
|
|
666
|
+
input:where([type='checkbox']):focus,input:where([type='radio']):focus {
|
|
662
667
|
outline: 2px solid transparent;
|
|
663
668
|
outline-offset: 2px;
|
|
664
669
|
--tw-ring-inset: var(--tw-empty,/*!*/ /*!*/);
|
|
@@ -670,7 +675,7 @@ select {
|
|
|
670
675
|
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
671
676
|
}
|
|
672
677
|
|
|
673
|
-
[type='checkbox']:checked,[type='radio']:checked {
|
|
678
|
+
input:where([type='checkbox']):checked,input:where([type='radio']):checked {
|
|
674
679
|
border-color: transparent;
|
|
675
680
|
background-color: currentColor;
|
|
676
681
|
background-size: 100% 100%;
|
|
@@ -678,20 +683,36 @@ select {
|
|
|
678
683
|
background-repeat: no-repeat;
|
|
679
684
|
}
|
|
680
685
|
|
|
681
|
-
[type='checkbox']:checked {
|
|
686
|
+
input:where([type='checkbox']):checked {
|
|
682
687
|
background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e");
|
|
683
688
|
}
|
|
684
689
|
|
|
685
|
-
|
|
690
|
+
@media (forced-colors: active) {
|
|
691
|
+
input:where([type='checkbox']):checked {
|
|
692
|
+
-webkit-appearance: auto;
|
|
693
|
+
-moz-appearance: auto;
|
|
694
|
+
appearance: auto;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
input:where([type='radio']):checked {
|
|
686
699
|
background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='8' cy='8' r='3'/%3e%3c/svg%3e");
|
|
687
700
|
}
|
|
688
701
|
|
|
689
|
-
|
|
702
|
+
@media (forced-colors: active) {
|
|
703
|
+
input:where([type='radio']):checked {
|
|
704
|
+
-webkit-appearance: auto;
|
|
705
|
+
-moz-appearance: auto;
|
|
706
|
+
appearance: auto;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
input:where([type='checkbox']):checked:hover,input:where([type='checkbox']):checked:focus,input:where([type='radio']):checked:hover,input:where([type='radio']):checked:focus {
|
|
690
711
|
border-color: transparent;
|
|
691
712
|
background-color: currentColor;
|
|
692
713
|
}
|
|
693
714
|
|
|
694
|
-
[type='checkbox']:indeterminate {
|
|
715
|
+
input:where([type='checkbox']):indeterminate {
|
|
695
716
|
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3e%3c/svg%3e");
|
|
696
717
|
border-color: transparent;
|
|
697
718
|
background-color: currentColor;
|
|
@@ -700,12 +721,20 @@ select {
|
|
|
700
721
|
background-repeat: no-repeat;
|
|
701
722
|
}
|
|
702
723
|
|
|
703
|
-
|
|
724
|
+
@media (forced-colors: active) {
|
|
725
|
+
input:where([type='checkbox']):indeterminate {
|
|
726
|
+
-webkit-appearance: auto;
|
|
727
|
+
-moz-appearance: auto;
|
|
728
|
+
appearance: auto;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
input:where([type='checkbox']):indeterminate:hover,input:where([type='checkbox']):indeterminate:focus {
|
|
704
733
|
border-color: transparent;
|
|
705
734
|
background-color: currentColor;
|
|
706
735
|
}
|
|
707
736
|
|
|
708
|
-
[type='file'] {
|
|
737
|
+
input:where([type='file']) {
|
|
709
738
|
background: unset;
|
|
710
739
|
border-color: inherit;
|
|
711
740
|
border-width: 0;
|
|
@@ -715,11 +744,45 @@ select {
|
|
|
715
744
|
line-height: inherit;
|
|
716
745
|
}
|
|
717
746
|
|
|
718
|
-
[type='file']:focus {
|
|
747
|
+
input:where([type='file']):focus {
|
|
719
748
|
outline: 1px solid ButtonText;
|
|
720
749
|
outline: 1px auto -webkit-focus-ring-color;
|
|
721
750
|
}
|
|
722
751
|
|
|
752
|
+
.container {
|
|
753
|
+
width: 100%;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
@media (min-width: 640px) {
|
|
757
|
+
.container {
|
|
758
|
+
max-width: 640px;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
@media (min-width: 768px) {
|
|
763
|
+
.container {
|
|
764
|
+
max-width: 768px;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
@media (min-width: 1024px) {
|
|
769
|
+
.container {
|
|
770
|
+
max-width: 1024px;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
@media (min-width: 1280px) {
|
|
775
|
+
.container {
|
|
776
|
+
max-width: 1280px;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
@media (min-width: 1536px) {
|
|
781
|
+
.container {
|
|
782
|
+
max-width: 1536px;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
723
786
|
.sr-only {
|
|
724
787
|
position: absolute;
|
|
725
788
|
width: 1px;
|
|
@@ -764,6 +827,10 @@ select {
|
|
|
764
827
|
position: relative;
|
|
765
828
|
}
|
|
766
829
|
|
|
830
|
+
.sticky {
|
|
831
|
+
position: sticky;
|
|
832
|
+
}
|
|
833
|
+
|
|
767
834
|
.-bottom-7 {
|
|
768
835
|
bottom: -1.75rem;
|
|
769
836
|
}
|
|
@@ -1108,6 +1175,12 @@ select {
|
|
|
1108
1175
|
overflow: scroll;
|
|
1109
1176
|
}
|
|
1110
1177
|
|
|
1178
|
+
.truncate {
|
|
1179
|
+
overflow: hidden;
|
|
1180
|
+
text-overflow: ellipsis;
|
|
1181
|
+
white-space: nowrap;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1111
1184
|
.text-ellipsis {
|
|
1112
1185
|
text-overflow: ellipsis;
|
|
1113
1186
|
}
|
|
@@ -1164,6 +1237,15 @@ select {
|
|
|
1164
1237
|
border-style: solid;
|
|
1165
1238
|
}
|
|
1166
1239
|
|
|
1240
|
+
.border-dashed {
|
|
1241
|
+
border-style: dashed;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
.border-amber-500 {
|
|
1245
|
+
--tw-border-opacity: 1;
|
|
1246
|
+
border-color: rgb(245 158 11 / var(--tw-border-opacity, 1));
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1167
1249
|
.border-blue-500 {
|
|
1168
1250
|
--tw-border-opacity: 1;
|
|
1169
1251
|
border-color: rgb(59 130 246 / var(--tw-border-opacity, 1));
|
|
@@ -1179,6 +1261,11 @@ select {
|
|
|
1179
1261
|
border-color: rgb(209 213 219 / var(--tw-border-opacity, 1));
|
|
1180
1262
|
}
|
|
1181
1263
|
|
|
1264
|
+
.border-gray-500 {
|
|
1265
|
+
--tw-border-opacity: 1;
|
|
1266
|
+
border-color: rgb(107 114 128 / var(--tw-border-opacity, 1));
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1182
1269
|
.border-gray-600 {
|
|
1183
1270
|
--tw-border-opacity: 1;
|
|
1184
1271
|
border-color: rgb(75 85 99 / var(--tw-border-opacity, 1));
|
|
@@ -1346,6 +1433,10 @@ select {
|
|
|
1346
1433
|
padding: 1rem;
|
|
1347
1434
|
}
|
|
1348
1435
|
|
|
1436
|
+
.p-5 {
|
|
1437
|
+
padding: 1.25rem;
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1349
1440
|
.p-6 {
|
|
1350
1441
|
padding: 1.5rem;
|
|
1351
1442
|
}
|
|
@@ -1681,10 +1772,19 @@ select {
|
|
|
1681
1772
|
--tw-ring-color: rgb(30 64 175 / var(--tw-ring-opacity, 1));
|
|
1682
1773
|
}
|
|
1683
1774
|
|
|
1775
|
+
.blur {
|
|
1776
|
+
--tw-blur: blur(8px);
|
|
1777
|
+
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1684
1780
|
.filter {
|
|
1685
1781
|
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
1686
1782
|
}
|
|
1687
1783
|
|
|
1784
|
+
.backdrop-filter {
|
|
1785
|
+
backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1688
1788
|
.transition {
|
|
1689
1789
|
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
|
|
1690
1790
|
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import jsxAdapter from "./jsx/jsxAdapter";
|
|
3
|
-
import svelteAdapter from "./svelte/svelteAdapter";
|
|
4
|
-
import vueAdapter from "./vue/vueAdapter";
|
|
1
|
+
import { resolveAdapter } from "./resolveAdapter";
|
|
5
2
|
export function getElementInfo(target, adapterId) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
if (adapterId === "svelte") {
|
|
10
|
-
return svelteAdapter.getElementInfo(target);
|
|
11
|
-
}
|
|
12
|
-
if (adapterId === "jsx") {
|
|
13
|
-
return jsxAdapter.getElementInfo(target);
|
|
14
|
-
}
|
|
15
|
-
if (adapterId === "vue") {
|
|
16
|
-
return vueAdapter.getElementInfo(target);
|
|
17
|
-
}
|
|
18
|
-
return jsxAdapter.getElementInfo(target) || reactAdapter.getElementInfo(target) || svelteAdapter.getElementInfo(target) || vueAdapter.getElementInfo(target);
|
|
3
|
+
const adapter = resolveAdapter(adapterId);
|
|
4
|
+
return adapter?.getElementInfo(target) ?? null;
|
|
19
5
|
}
|
|
@@ -1,35 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { detectJSX, detectReact, detectSvelte, detectVue } from "@locator/shared";
|
|
3
|
-
import svelteAdapter from "./svelte/svelteAdapter";
|
|
4
|
-
import jsxAdapter from "./jsx/jsxAdapter";
|
|
5
|
-
import vueAdapter from "./vue/vueAdapter";
|
|
1
|
+
import { resolveAdapter } from "./resolveAdapter";
|
|
6
2
|
export function getParentsPaths(target, adapterId) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
if (adapterId === "svelte" && svelteAdapter.getParentsPaths) {
|
|
11
|
-
return svelteAdapter.getParentsPaths(target);
|
|
12
|
-
}
|
|
13
|
-
if (adapterId === "vue" && vueAdapter.getParentsPaths) {
|
|
14
|
-
return vueAdapter.getParentsPaths(target);
|
|
15
|
-
}
|
|
16
|
-
if (adapterId === "jsx" && jsxAdapter.getParentsPaths) {
|
|
17
|
-
return jsxAdapter.getParentsPaths(target);
|
|
18
|
-
}
|
|
19
|
-
if (detectSvelte() && svelteAdapter.getParentsPaths) {
|
|
20
|
-
return svelteAdapter.getParentsPaths(target);
|
|
21
|
-
}
|
|
22
|
-
if (detectVue() && vueAdapter.getParentsPaths) {
|
|
23
|
-
return vueAdapter.getParentsPaths(target);
|
|
24
|
-
}
|
|
25
|
-
if (detectReact() && reactAdapter.getParentsPaths) {
|
|
26
|
-
return reactAdapter.getParentsPaths(target);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// // Must be last, because its global data leaks from Locator extension.
|
|
30
|
-
// // Because the extension is in SolidJS and it uses JSX plugin in dev mode.
|
|
31
|
-
if (detectJSX() && jsxAdapter.getParentsPaths) {
|
|
32
|
-
return jsxAdapter.getParentsPaths(target);
|
|
33
|
-
}
|
|
34
|
-
return [];
|
|
3
|
+
const adapter = resolveAdapter(adapterId);
|
|
4
|
+
return adapter?.getParentsPaths(target) ?? [];
|
|
35
5
|
}
|
package/dist/adapters/getTree.js
CHANGED
|
@@ -1,35 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import jsxAdapter from "./jsx/jsxAdapter";
|
|
3
|
-
import svelteAdapter from "./svelte/svelteAdapter";
|
|
4
|
-
import { detectJSX, detectReact, detectSvelte, detectVue } from "@locator/shared";
|
|
5
|
-
import vueAdapter from "./vue/vueAdapter";
|
|
1
|
+
import { resolveAdapter } from "./resolveAdapter";
|
|
6
2
|
export function getTree(target, adapterId) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
if (adapterId === "svelte" && svelteAdapter.getTree) {
|
|
11
|
-
return svelteAdapter.getTree(target);
|
|
12
|
-
}
|
|
13
|
-
if (adapterId === "vue" && vueAdapter.getTree) {
|
|
14
|
-
return vueAdapter.getTree(target);
|
|
15
|
-
}
|
|
16
|
-
if (adapterId === "jsx" && jsxAdapter.getTree) {
|
|
17
|
-
return jsxAdapter.getTree(target);
|
|
18
|
-
}
|
|
19
|
-
if (detectSvelte() && svelteAdapter.getTree) {
|
|
20
|
-
return svelteAdapter.getTree(target);
|
|
21
|
-
}
|
|
22
|
-
if (detectVue() && vueAdapter.getTree) {
|
|
23
|
-
return vueAdapter.getTree(target);
|
|
24
|
-
}
|
|
25
|
-
if (detectReact() && reactAdapter.getTree) {
|
|
26
|
-
return reactAdapter.getTree(target);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Must be last, because its global data leaks from Locator extension.
|
|
30
|
-
// Because the extension is in SolidJS and it uses JSX plugin in dev mode.
|
|
31
|
-
if (detectJSX() && jsxAdapter.getTree) {
|
|
32
|
-
return jsxAdapter.getTree(target);
|
|
33
|
-
}
|
|
34
|
-
return null;
|
|
3
|
+
const adapter = resolveAdapter(adapterId);
|
|
4
|
+
return adapter?.getTree?.(target) ?? null;
|
|
35
5
|
}
|
|
@@ -38,7 +38,6 @@ export function getJSXComponentBoundingBox(found, locatorData, componentFolder,
|
|
|
38
38
|
composedBox = mergeRects(composedBox, parent.getBoundingClientRect());
|
|
39
39
|
goParent(parent);
|
|
40
40
|
}
|
|
41
|
-
expData.wrappingComponentId;
|
|
42
41
|
}
|
|
43
42
|
} else {
|
|
44
43
|
// If there is no locatorjs-id or locatorjs, we should go to the parent, because it can be some library element
|
|
@@ -67,18 +67,6 @@ export function getDataForDataId(dataId) {
|
|
|
67
67
|
column: expData.loc.start.column || 0,
|
|
68
68
|
line: expData.loc.start.line || 0
|
|
69
69
|
};
|
|
70
|
-
|
|
71
|
-
// let label;
|
|
72
|
-
// if (expData.type === "jsx") {
|
|
73
|
-
// label =
|
|
74
|
-
// (expData.wrappingComponent ? `${expData.wrappingComponent}: ` : "") +
|
|
75
|
-
// expData.name;
|
|
76
|
-
// } else {
|
|
77
|
-
// label = `${expData.htmlTag ? `styled.${expData.htmlTag}` : "styled"}${
|
|
78
|
-
// expData.name ? `: ${expData.name}` : ""
|
|
79
|
-
// }`;
|
|
80
|
-
// }
|
|
81
|
-
|
|
82
70
|
return {
|
|
83
71
|
link,
|
|
84
72
|
label: expData.name,
|
|
@@ -23,14 +23,6 @@ export function getElementInfo(found) {
|
|
|
23
23
|
parentElements
|
|
24
24
|
} = result;
|
|
25
25
|
const allPotentialComponentFibers = getAllWrappingParents(component);
|
|
26
|
-
|
|
27
|
-
// This handles a common case when the component root is basically the comopnent itself, so I want to go to usage of the component
|
|
28
|
-
// TODO: whaat? why? currently I see that it adds the original styled components which is not necessary.
|
|
29
|
-
|
|
30
|
-
// if (fiber.return && fiber.return === fiber._debugOwner) {
|
|
31
|
-
// allPotentialComponentFibers.unshift(fiber.return);
|
|
32
|
-
// }
|
|
33
|
-
|
|
34
26
|
allPotentialComponentFibers.forEach(fiber => {
|
|
35
27
|
const fiberWithSource = findDebugSource(fiber);
|
|
36
28
|
if (fiberWithSource) {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AdapterObject } from "./adapterApi";
|
|
2
|
+
import type { AdapterId } from "../consts";
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the framework adapter to use.
|
|
5
|
+
* If an explicit adapterId is given, return that adapter.
|
|
6
|
+
* Otherwise, auto-detect the framework in priority order.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveAdapter(adapterId?: AdapterId): AdapterObject | null;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import reactAdapter from "./react/reactAdapter";
|
|
2
|
+
import jsxAdapter from "./jsx/jsxAdapter";
|
|
3
|
+
import svelteAdapter from "./svelte/svelteAdapter";
|
|
4
|
+
import vueAdapter from "./vue/vueAdapter";
|
|
5
|
+
import { detectJSX, detectReact, detectSvelte, detectVue } from "@locator/shared";
|
|
6
|
+
const adapterMap = {
|
|
7
|
+
react: reactAdapter,
|
|
8
|
+
svelte: svelteAdapter,
|
|
9
|
+
vue: vueAdapter,
|
|
10
|
+
jsx: jsxAdapter
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Resolve the framework adapter to use.
|
|
15
|
+
* If an explicit adapterId is given, return that adapter.
|
|
16
|
+
* Otherwise, auto-detect the framework in priority order.
|
|
17
|
+
*/
|
|
18
|
+
export function resolveAdapter(adapterId) {
|
|
19
|
+
if (adapterId) {
|
|
20
|
+
return adapterMap[adapterId] ?? null;
|
|
21
|
+
}
|
|
22
|
+
if (detectSvelte()) return svelteAdapter;
|
|
23
|
+
if (detectVue()) return vueAdapter;
|
|
24
|
+
if (detectReact()) return reactAdapter;
|
|
25
|
+
// Must be last: global data leaks from the LocatorJS extension (SolidJS + JSX plugin in dev)
|
|
26
|
+
if (detectJSX()) return jsxAdapter;
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
@@ -62,20 +62,6 @@ export class VueTreeNodeElement extends HtmlElementTreeNode {
|
|
|
62
62
|
getComponent() {
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
|
-
// getComponent(): TreeNodeComponent | null {
|
|
66
|
-
// const element = this.element as VueElement;
|
|
67
|
-
// const parentComponent = element.__vueParentComponent;
|
|
68
|
-
// if (parentComponent && parentComponent.type) {
|
|
69
|
-
// const { __name } = parentComponent.type;
|
|
70
|
-
// if (__name) {
|
|
71
|
-
// return {
|
|
72
|
-
// label: __name,
|
|
73
|
-
// definitionLink: this.getSource() || undefined,
|
|
74
|
-
// };
|
|
75
|
-
// }
|
|
76
|
-
// }
|
|
77
|
-
// return null;
|
|
78
|
-
// }
|
|
79
65
|
}
|
|
80
66
|
function getTree(element) {
|
|
81
67
|
const originalRoot = new VueTreeNodeElement(element);
|
package/dist/browserApi.d.ts
CHANGED
|
@@ -144,5 +144,5 @@ export interface LocatorJSAPI {
|
|
|
144
144
|
interactions: InteractionEvent[];
|
|
145
145
|
} | null>;
|
|
146
146
|
}
|
|
147
|
-
export declare function createBrowserAPI(
|
|
147
|
+
export declare function createBrowserAPI(adapterId?: AdapterId): LocatorJSAPI;
|
|
148
148
|
export declare function installBrowserAPI(adapterIdParam?: AdapterId): void;
|
package/dist/browserApi.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createTreeNode } from "./adapters/createTreeNode";
|
|
2
2
|
import { collectAncestry, formatAncestryChain } from "./functions/formatAncestryChain";
|
|
3
3
|
import { enrichAncestryWithSourceMaps } from "./functions/enrichAncestrySourceMaps";
|
|
4
|
-
let adapterId;
|
|
5
4
|
function resolveElement(elementOrSelector) {
|
|
6
5
|
if (typeof elementOrSelector === "string") {
|
|
7
6
|
const element = document.querySelector(elementOrSelector);
|
|
@@ -9,15 +8,15 @@ function resolveElement(elementOrSelector) {
|
|
|
9
8
|
}
|
|
10
9
|
return elementOrSelector;
|
|
11
10
|
}
|
|
12
|
-
function getAncestryForElement(element) {
|
|
11
|
+
function getAncestryForElement(element, adapterId) {
|
|
13
12
|
const treeNode = createTreeNode(element, adapterId);
|
|
14
13
|
if (!treeNode) {
|
|
15
14
|
return null;
|
|
16
15
|
}
|
|
17
16
|
return collectAncestry(treeNode);
|
|
18
17
|
}
|
|
19
|
-
async function getEnrichedAncestryForElement(element) {
|
|
20
|
-
const ancestry = getAncestryForElement(element);
|
|
18
|
+
async function getEnrichedAncestryForElement(element, adapterId) {
|
|
19
|
+
const ancestry = getAncestryForElement(element, adapterId);
|
|
21
20
|
if (!ancestry) return null;
|
|
22
21
|
return enrichAncestryWithSourceMaps(ancestry, element);
|
|
23
22
|
}
|
|
@@ -121,7 +120,7 @@ CYPRESS EXAMPLES:
|
|
|
121
120
|
----------------
|
|
122
121
|
|
|
123
122
|
cy.window().then((win) => {
|
|
124
|
-
const path = win.
|
|
123
|
+
const path = win.__treelocator__.getPath('button.submit');
|
|
125
124
|
cy.log(path);
|
|
126
125
|
});
|
|
127
126
|
|
|
@@ -134,29 +133,28 @@ NOTES:
|
|
|
134
133
|
|
|
135
134
|
Documentation: https://github.com/wende/treelocatorjs
|
|
136
135
|
`;
|
|
137
|
-
export function createBrowserAPI(
|
|
138
|
-
adapterId = adapterIdParam;
|
|
136
|
+
export function createBrowserAPI(adapterId) {
|
|
139
137
|
return {
|
|
140
138
|
getPath(elementOrSelector) {
|
|
141
139
|
const element = resolveElement(elementOrSelector);
|
|
142
140
|
if (!element) {
|
|
143
141
|
return Promise.resolve(null);
|
|
144
142
|
}
|
|
145
|
-
return getEnrichedAncestryForElement(element).then(ancestry => ancestry ? formatAncestryChain(ancestry) : null);
|
|
143
|
+
return getEnrichedAncestryForElement(element, adapterId).then(ancestry => ancestry ? formatAncestryChain(ancestry) : null);
|
|
146
144
|
},
|
|
147
145
|
getAncestry(elementOrSelector) {
|
|
148
146
|
const element = resolveElement(elementOrSelector);
|
|
149
147
|
if (!element) {
|
|
150
148
|
return Promise.resolve(null);
|
|
151
149
|
}
|
|
152
|
-
return getEnrichedAncestryForElement(element);
|
|
150
|
+
return getEnrichedAncestryForElement(element, adapterId);
|
|
153
151
|
},
|
|
154
152
|
getPathData(elementOrSelector) {
|
|
155
153
|
const element = resolveElement(elementOrSelector);
|
|
156
154
|
if (!element) {
|
|
157
155
|
return Promise.resolve(null);
|
|
158
156
|
}
|
|
159
|
-
return getEnrichedAncestryForElement(element).then(ancestry => ancestry ? {
|
|
157
|
+
return getEnrichedAncestryForElement(element, adapterId).then(ancestry => ancestry ? {
|
|
160
158
|
path: formatAncestryChain(ancestry),
|
|
161
159
|
ancestry
|
|
162
160
|
} : null);
|