@inspecto-dev/core 0.3.7 → 0.3.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/dist/{component-PVWVSPVZ.js → component-BLZBHHON.js} +45 -10
- package/dist/component-BLZBHHON.js.map +1 -0
- package/dist/index.cjs +46 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/component-PVWVSPVZ.js.map +0 -1
|
@@ -2061,6 +2061,8 @@ function createAnnotateOverlay(shadowRoot) {
|
|
|
2061
2061
|
|
|
2062
2062
|
// src/component-utils.ts
|
|
2063
2063
|
var ATTR_NAME = "data-inspecto";
|
|
2064
|
+
var ASTRO_FILE_ATTR_NAME = "data-astro-source-file";
|
|
2065
|
+
var ASTRO_LOC_ATTR_NAME = "data-astro-source-loc";
|
|
2064
2066
|
function parseAttrValue(value) {
|
|
2065
2067
|
const parts = value.split(":");
|
|
2066
2068
|
if (parts.length < 3) return null;
|
|
@@ -2070,9 +2072,29 @@ function parseAttrValue(value) {
|
|
|
2070
2072
|
if (isNaN(line) || isNaN(col) || !file) return null;
|
|
2071
2073
|
return { file, line, column: col };
|
|
2072
2074
|
}
|
|
2075
|
+
function parseAstroAttrValue(file, loc) {
|
|
2076
|
+
const parts = loc.split(":");
|
|
2077
|
+
if (parts.length !== 2) return null;
|
|
2078
|
+
const line = parseInt(parts[0], 10);
|
|
2079
|
+
const column = parseInt(parts[1], 10);
|
|
2080
|
+
if (isNaN(line) || isNaN(column) || !file) return null;
|
|
2081
|
+
return { file, line, column };
|
|
2082
|
+
}
|
|
2083
|
+
function getInspectableLocation(el) {
|
|
2084
|
+
const attrValue = el.getAttribute(ATTR_NAME);
|
|
2085
|
+
if (attrValue) {
|
|
2086
|
+
return parseAttrValue(attrValue);
|
|
2087
|
+
}
|
|
2088
|
+
const astroFile = el.getAttribute(ASTRO_FILE_ATTR_NAME);
|
|
2089
|
+
const astroLoc = el.getAttribute(ASTRO_LOC_ATTR_NAME);
|
|
2090
|
+
if (astroFile && astroLoc) {
|
|
2091
|
+
return parseAstroAttrValue(astroFile, astroLoc);
|
|
2092
|
+
}
|
|
2093
|
+
return null;
|
|
2094
|
+
}
|
|
2073
2095
|
function findInspectable(el) {
|
|
2074
2096
|
while (el) {
|
|
2075
|
-
if (el
|
|
2097
|
+
if (getInspectableLocation(el)) return el;
|
|
2076
2098
|
el = el.parentElement;
|
|
2077
2099
|
}
|
|
2078
2100
|
return null;
|
|
@@ -2276,7 +2298,16 @@ function findElementForLocation(_ctx, location, selector) {
|
|
|
2276
2298
|
const byLocation = Array.from(document.querySelectorAll(`[${ATTR_NAME}]`)).find(
|
|
2277
2299
|
(candidate) => candidate.getAttribute(ATTR_NAME) === locationAttr
|
|
2278
2300
|
);
|
|
2279
|
-
|
|
2301
|
+
if (byLocation instanceof Element) {
|
|
2302
|
+
return byLocation;
|
|
2303
|
+
}
|
|
2304
|
+
const byAstroLocation = Array.from(
|
|
2305
|
+
document.querySelectorAll("[data-astro-source-file][data-astro-source-loc]")
|
|
2306
|
+
).find((candidate) => {
|
|
2307
|
+
const candidateLocation = getInspectableLocation(candidate);
|
|
2308
|
+
return (candidateLocation == null ? void 0 : candidateLocation.file) === location.file && candidateLocation.line === location.line && candidateLocation.column === location.column;
|
|
2309
|
+
});
|
|
2310
|
+
return byAstroLocation instanceof Element ? byAstroLocation : null;
|
|
2280
2311
|
}
|
|
2281
2312
|
function rebindCurrentAnnotationElements(ctx) {
|
|
2282
2313
|
const state = asAnnotateContext(ctx);
|
|
@@ -4829,9 +4860,8 @@ function handleMouseMove(ctx, event) {
|
|
|
4829
4860
|
state.overlay.hide();
|
|
4830
4861
|
return;
|
|
4831
4862
|
}
|
|
4832
|
-
const
|
|
4833
|
-
const loc =
|
|
4834
|
-
const label = loc ? `${(_a2 = loc.file.split("/").pop()) != null ? _a2 : ""}:${loc.line}` : attrValue;
|
|
4863
|
+
const loc = getInspectableLocation(target);
|
|
4864
|
+
const label = loc ? `${(_a2 = loc.file.split("/").pop()) != null ? _a2 : ""}:${loc.line}` : "";
|
|
4835
4865
|
if (state.mode === "annotate" && state.annotateCapturePaused) {
|
|
4836
4866
|
state.overlay.hide();
|
|
4837
4867
|
return;
|
|
@@ -4858,8 +4888,7 @@ function handleTrigger(ctx, event) {
|
|
|
4858
4888
|
if (state.mode === "annotate" && state.annotateCapturePaused) return;
|
|
4859
4889
|
event.preventDefault();
|
|
4860
4890
|
event.stopPropagation();
|
|
4861
|
-
const
|
|
4862
|
-
const loc = parseAttrValue(attrValue);
|
|
4891
|
+
const loc = getInspectableLocation(target);
|
|
4863
4892
|
if (!loc) return;
|
|
4864
4893
|
if (state.mode === "annotate") {
|
|
4865
4894
|
if (state.annotateQuickCaptureEnabled) {
|
|
@@ -4879,10 +4908,13 @@ function handleTrigger(ctx, event) {
|
|
|
4879
4908
|
state.openInspectMenu(loc, event.clientX, event.clientY, target);
|
|
4880
4909
|
}
|
|
4881
4910
|
function handleKeyDown(ctx, event) {
|
|
4882
|
-
var _a2;
|
|
4883
4911
|
const state = asInteractionContext(ctx);
|
|
4884
4912
|
if (event.key === "Escape") {
|
|
4885
|
-
(
|
|
4913
|
+
if (state.cleanupMenu !== null) {
|
|
4914
|
+
state.cleanupMenu();
|
|
4915
|
+
} else if (!state.disabled) {
|
|
4916
|
+
state.pause();
|
|
4917
|
+
}
|
|
4886
4918
|
state.overlay.hide();
|
|
4887
4919
|
}
|
|
4888
4920
|
state.updateLauncherEye();
|
|
@@ -6396,6 +6428,9 @@ var InspectoElement = class extends BaseElement {
|
|
|
6396
6428
|
updateLauncherEye() {
|
|
6397
6429
|
updateLauncherEye(this);
|
|
6398
6430
|
}
|
|
6431
|
+
pause() {
|
|
6432
|
+
this.setPaused(true);
|
|
6433
|
+
}
|
|
6399
6434
|
openInspectMenu(loc, clientX, clientY, targetElement) {
|
|
6400
6435
|
openInspectMenu(this, loc, clientX, clientY, targetElement);
|
|
6401
6436
|
}
|
|
@@ -6556,4 +6591,4 @@ if (typeof customElements !== "undefined" && !customElements.get("inspecto-overl
|
|
|
6556
6591
|
export {
|
|
6557
6592
|
InspectoElement
|
|
6558
6593
|
};
|
|
6559
|
-
//# sourceMappingURL=component-
|
|
6594
|
+
//# sourceMappingURL=component-BLZBHHON.js.map
|