@inspecto-dev/core 0.3.3 → 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);
|
|
@@ -3582,6 +3584,113 @@ var init_fix_bug_prompt = __esm({
|
|
|
3582
3584
|
}
|
|
3583
3585
|
});
|
|
3584
3586
|
|
|
3587
|
+
// src/menu-helpers.ts
|
|
3588
|
+
function formatSourceAnchor(location) {
|
|
3589
|
+
const fileName = location.file.split("/").pop() || location.file;
|
|
3590
|
+
return `${fileName}:${location.line}:${location.column}`;
|
|
3591
|
+
}
|
|
3592
|
+
function formatRuntimeErrorCount2(count) {
|
|
3593
|
+
if (count > 99) return "99+";
|
|
3594
|
+
return String(count);
|
|
3595
|
+
}
|
|
3596
|
+
function createMenuSection() {
|
|
3597
|
+
const section = document.createElement("div");
|
|
3598
|
+
section.className = menuSectionClass;
|
|
3599
|
+
return section;
|
|
3600
|
+
}
|
|
3601
|
+
function createAskInput(placeholder) {
|
|
3602
|
+
const inputWrapper = document.createElement("div");
|
|
3603
|
+
inputWrapper.className = menuInputWrapperClass;
|
|
3604
|
+
const input = document.createElement("input");
|
|
3605
|
+
input.className = menuInputClass;
|
|
3606
|
+
input.type = "text";
|
|
3607
|
+
input.placeholder = placeholder != null ? placeholder : "Add a custom ask or extra instruction...";
|
|
3608
|
+
input.setAttribute("aria-label", "Custom ask");
|
|
3609
|
+
const sendIcon = document.createElement("div");
|
|
3610
|
+
sendIcon.className = menuInputIconClass;
|
|
3611
|
+
sendIcon.innerHTML = `<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>`;
|
|
3612
|
+
sendIcon.style.cursor = "pointer";
|
|
3613
|
+
inputWrapper.appendChild(input);
|
|
3614
|
+
inputWrapper.appendChild(sendIcon);
|
|
3615
|
+
return { input, inputWrapper, sendIcon };
|
|
3616
|
+
}
|
|
3617
|
+
function showError(menu, message, errorCode) {
|
|
3618
|
+
var _a2;
|
|
3619
|
+
(_a2 = menu.querySelector(`.${errorMsgClass}`)) == null ? void 0 : _a2.remove();
|
|
3620
|
+
const errEl = document.createElement("div");
|
|
3621
|
+
errEl.className = errorMsgClass;
|
|
3622
|
+
errEl.textContent = errorCode === "FILE_NOT_FOUND" ? "Source file not found. Is the server running?" : `Error: ${message}`;
|
|
3623
|
+
menu.appendChild(errEl);
|
|
3624
|
+
}
|
|
3625
|
+
function isFixIntent(intent) {
|
|
3626
|
+
return intent.aiIntent === "fix";
|
|
3627
|
+
}
|
|
3628
|
+
function isFixUiIntent(intent) {
|
|
3629
|
+
return intent.id === "fix-ui";
|
|
3630
|
+
}
|
|
3631
|
+
function createRuntimeContextUi(runtimeContext, options) {
|
|
3632
|
+
var _a2;
|
|
3633
|
+
if (!runtimeContext) return null;
|
|
3634
|
+
const summary = formatRuntimeContextSummary(runtimeContext);
|
|
3635
|
+
if (!summary) return null;
|
|
3636
|
+
const container = document.createElement("div");
|
|
3637
|
+
container.style.display = "flex";
|
|
3638
|
+
container.style.flexDirection = "column";
|
|
3639
|
+
container.style.gap = "4px";
|
|
3640
|
+
const summaryEl = document.createElement("div");
|
|
3641
|
+
summaryEl.className = menuContextSummaryClass;
|
|
3642
|
+
summaryEl.textContent = summary;
|
|
3643
|
+
container.appendChild(summaryEl);
|
|
3644
|
+
if (((_a2 = options.runtimeContext) == null ? void 0 : _a2.preview) !== true || runtimeContext.records.length === 0) {
|
|
3645
|
+
return container;
|
|
3646
|
+
}
|
|
3647
|
+
const toggle = document.createElement("button");
|
|
3648
|
+
toggle.type = "button";
|
|
3649
|
+
toggle.className = menuContextToggleClass;
|
|
3650
|
+
toggle.textContent = "Show preview";
|
|
3651
|
+
const preview = document.createElement("div");
|
|
3652
|
+
preview.className = menuContextPreviewClass;
|
|
3653
|
+
preview.hidden = true;
|
|
3654
|
+
preview.textContent = formatRuntimeContextPreview(runtimeContext.records);
|
|
3655
|
+
toggle.addEventListener("click", (event) => {
|
|
3656
|
+
event.preventDefault();
|
|
3657
|
+
event.stopPropagation();
|
|
3658
|
+
preview.hidden = !preview.hidden;
|
|
3659
|
+
toggle.textContent = preview.hidden ? "Show preview" : "Hide preview";
|
|
3660
|
+
});
|
|
3661
|
+
container.append(toggle, preview);
|
|
3662
|
+
return container;
|
|
3663
|
+
}
|
|
3664
|
+
function formatRuntimeContextSummary(runtimeContext) {
|
|
3665
|
+
const parts = [];
|
|
3666
|
+
const { runtimeErrorCount, failedRequestCount } = runtimeContext.summary;
|
|
3667
|
+
if (runtimeErrorCount > 0) {
|
|
3668
|
+
parts.push(
|
|
3669
|
+
`${runtimeErrorCount} ${runtimeErrorCount === 1 ? "runtime error" : "runtime errors"}`
|
|
3670
|
+
);
|
|
3671
|
+
}
|
|
3672
|
+
if (failedRequestCount > 0) {
|
|
3673
|
+
parts.push(
|
|
3674
|
+
`${failedRequestCount} ${failedRequestCount === 1 ? "failed request" : "failed requests"}`
|
|
3675
|
+
);
|
|
3676
|
+
}
|
|
3677
|
+
return parts.join(" \u2022 ");
|
|
3678
|
+
}
|
|
3679
|
+
function formatRuntimeContextPreview(records) {
|
|
3680
|
+
return records.slice(0, 3).map((record) => {
|
|
3681
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
3682
|
+
const details = record.kind === "failed-request" ? `${(_b = (_a2 = record.request) == null ? void 0 : _a2.method) != null ? _b : "GET"} ${(_f = (_e = (_c = record.request) == null ? void 0 : _c.pathname) != null ? _e : (_d = record.request) == null ? void 0 : _d.url) != null ? _f : ""}`.trim() : `${record.occurrenceCount}x`;
|
|
3683
|
+
return `[${record.kind}] ${record.message}
|
|
3684
|
+
${details}`;
|
|
3685
|
+
}).join("\n\n");
|
|
3686
|
+
}
|
|
3687
|
+
var init_menu_helpers = __esm({
|
|
3688
|
+
"src/menu-helpers.ts"() {
|
|
3689
|
+
"use strict";
|
|
3690
|
+
init_styles();
|
|
3691
|
+
}
|
|
3692
|
+
});
|
|
3693
|
+
|
|
3585
3694
|
// src/menu-actions.ts
|
|
3586
3695
|
function createIntentActionButtons(input) {
|
|
3587
3696
|
return input.intents.map((intent) => {
|
|
@@ -3607,7 +3716,9 @@ function createIntentActionButtons(input) {
|
|
|
3607
3716
|
}
|
|
3608
3717
|
const requestRuntimeContext = input.resolveRuntimeContext(intent);
|
|
3609
3718
|
const requestScreenshotContext = yield input.resolveScreenshotContext();
|
|
3610
|
-
const requestCssContextPrompt = input.resolveCssContextPrompt(
|
|
3719
|
+
const requestCssContextPrompt = input.resolveCssContextPrompt(
|
|
3720
|
+
isFixUiIntent(intent) ? intent : void 0
|
|
3721
|
+
);
|
|
3611
3722
|
const prompt = appendCssContextToPrompt(
|
|
3612
3723
|
appendScreenshotContextToPrompt(
|
|
3613
3724
|
buildPromptForIntent(intent, input.location, snippetResult, requestRuntimeContext),
|
|
@@ -3638,6 +3749,7 @@ var init_menu_actions = __esm({
|
|
|
3638
3749
|
init_css_context();
|
|
3639
3750
|
init_fix_bug_prompt();
|
|
3640
3751
|
init_http();
|
|
3752
|
+
init_menu_helpers();
|
|
3641
3753
|
init_styles();
|
|
3642
3754
|
}
|
|
3643
3755
|
});
|
|
@@ -3687,7 +3799,11 @@ function buildCustomInspectPrompt(input) {
|
|
|
3687
3799
|
const prompt = appendCssContextToPrompt(
|
|
3688
3800
|
appendScreenshotContextToPrompt(
|
|
3689
3801
|
appendRuntimeContextToPrompt(
|
|
3690
|
-
buildPrompt(
|
|
3802
|
+
buildPrompt(
|
|
3803
|
+
buildCustomInspectPromptTemplate(input.ask.trim(), input.location, input.targetLabel),
|
|
3804
|
+
input.location,
|
|
3805
|
+
snippetResult
|
|
3806
|
+
),
|
|
3691
3807
|
(_b = (_a2 = input.runtimeContext) == null ? void 0 : _a2.records) != null ? _b : []
|
|
3692
3808
|
),
|
|
3693
3809
|
(_c = input.screenshotContext) != null ? _c : null
|
|
@@ -3700,6 +3816,19 @@ function buildCustomInspectPrompt(input) {
|
|
|
3700
3816
|
};
|
|
3701
3817
|
});
|
|
3702
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
|
+
}
|
|
3703
3832
|
var init_menu_send = __esm({
|
|
3704
3833
|
"src/menu-send.ts"() {
|
|
3705
3834
|
"use strict";
|
|
@@ -3710,110 +3839,6 @@ var init_menu_send = __esm({
|
|
|
3710
3839
|
}
|
|
3711
3840
|
});
|
|
3712
3841
|
|
|
3713
|
-
// src/menu-helpers.ts
|
|
3714
|
-
function formatSourceAnchor(location) {
|
|
3715
|
-
const fileName = location.file.split("/").pop() || location.file;
|
|
3716
|
-
return `${fileName}:${location.line}:${location.column}`;
|
|
3717
|
-
}
|
|
3718
|
-
function formatRuntimeErrorCount2(count) {
|
|
3719
|
-
if (count > 99) return "99+";
|
|
3720
|
-
return String(count);
|
|
3721
|
-
}
|
|
3722
|
-
function createMenuSection() {
|
|
3723
|
-
const section = document.createElement("div");
|
|
3724
|
-
section.className = menuSectionClass;
|
|
3725
|
-
return section;
|
|
3726
|
-
}
|
|
3727
|
-
function createAskInput(placeholder) {
|
|
3728
|
-
const inputWrapper = document.createElement("div");
|
|
3729
|
-
inputWrapper.className = menuInputWrapperClass;
|
|
3730
|
-
const input = document.createElement("input");
|
|
3731
|
-
input.className = menuInputClass;
|
|
3732
|
-
input.type = "text";
|
|
3733
|
-
input.placeholder = placeholder != null ? placeholder : "Add a custom ask or extra instruction...";
|
|
3734
|
-
input.setAttribute("aria-label", "Custom ask");
|
|
3735
|
-
const sendIcon = document.createElement("div");
|
|
3736
|
-
sendIcon.className = menuInputIconClass;
|
|
3737
|
-
sendIcon.innerHTML = `<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>`;
|
|
3738
|
-
sendIcon.style.cursor = "pointer";
|
|
3739
|
-
inputWrapper.appendChild(input);
|
|
3740
|
-
inputWrapper.appendChild(sendIcon);
|
|
3741
|
-
return { input, inputWrapper, sendIcon };
|
|
3742
|
-
}
|
|
3743
|
-
function showError(menu, message, errorCode) {
|
|
3744
|
-
var _a2;
|
|
3745
|
-
(_a2 = menu.querySelector(`.${errorMsgClass}`)) == null ? void 0 : _a2.remove();
|
|
3746
|
-
const errEl = document.createElement("div");
|
|
3747
|
-
errEl.className = errorMsgClass;
|
|
3748
|
-
errEl.textContent = errorCode === "FILE_NOT_FOUND" ? "Source file not found. Is the server running?" : `Error: ${message}`;
|
|
3749
|
-
menu.appendChild(errEl);
|
|
3750
|
-
}
|
|
3751
|
-
function isFixIntent(intent) {
|
|
3752
|
-
return intent.aiIntent === "fix";
|
|
3753
|
-
}
|
|
3754
|
-
function createRuntimeContextUi(runtimeContext, options) {
|
|
3755
|
-
var _a2;
|
|
3756
|
-
if (!runtimeContext) return null;
|
|
3757
|
-
const summary = formatRuntimeContextSummary(runtimeContext);
|
|
3758
|
-
if (!summary) return null;
|
|
3759
|
-
const container = document.createElement("div");
|
|
3760
|
-
container.style.display = "flex";
|
|
3761
|
-
container.style.flexDirection = "column";
|
|
3762
|
-
container.style.gap = "4px";
|
|
3763
|
-
const summaryEl = document.createElement("div");
|
|
3764
|
-
summaryEl.className = menuContextSummaryClass;
|
|
3765
|
-
summaryEl.textContent = summary;
|
|
3766
|
-
container.appendChild(summaryEl);
|
|
3767
|
-
if (((_a2 = options.runtimeContext) == null ? void 0 : _a2.preview) !== true || runtimeContext.records.length === 0) {
|
|
3768
|
-
return container;
|
|
3769
|
-
}
|
|
3770
|
-
const toggle = document.createElement("button");
|
|
3771
|
-
toggle.type = "button";
|
|
3772
|
-
toggle.className = menuContextToggleClass;
|
|
3773
|
-
toggle.textContent = "Show preview";
|
|
3774
|
-
const preview = document.createElement("div");
|
|
3775
|
-
preview.className = menuContextPreviewClass;
|
|
3776
|
-
preview.hidden = true;
|
|
3777
|
-
preview.textContent = formatRuntimeContextPreview(runtimeContext.records);
|
|
3778
|
-
toggle.addEventListener("click", (event) => {
|
|
3779
|
-
event.preventDefault();
|
|
3780
|
-
event.stopPropagation();
|
|
3781
|
-
preview.hidden = !preview.hidden;
|
|
3782
|
-
toggle.textContent = preview.hidden ? "Show preview" : "Hide preview";
|
|
3783
|
-
});
|
|
3784
|
-
container.append(toggle, preview);
|
|
3785
|
-
return container;
|
|
3786
|
-
}
|
|
3787
|
-
function formatRuntimeContextSummary(runtimeContext) {
|
|
3788
|
-
const parts = [];
|
|
3789
|
-
const { runtimeErrorCount, failedRequestCount } = runtimeContext.summary;
|
|
3790
|
-
if (runtimeErrorCount > 0) {
|
|
3791
|
-
parts.push(
|
|
3792
|
-
`${runtimeErrorCount} ${runtimeErrorCount === 1 ? "runtime error" : "runtime errors"}`
|
|
3793
|
-
);
|
|
3794
|
-
}
|
|
3795
|
-
if (failedRequestCount > 0) {
|
|
3796
|
-
parts.push(
|
|
3797
|
-
`${failedRequestCount} ${failedRequestCount === 1 ? "failed request" : "failed requests"}`
|
|
3798
|
-
);
|
|
3799
|
-
}
|
|
3800
|
-
return parts.join(" \u2022 ");
|
|
3801
|
-
}
|
|
3802
|
-
function formatRuntimeContextPreview(records) {
|
|
3803
|
-
return records.slice(0, 3).map((record) => {
|
|
3804
|
-
var _a2, _b, _c, _d, _e, _f;
|
|
3805
|
-
const details = record.kind === "failed-request" ? `${(_b = (_a2 = record.request) == null ? void 0 : _a2.method) != null ? _b : "GET"} ${(_f = (_e = (_c = record.request) == null ? void 0 : _c.pathname) != null ? _e : (_d = record.request) == null ? void 0 : _d.url) != null ? _f : ""}`.trim() : `${record.occurrenceCount}x`;
|
|
3806
|
-
return `[${record.kind}] ${record.message}
|
|
3807
|
-
${details}`;
|
|
3808
|
-
}).join("\n\n");
|
|
3809
|
-
}
|
|
3810
|
-
var init_menu_helpers = __esm({
|
|
3811
|
-
"src/menu-helpers.ts"() {
|
|
3812
|
-
"use strict";
|
|
3813
|
-
init_styles();
|
|
3814
|
-
}
|
|
3815
|
-
});
|
|
3816
|
-
|
|
3817
3842
|
// src/menu-header.ts
|
|
3818
3843
|
function createMenuHeaderDom(input) {
|
|
3819
3844
|
var _a2;
|
|
@@ -3823,7 +3848,14 @@ function createMenuHeaderDom(input) {
|
|
|
3823
3848
|
headerCopy.style.display = "flex";
|
|
3824
3849
|
headerCopy.style.flexDirection = "column";
|
|
3825
3850
|
headerCopy.style.gap = "2px";
|
|
3851
|
+
headerCopy.style.minWidth = "0";
|
|
3852
|
+
headerCopy.style.flex = "1 1 auto";
|
|
3826
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";
|
|
3827
3859
|
title.textContent = ((_a2 = input.targetLabel) == null ? void 0 : _a2.trim()) || input.location.file.split("/").pop() || input.location.file;
|
|
3828
3860
|
const meta = document.createElement("div");
|
|
3829
3861
|
meta.className = menuMetaClass;
|
|
@@ -3927,6 +3959,26 @@ var init_menu_header = __esm({
|
|
|
3927
3959
|
}
|
|
3928
3960
|
});
|
|
3929
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
|
+
|
|
3930
3982
|
// src/menu.ts
|
|
3931
3983
|
function showIntentMenu(shadowRoot, location, clickX, clickY, options, onClose, deps = {}) {
|
|
3932
3984
|
var _a2, _b, _c;
|
|
@@ -3941,6 +3993,10 @@ function showIntentMenu(shadowRoot, location, clickX, clickY, options, onClose,
|
|
|
3941
3993
|
const canAttachCssContext2 = typeof deps.captureCssContextPrompt === "function";
|
|
3942
3994
|
const menu = document.createElement("div");
|
|
3943
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";
|
|
3944
4000
|
const {
|
|
3945
4001
|
header,
|
|
3946
4002
|
headerActions,
|
|
@@ -4027,20 +4083,23 @@ function showIntentMenu(shadowRoot, location, clickX, clickY, options, onClose,
|
|
|
4027
4083
|
menu.appendChild(askAiSection);
|
|
4028
4084
|
const actionsSection = createMenuSection();
|
|
4029
4085
|
menu.appendChild(actionsSection);
|
|
4030
|
-
|
|
4031
|
-
const safeWidth = viewportWidth > 0 ? viewportWidth : MENU_WIDTH;
|
|
4032
|
-
menu.style.left = `${Math.min(clickX, Math.max(safeWidth - MENU_WIDTH, 0))}px`;
|
|
4086
|
+
menu.style.left = `${clickX}px`;
|
|
4033
4087
|
menu.style.visibility = "hidden";
|
|
4034
4088
|
menu.style.display = "block";
|
|
4035
4089
|
shadowRoot.appendChild(menu);
|
|
4036
4090
|
const updatePosition = () => {
|
|
4037
4091
|
const rect = menu.getBoundingClientRect();
|
|
4038
|
-
const
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
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`;
|
|
4044
4103
|
};
|
|
4045
4104
|
updatePosition();
|
|
4046
4105
|
menu.style.visibility = "visible";
|
|
@@ -4143,9 +4202,10 @@ function showIntentMenu(shadowRoot, location, clickX, clickY, options, onClose,
|
|
|
4143
4202
|
return null;
|
|
4144
4203
|
}
|
|
4145
4204
|
});
|
|
4146
|
-
const resolveCssContextPrompt = () => {
|
|
4205
|
+
const resolveCssContextPrompt = (intent) => {
|
|
4147
4206
|
var _a3, _b2;
|
|
4148
|
-
|
|
4207
|
+
const shouldAttachCssContext = cssContextEnabled || Boolean(intent && isFixUiIntent(intent));
|
|
4208
|
+
if (!shouldAttachCssContext) return null;
|
|
4149
4209
|
try {
|
|
4150
4210
|
return (_b2 = (_a3 = deps.captureCssContextPrompt) == null ? void 0 : _a3.call(deps)) != null ? _b2 : null;
|
|
4151
4211
|
} catch (e) {
|
|
@@ -4160,15 +4220,16 @@ function showIntentMenu(shadowRoot, location, clickX, clickY, options, onClose,
|
|
|
4160
4220
|
const requestRuntimeContext = resolveRuntimeContext();
|
|
4161
4221
|
const requestScreenshotContext = yield resolveScreenshotContext();
|
|
4162
4222
|
const requestCssContextPrompt = resolveCssContextPrompt();
|
|
4163
|
-
const built = yield buildCustomInspectPrompt({
|
|
4223
|
+
const built = yield buildCustomInspectPrompt(__spreadProps(__spreadValues({
|
|
4164
4224
|
location,
|
|
4165
|
-
ask: input.value.trim()
|
|
4225
|
+
ask: input.value.trim()
|
|
4226
|
+
}, deps.targetLabel ? { targetLabel: deps.targetLabel } : {}), {
|
|
4166
4227
|
includeSnippet,
|
|
4167
4228
|
maxSnippetLines,
|
|
4168
4229
|
runtimeContext: requestRuntimeContext,
|
|
4169
4230
|
screenshotContext: requestScreenshotContext,
|
|
4170
4231
|
cssContextPrompt: requestCssContextPrompt
|
|
4171
|
-
});
|
|
4232
|
+
}));
|
|
4172
4233
|
yield openAndSendInspectPrompt({
|
|
4173
4234
|
location,
|
|
4174
4235
|
promptText: built.prompt,
|
|
@@ -4261,7 +4322,6 @@ function showIntentMenu(shadowRoot, location, clickX, clickY, options, onClose,
|
|
|
4261
4322
|
});
|
|
4262
4323
|
return cleanup;
|
|
4263
4324
|
}
|
|
4264
|
-
var MENU_WIDTH;
|
|
4265
4325
|
var init_menu = __esm({
|
|
4266
4326
|
"src/menu.ts"() {
|
|
4267
4327
|
"use strict";
|
|
@@ -4269,9 +4329,9 @@ var init_menu = __esm({
|
|
|
4269
4329
|
init_menu_send();
|
|
4270
4330
|
init_http();
|
|
4271
4331
|
init_menu_header();
|
|
4332
|
+
init_menu_position();
|
|
4272
4333
|
init_menu_helpers();
|
|
4273
4334
|
init_styles();
|
|
4274
|
-
MENU_WIDTH = 280;
|
|
4275
4335
|
}
|
|
4276
4336
|
});
|
|
4277
4337
|
|
|
@@ -4906,6 +4966,10 @@ function handleMouseMove(ctx, event) {
|
|
|
4906
4966
|
state.lastPointerX = event.clientX;
|
|
4907
4967
|
state.lastPointerY = event.clientY;
|
|
4908
4968
|
state.updateLauncherEye();
|
|
4969
|
+
if (state.cleanupMenu !== null) {
|
|
4970
|
+
state.overlay.hide();
|
|
4971
|
+
return;
|
|
4972
|
+
}
|
|
4909
4973
|
const isActive = state.isInspectorActive(event);
|
|
4910
4974
|
if (!isActive) {
|
|
4911
4975
|
state.overlay.hide();
|
|
@@ -4927,8 +4991,8 @@ function handleMouseMove(ctx, event) {
|
|
|
4927
4991
|
event.stopPropagation();
|
|
4928
4992
|
}
|
|
4929
4993
|
function handleTrigger(ctx, event) {
|
|
4930
|
-
var _a2;
|
|
4931
4994
|
const state = asInteractionContext(ctx);
|
|
4995
|
+
if (state.cleanupMenu !== null) return;
|
|
4932
4996
|
if (!state.isInspectorActive(event)) return;
|
|
4933
4997
|
const target = findInspectable(event.target);
|
|
4934
4998
|
if (!target) return;
|
|
@@ -4947,11 +5011,12 @@ function handleTrigger(ctx, event) {
|
|
|
4947
5011
|
return;
|
|
4948
5012
|
}
|
|
4949
5013
|
if (state.shouldQuickJumpOnTrigger(event)) {
|
|
4950
|
-
|
|
5014
|
+
state.overlay.hide();
|
|
4951
5015
|
state.cleanupMenu = null;
|
|
4952
5016
|
void openFile(loc);
|
|
4953
5017
|
return;
|
|
4954
5018
|
}
|
|
5019
|
+
state.overlay.hide();
|
|
4955
5020
|
state.openInspectMenu(loc, event.clientX, event.clientY, target);
|
|
4956
5021
|
}
|
|
4957
5022
|
function handleKeyDown(ctx, event) {
|
|
@@ -4979,6 +5044,7 @@ function openInspectMenu(ctx, loc, clientX, clientY, targetElement) {
|
|
|
4979
5044
|
var _a2, _b;
|
|
4980
5045
|
const state = asInteractionContext(ctx);
|
|
4981
5046
|
(_a2 = state.cleanupMenu) == null ? void 0 : _a2.call(state);
|
|
5047
|
+
state.style.pointerEvents = "auto";
|
|
4982
5048
|
state.cleanupMenu = showIntentMenu(
|
|
4983
5049
|
state.shadowRootEl,
|
|
4984
5050
|
loc,
|
|
@@ -4986,6 +5052,7 @@ function openInspectMenu(ctx, loc, clientX, clientY, targetElement) {
|
|
|
4986
5052
|
clientY,
|
|
4987
5053
|
state.options,
|
|
4988
5054
|
() => {
|
|
5055
|
+
state.style.pointerEvents = "none";
|
|
4989
5056
|
state.cleanupMenu = null;
|
|
4990
5057
|
},
|
|
4991
5058
|
{
|
|
@@ -5509,11 +5576,14 @@ function createAnnotateSidebarRenderers({
|
|
|
5509
5576
|
titleEl.style.letterSpacing = "0.04em";
|
|
5510
5577
|
titleEl.textContent = title;
|
|
5511
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";
|
|
5512
5583
|
if (typeof content === "string") {
|
|
5513
5584
|
contentEl.style.fontSize = "13px";
|
|
5514
5585
|
contentEl.style.color = "rgba(255, 255, 255, 0.9)";
|
|
5515
5586
|
contentEl.style.lineHeight = "1.4";
|
|
5516
|
-
contentEl.style.wordBreak = "break-word";
|
|
5517
5587
|
if (title === "NOTE" && !chip.note.trim()) {
|
|
5518
5588
|
contentEl.style.fontStyle = "italic";
|
|
5519
5589
|
contentEl.style.color = "rgba(255, 255, 255, 0.4)";
|
|
@@ -5526,9 +5596,13 @@ function createAnnotateSidebarRenderers({
|
|
|
5526
5596
|
return section;
|
|
5527
5597
|
};
|
|
5528
5598
|
const elementValue = document.createElement("div");
|
|
5599
|
+
elementValue.style.minWidth = "0";
|
|
5529
5600
|
elementValue.style.fontFamily = "monospace";
|
|
5530
5601
|
elementValue.style.fontSize = "13px";
|
|
5531
5602
|
elementValue.style.color = "#9cdcfe";
|
|
5603
|
+
elementValue.style.whiteSpace = "normal";
|
|
5604
|
+
elementValue.style.overflowWrap = "anywhere";
|
|
5605
|
+
elementValue.style.wordBreak = "break-word";
|
|
5532
5606
|
elementValue.textContent = chip.label;
|
|
5533
5607
|
activeTooltip.appendChild(createSection("ELEMENT", elementValue));
|
|
5534
5608
|
activeTooltip.appendChild(createSection("NOTE", chip.note.trim() || "No note provided"));
|
|
@@ -5563,9 +5637,12 @@ function createAnnotateSidebarRenderers({
|
|
|
5563
5637
|
chipElement.className = annotateSidebarChipClass;
|
|
5564
5638
|
chipElement.contentEditable = "false";
|
|
5565
5639
|
chipElement.style.margin = "0 4px";
|
|
5640
|
+
chipElement.style.boxSizing = "border-box";
|
|
5566
5641
|
chipElement.style.display = "inline-flex";
|
|
5567
5642
|
chipElement.style.alignItems = "center";
|
|
5568
5643
|
chipElement.style.gap = "5px";
|
|
5644
|
+
chipElement.style.minWidth = "0";
|
|
5645
|
+
chipElement.style.maxWidth = "calc(100% - 8px)";
|
|
5569
5646
|
chipElement.style.verticalAlign = "middle";
|
|
5570
5647
|
chipElement.tabIndex = 0;
|
|
5571
5648
|
chipElement.setAttribute("role", "button");
|
|
@@ -5573,6 +5650,11 @@ function createAnnotateSidebarRenderers({
|
|
|
5573
5650
|
chipElement.dataset.state = chip.state;
|
|
5574
5651
|
const label = document.createElement("span");
|
|
5575
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";
|
|
5576
5658
|
label.textContent = chip.label;
|
|
5577
5659
|
const actionSlot = document.createElement("span");
|
|
5578
5660
|
actionSlot.style.position = "relative";
|
|
@@ -6066,7 +6148,7 @@ function createOverlay(shadowRoot) {
|
|
|
6066
6148
|
tagSpan.textContent = tagName;
|
|
6067
6149
|
idSpan.textContent = el.id ? `#${el.id}` : "";
|
|
6068
6150
|
const classes = Array.from(el.classList).map((c) => `.${c}`).join("");
|
|
6069
|
-
classSpan.textContent = classes;
|
|
6151
|
+
classSpan.textContent = summarizeClasses(classes);
|
|
6070
6152
|
dimSpan.textContent = `${Math.round(rect.width)} \xD7 ${Math.round(rect.height)}`;
|
|
6071
6153
|
sourceSpan.textContent = sourceLabel;
|
|
6072
6154
|
tooltip.style.visibility = "hidden";
|
|
@@ -6106,13 +6188,18 @@ function createOverlay(shadowRoot) {
|
|
|
6106
6188
|
}
|
|
6107
6189
|
return { show, hide };
|
|
6108
6190
|
}
|
|
6109
|
-
|
|
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;
|
|
6110
6196
|
var init_overlay = __esm({
|
|
6111
6197
|
"src/overlay.ts"() {
|
|
6112
6198
|
"use strict";
|
|
6113
6199
|
init_styles();
|
|
6114
6200
|
GAP = 8;
|
|
6115
6201
|
EDGE_MARGIN = 4;
|
|
6202
|
+
MAX_CLASS_SUMMARY_LENGTH = 96;
|
|
6116
6203
|
}
|
|
6117
6204
|
});
|
|
6118
6205
|
|
|
@@ -6140,6 +6227,11 @@ function resetAnnotateState(state) {
|
|
|
6140
6227
|
}
|
|
6141
6228
|
function connect(ctx, createAnnotateOverlay2) {
|
|
6142
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";
|
|
6143
6235
|
state.shadowRootEl = state.attachShadow({ mode: "open" });
|
|
6144
6236
|
const style = document.createElement("style");
|
|
6145
6237
|
style.textContent = inspectorStyles;
|
|
@@ -6686,7 +6778,7 @@ var init_component = __esm({
|
|
|
6686
6778
|
});
|
|
6687
6779
|
}
|
|
6688
6780
|
};
|
|
6689
|
-
if (typeof customElements !== "undefined") {
|
|
6781
|
+
if (typeof customElements !== "undefined" && !customElements.get("inspecto-overlay")) {
|
|
6690
6782
|
customElements.define("inspecto-overlay", InspectoElement);
|
|
6691
6783
|
}
|
|
6692
6784
|
}
|