@inspecto-dev/core 0.3.4 → 0.3.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/index.cjs
CHANGED
|
@@ -1059,7 +1059,9 @@ var init_styles_overlay_menu = __esm({
|
|
|
1059
1059
|
border: 1px solid var(--inspecto-border-subtle);
|
|
1060
1060
|
border-radius: var(--inspecto-radius-lg);
|
|
1061
1061
|
padding: 10px;
|
|
1062
|
-
|
|
1062
|
+
width: 304px;
|
|
1063
|
+
max-width: calc(100vw - 16px);
|
|
1064
|
+
box-sizing: border-box;
|
|
1063
1065
|
box-shadow: var(--inspecto-shadow-floating);
|
|
1064
1066
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
1065
1067
|
color: var(--inspecto-text-primary);
|
|
@@ -3797,7 +3799,11 @@ function buildCustomInspectPrompt(input) {
|
|
|
3797
3799
|
const prompt = appendCssContextToPrompt(
|
|
3798
3800
|
appendScreenshotContextToPrompt(
|
|
3799
3801
|
appendRuntimeContextToPrompt(
|
|
3800
|
-
buildPrompt(
|
|
3802
|
+
buildPrompt(
|
|
3803
|
+
buildCustomInspectPromptTemplate(input.ask.trim(), input.location, input.targetLabel),
|
|
3804
|
+
input.location,
|
|
3805
|
+
snippetResult
|
|
3806
|
+
),
|
|
3801
3807
|
(_b = (_a2 = input.runtimeContext) == null ? void 0 : _a2.records) != null ? _b : []
|
|
3802
3808
|
),
|
|
3803
3809
|
(_c = input.screenshotContext) != null ? _c : null
|
|
@@ -3810,6 +3816,19 @@ function buildCustomInspectPrompt(input) {
|
|
|
3810
3816
|
};
|
|
3811
3817
|
});
|
|
3812
3818
|
}
|
|
3819
|
+
function buildCustomInspectPromptTemplate(ask, location, targetLabel) {
|
|
3820
|
+
const sections = [CUSTOM_PROMPT_TEMPLATE(ask)];
|
|
3821
|
+
if (targetLabel == null ? void 0 : targetLabel.trim()) {
|
|
3822
|
+
sections.push(`Selected component:
|
|
3823
|
+
- ${targetLabel.trim()}`);
|
|
3824
|
+
}
|
|
3825
|
+
sections.push(
|
|
3826
|
+
`Source location:
|
|
3827
|
+
- file: ${location.file}
|
|
3828
|
+
- location: ${location.line}:${location.column}`
|
|
3829
|
+
);
|
|
3830
|
+
return sections.join("\n\n");
|
|
3831
|
+
}
|
|
3813
3832
|
var init_menu_send = __esm({
|
|
3814
3833
|
"src/menu-send.ts"() {
|
|
3815
3834
|
"use strict";
|
|
@@ -3829,7 +3848,14 @@ function createMenuHeaderDom(input) {
|
|
|
3829
3848
|
headerCopy.style.display = "flex";
|
|
3830
3849
|
headerCopy.style.flexDirection = "column";
|
|
3831
3850
|
headerCopy.style.gap = "2px";
|
|
3851
|
+
headerCopy.style.minWidth = "0";
|
|
3852
|
+
headerCopy.style.flex = "1 1 auto";
|
|
3832
3853
|
const title = document.createElement("strong");
|
|
3854
|
+
title.style.display = "block";
|
|
3855
|
+
title.style.minWidth = "0";
|
|
3856
|
+
title.style.whiteSpace = "nowrap";
|
|
3857
|
+
title.style.overflow = "hidden";
|
|
3858
|
+
title.style.textOverflow = "ellipsis";
|
|
3833
3859
|
title.textContent = ((_a2 = input.targetLabel) == null ? void 0 : _a2.trim()) || input.location.file.split("/").pop() || input.location.file;
|
|
3834
3860
|
const meta = document.createElement("div");
|
|
3835
3861
|
meta.className = menuMetaClass;
|
|
@@ -3933,6 +3959,26 @@ var init_menu_header = __esm({
|
|
|
3933
3959
|
}
|
|
3934
3960
|
});
|
|
3935
3961
|
|
|
3962
|
+
// src/menu-position.ts
|
|
3963
|
+
function resolveMenuPosition(input) {
|
|
3964
|
+
var _a2;
|
|
3965
|
+
const edgeMargin = (_a2 = input.edgeMargin) != null ? _a2 : DEFAULT_EDGE_MARGIN;
|
|
3966
|
+
const safeWidth = input.viewport.width > 0 ? input.viewport.width : input.menuRect.width + edgeMargin * 2;
|
|
3967
|
+
const safeHeight = input.viewport.height > 0 ? input.viewport.height : input.menuRect.height + edgeMargin * 2;
|
|
3968
|
+
const maxLeft = Math.max(safeWidth - input.menuRect.width - edgeMargin, edgeMargin);
|
|
3969
|
+
const left = Math.max(edgeMargin, Math.min(input.clickX, maxLeft));
|
|
3970
|
+
const maxTop = Math.max(safeHeight - input.menuRect.height - edgeMargin, edgeMargin);
|
|
3971
|
+
const top = Math.max(edgeMargin, Math.min(input.clickY + edgeMargin, maxTop));
|
|
3972
|
+
return { left, top };
|
|
3973
|
+
}
|
|
3974
|
+
var DEFAULT_EDGE_MARGIN;
|
|
3975
|
+
var init_menu_position = __esm({
|
|
3976
|
+
"src/menu-position.ts"() {
|
|
3977
|
+
"use strict";
|
|
3978
|
+
DEFAULT_EDGE_MARGIN = 8;
|
|
3979
|
+
}
|
|
3980
|
+
});
|
|
3981
|
+
|
|
3936
3982
|
// src/menu.ts
|
|
3937
3983
|
function showIntentMenu(shadowRoot, location, clickX, clickY, options, onClose, deps = {}) {
|
|
3938
3984
|
var _a2, _b, _c;
|
|
@@ -3947,6 +3993,10 @@ function showIntentMenu(shadowRoot, location, clickX, clickY, options, onClose,
|
|
|
3947
3993
|
const canAttachCssContext2 = typeof deps.captureCssContextPrompt === "function";
|
|
3948
3994
|
const menu = document.createElement("div");
|
|
3949
3995
|
menu.className = menuClass;
|
|
3996
|
+
menu.style.width = "304px";
|
|
3997
|
+
menu.style.maxWidth = "calc(100vw - 16px)";
|
|
3998
|
+
menu.style.boxSizing = "border-box";
|
|
3999
|
+
menu.style.pointerEvents = "auto";
|
|
3950
4000
|
const {
|
|
3951
4001
|
header,
|
|
3952
4002
|
headerActions,
|
|
@@ -4033,20 +4083,23 @@ function showIntentMenu(shadowRoot, location, clickX, clickY, options, onClose,
|
|
|
4033
4083
|
menu.appendChild(askAiSection);
|
|
4034
4084
|
const actionsSection = createMenuSection();
|
|
4035
4085
|
menu.appendChild(actionsSection);
|
|
4036
|
-
|
|
4037
|
-
const safeWidth = viewportWidth > 0 ? viewportWidth : MENU_WIDTH;
|
|
4038
|
-
menu.style.left = `${Math.min(clickX, Math.max(safeWidth - MENU_WIDTH, 0))}px`;
|
|
4086
|
+
menu.style.left = `${clickX}px`;
|
|
4039
4087
|
menu.style.visibility = "hidden";
|
|
4040
4088
|
menu.style.display = "block";
|
|
4041
4089
|
shadowRoot.appendChild(menu);
|
|
4042
4090
|
const updatePosition = () => {
|
|
4043
4091
|
const rect = menu.getBoundingClientRect();
|
|
4044
|
-
const
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4092
|
+
const { left: nextLeft, top: nextTop } = resolveMenuPosition({
|
|
4093
|
+
clickX,
|
|
4094
|
+
clickY,
|
|
4095
|
+
menuRect: { width: rect.width, height: rect.height },
|
|
4096
|
+
viewport: {
|
|
4097
|
+
width: document.documentElement.clientWidth || window.innerWidth || 0,
|
|
4098
|
+
height: document.documentElement.clientHeight || window.innerHeight || 0
|
|
4099
|
+
}
|
|
4100
|
+
});
|
|
4101
|
+
menu.style.left = `${nextLeft}px`;
|
|
4102
|
+
menu.style.top = `${nextTop}px`;
|
|
4050
4103
|
};
|
|
4051
4104
|
updatePosition();
|
|
4052
4105
|
menu.style.visibility = "visible";
|
|
@@ -4167,15 +4220,16 @@ function showIntentMenu(shadowRoot, location, clickX, clickY, options, onClose,
|
|
|
4167
4220
|
const requestRuntimeContext = resolveRuntimeContext();
|
|
4168
4221
|
const requestScreenshotContext = yield resolveScreenshotContext();
|
|
4169
4222
|
const requestCssContextPrompt = resolveCssContextPrompt();
|
|
4170
|
-
const built = yield buildCustomInspectPrompt({
|
|
4223
|
+
const built = yield buildCustomInspectPrompt(__spreadProps(__spreadValues({
|
|
4171
4224
|
location,
|
|
4172
|
-
ask: input.value.trim()
|
|
4225
|
+
ask: input.value.trim()
|
|
4226
|
+
}, deps.targetLabel ? { targetLabel: deps.targetLabel } : {}), {
|
|
4173
4227
|
includeSnippet,
|
|
4174
4228
|
maxSnippetLines,
|
|
4175
4229
|
runtimeContext: requestRuntimeContext,
|
|
4176
4230
|
screenshotContext: requestScreenshotContext,
|
|
4177
4231
|
cssContextPrompt: requestCssContextPrompt
|
|
4178
|
-
});
|
|
4232
|
+
}));
|
|
4179
4233
|
yield openAndSendInspectPrompt({
|
|
4180
4234
|
location,
|
|
4181
4235
|
promptText: built.prompt,
|
|
@@ -4268,7 +4322,6 @@ function showIntentMenu(shadowRoot, location, clickX, clickY, options, onClose,
|
|
|
4268
4322
|
});
|
|
4269
4323
|
return cleanup;
|
|
4270
4324
|
}
|
|
4271
|
-
var MENU_WIDTH;
|
|
4272
4325
|
var init_menu = __esm({
|
|
4273
4326
|
"src/menu.ts"() {
|
|
4274
4327
|
"use strict";
|
|
@@ -4276,9 +4329,9 @@ var init_menu = __esm({
|
|
|
4276
4329
|
init_menu_send();
|
|
4277
4330
|
init_http();
|
|
4278
4331
|
init_menu_header();
|
|
4332
|
+
init_menu_position();
|
|
4279
4333
|
init_menu_helpers();
|
|
4280
4334
|
init_styles();
|
|
4281
|
-
MENU_WIDTH = 280;
|
|
4282
4335
|
}
|
|
4283
4336
|
});
|
|
4284
4337
|
|
|
@@ -4913,6 +4966,10 @@ function handleMouseMove(ctx, event) {
|
|
|
4913
4966
|
state.lastPointerX = event.clientX;
|
|
4914
4967
|
state.lastPointerY = event.clientY;
|
|
4915
4968
|
state.updateLauncherEye();
|
|
4969
|
+
if (state.cleanupMenu !== null) {
|
|
4970
|
+
state.overlay.hide();
|
|
4971
|
+
return;
|
|
4972
|
+
}
|
|
4916
4973
|
const isActive = state.isInspectorActive(event);
|
|
4917
4974
|
if (!isActive) {
|
|
4918
4975
|
state.overlay.hide();
|
|
@@ -4934,8 +4991,8 @@ function handleMouseMove(ctx, event) {
|
|
|
4934
4991
|
event.stopPropagation();
|
|
4935
4992
|
}
|
|
4936
4993
|
function handleTrigger(ctx, event) {
|
|
4937
|
-
var _a2;
|
|
4938
4994
|
const state = asInteractionContext(ctx);
|
|
4995
|
+
if (state.cleanupMenu !== null) return;
|
|
4939
4996
|
if (!state.isInspectorActive(event)) return;
|
|
4940
4997
|
const target = findInspectable(event.target);
|
|
4941
4998
|
if (!target) return;
|
|
@@ -4954,11 +5011,12 @@ function handleTrigger(ctx, event) {
|
|
|
4954
5011
|
return;
|
|
4955
5012
|
}
|
|
4956
5013
|
if (state.shouldQuickJumpOnTrigger(event)) {
|
|
4957
|
-
|
|
5014
|
+
state.overlay.hide();
|
|
4958
5015
|
state.cleanupMenu = null;
|
|
4959
5016
|
void openFile(loc);
|
|
4960
5017
|
return;
|
|
4961
5018
|
}
|
|
5019
|
+
state.overlay.hide();
|
|
4962
5020
|
state.openInspectMenu(loc, event.clientX, event.clientY, target);
|
|
4963
5021
|
}
|
|
4964
5022
|
function handleKeyDown(ctx, event) {
|
|
@@ -4986,6 +5044,7 @@ function openInspectMenu(ctx, loc, clientX, clientY, targetElement) {
|
|
|
4986
5044
|
var _a2, _b;
|
|
4987
5045
|
const state = asInteractionContext(ctx);
|
|
4988
5046
|
(_a2 = state.cleanupMenu) == null ? void 0 : _a2.call(state);
|
|
5047
|
+
state.style.pointerEvents = "auto";
|
|
4989
5048
|
state.cleanupMenu = showIntentMenu(
|
|
4990
5049
|
state.shadowRootEl,
|
|
4991
5050
|
loc,
|
|
@@ -4993,6 +5052,7 @@ function openInspectMenu(ctx, loc, clientX, clientY, targetElement) {
|
|
|
4993
5052
|
clientY,
|
|
4994
5053
|
state.options,
|
|
4995
5054
|
() => {
|
|
5055
|
+
state.style.pointerEvents = "none";
|
|
4996
5056
|
state.cleanupMenu = null;
|
|
4997
5057
|
},
|
|
4998
5058
|
{
|
|
@@ -5516,11 +5576,14 @@ function createAnnotateSidebarRenderers({
|
|
|
5516
5576
|
titleEl.style.letterSpacing = "0.04em";
|
|
5517
5577
|
titleEl.textContent = title;
|
|
5518
5578
|
const contentEl = document.createElement("div");
|
|
5579
|
+
contentEl.style.minWidth = "0";
|
|
5580
|
+
contentEl.style.whiteSpace = "normal";
|
|
5581
|
+
contentEl.style.overflowWrap = "anywhere";
|
|
5582
|
+
contentEl.style.wordBreak = "break-word";
|
|
5519
5583
|
if (typeof content === "string") {
|
|
5520
5584
|
contentEl.style.fontSize = "13px";
|
|
5521
5585
|
contentEl.style.color = "rgba(255, 255, 255, 0.9)";
|
|
5522
5586
|
contentEl.style.lineHeight = "1.4";
|
|
5523
|
-
contentEl.style.wordBreak = "break-word";
|
|
5524
5587
|
if (title === "NOTE" && !chip.note.trim()) {
|
|
5525
5588
|
contentEl.style.fontStyle = "italic";
|
|
5526
5589
|
contentEl.style.color = "rgba(255, 255, 255, 0.4)";
|
|
@@ -5533,9 +5596,13 @@ function createAnnotateSidebarRenderers({
|
|
|
5533
5596
|
return section;
|
|
5534
5597
|
};
|
|
5535
5598
|
const elementValue = document.createElement("div");
|
|
5599
|
+
elementValue.style.minWidth = "0";
|
|
5536
5600
|
elementValue.style.fontFamily = "monospace";
|
|
5537
5601
|
elementValue.style.fontSize = "13px";
|
|
5538
5602
|
elementValue.style.color = "#9cdcfe";
|
|
5603
|
+
elementValue.style.whiteSpace = "normal";
|
|
5604
|
+
elementValue.style.overflowWrap = "anywhere";
|
|
5605
|
+
elementValue.style.wordBreak = "break-word";
|
|
5539
5606
|
elementValue.textContent = chip.label;
|
|
5540
5607
|
activeTooltip.appendChild(createSection("ELEMENT", elementValue));
|
|
5541
5608
|
activeTooltip.appendChild(createSection("NOTE", chip.note.trim() || "No note provided"));
|
|
@@ -5570,9 +5637,12 @@ function createAnnotateSidebarRenderers({
|
|
|
5570
5637
|
chipElement.className = annotateSidebarChipClass;
|
|
5571
5638
|
chipElement.contentEditable = "false";
|
|
5572
5639
|
chipElement.style.margin = "0 4px";
|
|
5640
|
+
chipElement.style.boxSizing = "border-box";
|
|
5573
5641
|
chipElement.style.display = "inline-flex";
|
|
5574
5642
|
chipElement.style.alignItems = "center";
|
|
5575
5643
|
chipElement.style.gap = "5px";
|
|
5644
|
+
chipElement.style.minWidth = "0";
|
|
5645
|
+
chipElement.style.maxWidth = "calc(100% - 8px)";
|
|
5576
5646
|
chipElement.style.verticalAlign = "middle";
|
|
5577
5647
|
chipElement.tabIndex = 0;
|
|
5578
5648
|
chipElement.setAttribute("role", "button");
|
|
@@ -5580,6 +5650,11 @@ function createAnnotateSidebarRenderers({
|
|
|
5580
5650
|
chipElement.dataset.state = chip.state;
|
|
5581
5651
|
const label = document.createElement("span");
|
|
5582
5652
|
label.dataset.annotateChipLabel = "true";
|
|
5653
|
+
label.style.flex = "1 1 auto";
|
|
5654
|
+
label.style.minWidth = "0";
|
|
5655
|
+
label.style.overflow = "hidden";
|
|
5656
|
+
label.style.textOverflow = "ellipsis";
|
|
5657
|
+
label.style.whiteSpace = "nowrap";
|
|
5583
5658
|
label.textContent = chip.label;
|
|
5584
5659
|
const actionSlot = document.createElement("span");
|
|
5585
5660
|
actionSlot.style.position = "relative";
|
|
@@ -6073,7 +6148,7 @@ function createOverlay(shadowRoot) {
|
|
|
6073
6148
|
tagSpan.textContent = tagName;
|
|
6074
6149
|
idSpan.textContent = el.id ? `#${el.id}` : "";
|
|
6075
6150
|
const classes = Array.from(el.classList).map((c) => `.${c}`).join("");
|
|
6076
|
-
classSpan.textContent = classes;
|
|
6151
|
+
classSpan.textContent = summarizeClasses(classes);
|
|
6077
6152
|
dimSpan.textContent = `${Math.round(rect.width)} \xD7 ${Math.round(rect.height)}`;
|
|
6078
6153
|
sourceSpan.textContent = sourceLabel;
|
|
6079
6154
|
tooltip.style.visibility = "hidden";
|
|
@@ -6113,13 +6188,18 @@ function createOverlay(shadowRoot) {
|
|
|
6113
6188
|
}
|
|
6114
6189
|
return { show, hide };
|
|
6115
6190
|
}
|
|
6116
|
-
|
|
6191
|
+
function summarizeClasses(classes) {
|
|
6192
|
+
if (classes.length <= MAX_CLASS_SUMMARY_LENGTH) return classes;
|
|
6193
|
+
return `${classes.slice(0, MAX_CLASS_SUMMARY_LENGTH - 3)}...`;
|
|
6194
|
+
}
|
|
6195
|
+
var GAP, EDGE_MARGIN, MAX_CLASS_SUMMARY_LENGTH;
|
|
6117
6196
|
var init_overlay = __esm({
|
|
6118
6197
|
"src/overlay.ts"() {
|
|
6119
6198
|
"use strict";
|
|
6120
6199
|
init_styles();
|
|
6121
6200
|
GAP = 8;
|
|
6122
6201
|
EDGE_MARGIN = 4;
|
|
6202
|
+
MAX_CLASS_SUMMARY_LENGTH = 96;
|
|
6123
6203
|
}
|
|
6124
6204
|
});
|
|
6125
6205
|
|
|
@@ -6147,6 +6227,11 @@ function resetAnnotateState(state) {
|
|
|
6147
6227
|
}
|
|
6148
6228
|
function connect(ctx, createAnnotateOverlay2) {
|
|
6149
6229
|
const state = asLifecycleContext(ctx);
|
|
6230
|
+
const host = state;
|
|
6231
|
+
host.style.position = "fixed";
|
|
6232
|
+
host.style.inset = "0";
|
|
6233
|
+
host.style.pointerEvents = "none";
|
|
6234
|
+
host.style.zIndex = "2147483646";
|
|
6150
6235
|
state.shadowRootEl = state.attachShadow({ mode: "open" });
|
|
6151
6236
|
const style = document.createElement("style");
|
|
6152
6237
|
style.textContent = inspectorStyles;
|
|
@@ -6693,7 +6778,7 @@ var init_component = __esm({
|
|
|
6693
6778
|
});
|
|
6694
6779
|
}
|
|
6695
6780
|
};
|
|
6696
|
-
if (typeof customElements !== "undefined") {
|
|
6781
|
+
if (typeof customElements !== "undefined" && !customElements.get("inspecto-overlay")) {
|
|
6697
6782
|
customElements.define("inspecto-overlay", InspectoElement);
|
|
6698
6783
|
}
|
|
6699
6784
|
}
|