@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
package/dist/index.cjs
CHANGED
|
@@ -2206,9 +2206,29 @@ function parseAttrValue(value) {
|
|
|
2206
2206
|
if (isNaN(line) || isNaN(col) || !file) return null;
|
|
2207
2207
|
return { file, line, column: col };
|
|
2208
2208
|
}
|
|
2209
|
+
function parseAstroAttrValue(file, loc) {
|
|
2210
|
+
const parts = loc.split(":");
|
|
2211
|
+
if (parts.length !== 2) return null;
|
|
2212
|
+
const line = parseInt(parts[0], 10);
|
|
2213
|
+
const column = parseInt(parts[1], 10);
|
|
2214
|
+
if (isNaN(line) || isNaN(column) || !file) return null;
|
|
2215
|
+
return { file, line, column };
|
|
2216
|
+
}
|
|
2217
|
+
function getInspectableLocation(el) {
|
|
2218
|
+
const attrValue = el.getAttribute(ATTR_NAME);
|
|
2219
|
+
if (attrValue) {
|
|
2220
|
+
return parseAttrValue(attrValue);
|
|
2221
|
+
}
|
|
2222
|
+
const astroFile = el.getAttribute(ASTRO_FILE_ATTR_NAME);
|
|
2223
|
+
const astroLoc = el.getAttribute(ASTRO_LOC_ATTR_NAME);
|
|
2224
|
+
if (astroFile && astroLoc) {
|
|
2225
|
+
return parseAstroAttrValue(astroFile, astroLoc);
|
|
2226
|
+
}
|
|
2227
|
+
return null;
|
|
2228
|
+
}
|
|
2209
2229
|
function findInspectable(el) {
|
|
2210
2230
|
while (el) {
|
|
2211
|
-
if (el
|
|
2231
|
+
if (getInspectableLocation(el)) return el;
|
|
2212
2232
|
el = el.parentElement;
|
|
2213
2233
|
}
|
|
2214
2234
|
return null;
|
|
@@ -2258,11 +2278,13 @@ function createElementSelector(element) {
|
|
|
2258
2278
|
}
|
|
2259
2279
|
return segments.join(" > ");
|
|
2260
2280
|
}
|
|
2261
|
-
var ATTR_NAME;
|
|
2281
|
+
var ATTR_NAME, ASTRO_FILE_ATTR_NAME, ASTRO_LOC_ATTR_NAME;
|
|
2262
2282
|
var init_component_utils = __esm({
|
|
2263
2283
|
"src/component-utils.ts"() {
|
|
2264
2284
|
"use strict";
|
|
2265
2285
|
ATTR_NAME = "data-inspecto";
|
|
2286
|
+
ASTRO_FILE_ATTR_NAME = "data-astro-source-file";
|
|
2287
|
+
ASTRO_LOC_ATTR_NAME = "data-astro-source-loc";
|
|
2266
2288
|
}
|
|
2267
2289
|
});
|
|
2268
2290
|
|
|
@@ -2424,7 +2446,16 @@ function findElementForLocation(_ctx, location, selector) {
|
|
|
2424
2446
|
const byLocation = Array.from(document.querySelectorAll(`[${ATTR_NAME}]`)).find(
|
|
2425
2447
|
(candidate) => candidate.getAttribute(ATTR_NAME) === locationAttr
|
|
2426
2448
|
);
|
|
2427
|
-
|
|
2449
|
+
if (byLocation instanceof Element) {
|
|
2450
|
+
return byLocation;
|
|
2451
|
+
}
|
|
2452
|
+
const byAstroLocation = Array.from(
|
|
2453
|
+
document.querySelectorAll("[data-astro-source-file][data-astro-source-loc]")
|
|
2454
|
+
).find((candidate) => {
|
|
2455
|
+
const candidateLocation = getInspectableLocation(candidate);
|
|
2456
|
+
return (candidateLocation == null ? void 0 : candidateLocation.file) === location.file && candidateLocation.line === location.line && candidateLocation.column === location.column;
|
|
2457
|
+
});
|
|
2458
|
+
return byAstroLocation instanceof Element ? byAstroLocation : null;
|
|
2428
2459
|
}
|
|
2429
2460
|
function rebindCurrentAnnotationElements(ctx) {
|
|
2430
2461
|
const state = asAnnotateContext(ctx);
|
|
@@ -5124,9 +5155,8 @@ function handleMouseMove(ctx, event) {
|
|
|
5124
5155
|
state.overlay.hide();
|
|
5125
5156
|
return;
|
|
5126
5157
|
}
|
|
5127
|
-
const
|
|
5128
|
-
const loc =
|
|
5129
|
-
const label = loc ? `${(_a2 = loc.file.split("/").pop()) != null ? _a2 : ""}:${loc.line}` : attrValue;
|
|
5158
|
+
const loc = getInspectableLocation(target);
|
|
5159
|
+
const label = loc ? `${(_a2 = loc.file.split("/").pop()) != null ? _a2 : ""}:${loc.line}` : "";
|
|
5130
5160
|
if (state.mode === "annotate" && state.annotateCapturePaused) {
|
|
5131
5161
|
state.overlay.hide();
|
|
5132
5162
|
return;
|
|
@@ -5153,8 +5183,7 @@ function handleTrigger(ctx, event) {
|
|
|
5153
5183
|
if (state.mode === "annotate" && state.annotateCapturePaused) return;
|
|
5154
5184
|
event.preventDefault();
|
|
5155
5185
|
event.stopPropagation();
|
|
5156
|
-
const
|
|
5157
|
-
const loc = parseAttrValue(attrValue);
|
|
5186
|
+
const loc = getInspectableLocation(target);
|
|
5158
5187
|
if (!loc) return;
|
|
5159
5188
|
if (state.mode === "annotate") {
|
|
5160
5189
|
if (state.annotateQuickCaptureEnabled) {
|
|
@@ -5174,10 +5203,13 @@ function handleTrigger(ctx, event) {
|
|
|
5174
5203
|
state.openInspectMenu(loc, event.clientX, event.clientY, target);
|
|
5175
5204
|
}
|
|
5176
5205
|
function handleKeyDown(ctx, event) {
|
|
5177
|
-
var _a2;
|
|
5178
5206
|
const state = asInteractionContext(ctx);
|
|
5179
5207
|
if (event.key === "Escape") {
|
|
5180
|
-
(
|
|
5208
|
+
if (state.cleanupMenu !== null) {
|
|
5209
|
+
state.cleanupMenu();
|
|
5210
|
+
} else if (!state.disabled) {
|
|
5211
|
+
state.pause();
|
|
5212
|
+
}
|
|
5181
5213
|
state.overlay.hide();
|
|
5182
5214
|
}
|
|
5183
5215
|
state.updateLauncherEye();
|
|
@@ -6779,6 +6811,9 @@ var init_component = __esm({
|
|
|
6779
6811
|
updateLauncherEye() {
|
|
6780
6812
|
updateLauncherEye(this);
|
|
6781
6813
|
}
|
|
6814
|
+
pause() {
|
|
6815
|
+
this.setPaused(true);
|
|
6816
|
+
}
|
|
6782
6817
|
openInspectMenu(loc, clientX, clientY, targetElement) {
|
|
6783
6818
|
openInspectMenu(this, loc, clientX, clientY, targetElement);
|
|
6784
6819
|
}
|
|
@@ -6950,7 +6985,7 @@ var TAG_NAME = "inspecto-overlay";
|
|
|
6950
6985
|
function mountInspector() {
|
|
6951
6986
|
return __async(this, arguments, function* (options = {}) {
|
|
6952
6987
|
if (typeof document === "undefined") return null;
|
|
6953
|
-
const { InspectoElement:
|
|
6988
|
+
const { InspectoElement: _InspectoElement } = yield Promise.resolve().then(() => (init_component(), component_exports));
|
|
6954
6989
|
const existing = document.querySelector(TAG_NAME);
|
|
6955
6990
|
if (existing) {
|
|
6956
6991
|
;
|