@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.
@@ -966,7 +966,9 @@ var overlayMenuStyles = `
966
966
  border: 1px solid var(--inspecto-border-subtle);
967
967
  border-radius: var(--inspecto-radius-lg);
968
968
  padding: 10px;
969
- min-width: 304px;
969
+ width: 304px;
970
+ max-width: calc(100vw - 16px);
971
+ box-sizing: border-box;
970
972
  box-shadow: var(--inspecto-shadow-floating);
971
973
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
972
974
  color: var(--inspecto-text-primary);
@@ -3571,7 +3573,11 @@ function buildCustomInspectPrompt(input) {
3571
3573
  const prompt = appendCssContextToPrompt(
3572
3574
  appendScreenshotContextToPrompt(
3573
3575
  appendRuntimeContextToPrompt(
3574
- buildPrompt(CUSTOM_PROMPT_TEMPLATE(input.ask.trim()), input.location, snippetResult),
3576
+ buildPrompt(
3577
+ buildCustomInspectPromptTemplate(input.ask.trim(), input.location, input.targetLabel),
3578
+ input.location,
3579
+ snippetResult
3580
+ ),
3575
3581
  (_b = (_a2 = input.runtimeContext) == null ? void 0 : _a2.records) != null ? _b : []
3576
3582
  ),
3577
3583
  (_c = input.screenshotContext) != null ? _c : null
@@ -3584,6 +3590,19 @@ function buildCustomInspectPrompt(input) {
3584
3590
  };
3585
3591
  });
3586
3592
  }
3593
+ function buildCustomInspectPromptTemplate(ask, location, targetLabel) {
3594
+ const sections = [CUSTOM_PROMPT_TEMPLATE(ask)];
3595
+ if (targetLabel == null ? void 0 : targetLabel.trim()) {
3596
+ sections.push(`Selected component:
3597
+ - ${targetLabel.trim()}`);
3598
+ }
3599
+ sections.push(
3600
+ `Source location:
3601
+ - file: ${location.file}
3602
+ - location: ${location.line}:${location.column}`
3603
+ );
3604
+ return sections.join("\n\n");
3605
+ }
3587
3606
 
3588
3607
  // src/menu-header.ts
3589
3608
  function createMenuHeaderDom(input) {
@@ -3594,7 +3613,14 @@ function createMenuHeaderDom(input) {
3594
3613
  headerCopy.style.display = "flex";
3595
3614
  headerCopy.style.flexDirection = "column";
3596
3615
  headerCopy.style.gap = "2px";
3616
+ headerCopy.style.minWidth = "0";
3617
+ headerCopy.style.flex = "1 1 auto";
3597
3618
  const title = document.createElement("strong");
3619
+ title.style.display = "block";
3620
+ title.style.minWidth = "0";
3621
+ title.style.whiteSpace = "nowrap";
3622
+ title.style.overflow = "hidden";
3623
+ title.style.textOverflow = "ellipsis";
3598
3624
  title.textContent = ((_a2 = input.targetLabel) == null ? void 0 : _a2.trim()) || input.location.file.split("/").pop() || input.location.file;
3599
3625
  const meta = document.createElement("div");
3600
3626
  meta.className = menuMetaClass;
@@ -3690,8 +3716,21 @@ function applyIconToggleButtonState(button, enabled, enabledTitle, disabledTitle
3690
3716
  button.style.boxShadow = "none";
3691
3717
  }
3692
3718
 
3719
+ // src/menu-position.ts
3720
+ var DEFAULT_EDGE_MARGIN = 8;
3721
+ function resolveMenuPosition(input) {
3722
+ var _a2;
3723
+ const edgeMargin = (_a2 = input.edgeMargin) != null ? _a2 : DEFAULT_EDGE_MARGIN;
3724
+ const safeWidth = input.viewport.width > 0 ? input.viewport.width : input.menuRect.width + edgeMargin * 2;
3725
+ const safeHeight = input.viewport.height > 0 ? input.viewport.height : input.menuRect.height + edgeMargin * 2;
3726
+ const maxLeft = Math.max(safeWidth - input.menuRect.width - edgeMargin, edgeMargin);
3727
+ const left = Math.max(edgeMargin, Math.min(input.clickX, maxLeft));
3728
+ const maxTop = Math.max(safeHeight - input.menuRect.height - edgeMargin, edgeMargin);
3729
+ const top = Math.max(edgeMargin, Math.min(input.clickY + edgeMargin, maxTop));
3730
+ return { left, top };
3731
+ }
3732
+
3693
3733
  // src/menu.ts
3694
- var MENU_WIDTH = 280;
3695
3734
  function showIntentMenu(shadowRoot, location, clickX, clickY, options, onClose, deps = {}) {
3696
3735
  var _a2, _b, _c;
3697
3736
  const maxSnippetLines = (_a2 = options.maxSnippetLines) != null ? _a2 : 100;
@@ -3705,6 +3744,10 @@ function showIntentMenu(shadowRoot, location, clickX, clickY, options, onClose,
3705
3744
  const canAttachCssContext2 = typeof deps.captureCssContextPrompt === "function";
3706
3745
  const menu = document.createElement("div");
3707
3746
  menu.className = menuClass;
3747
+ menu.style.width = "304px";
3748
+ menu.style.maxWidth = "calc(100vw - 16px)";
3749
+ menu.style.boxSizing = "border-box";
3750
+ menu.style.pointerEvents = "auto";
3708
3751
  const {
3709
3752
  header,
3710
3753
  headerActions,
@@ -3791,20 +3834,23 @@ function showIntentMenu(shadowRoot, location, clickX, clickY, options, onClose,
3791
3834
  menu.appendChild(askAiSection);
3792
3835
  const actionsSection = createMenuSection();
3793
3836
  menu.appendChild(actionsSection);
3794
- const viewportWidth = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
3795
- const safeWidth = viewportWidth > 0 ? viewportWidth : MENU_WIDTH;
3796
- menu.style.left = `${Math.min(clickX, Math.max(safeWidth - MENU_WIDTH, 0))}px`;
3837
+ menu.style.left = `${clickX}px`;
3797
3838
  menu.style.visibility = "hidden";
3798
3839
  menu.style.display = "block";
3799
3840
  shadowRoot.appendChild(menu);
3800
3841
  const updatePosition = () => {
3801
3842
  const rect = menu.getBoundingClientRect();
3802
- const viewportHeight = Math.max(
3803
- document.documentElement.clientHeight || 0,
3804
- window.innerHeight || 0
3805
- );
3806
- const safeHeight = viewportHeight > 0 ? viewportHeight : rect.height + 16;
3807
- menu.style.top = `${Math.min(clickY + 8, Math.max(safeHeight - rect.height - 8, 0))}px`;
3843
+ const { left: nextLeft, top: nextTop } = resolveMenuPosition({
3844
+ clickX,
3845
+ clickY,
3846
+ menuRect: { width: rect.width, height: rect.height },
3847
+ viewport: {
3848
+ width: document.documentElement.clientWidth || window.innerWidth || 0,
3849
+ height: document.documentElement.clientHeight || window.innerHeight || 0
3850
+ }
3851
+ });
3852
+ menu.style.left = `${nextLeft}px`;
3853
+ menu.style.top = `${nextTop}px`;
3808
3854
  };
3809
3855
  updatePosition();
3810
3856
  menu.style.visibility = "visible";
@@ -3925,15 +3971,16 @@ function showIntentMenu(shadowRoot, location, clickX, clickY, options, onClose,
3925
3971
  const requestRuntimeContext = resolveRuntimeContext();
3926
3972
  const requestScreenshotContext = yield resolveScreenshotContext();
3927
3973
  const requestCssContextPrompt = resolveCssContextPrompt();
3928
- const built = yield buildCustomInspectPrompt({
3974
+ const built = yield buildCustomInspectPrompt(__spreadProps(__spreadValues({
3929
3975
  location,
3930
- ask: input.value.trim(),
3976
+ ask: input.value.trim()
3977
+ }, deps.targetLabel ? { targetLabel: deps.targetLabel } : {}), {
3931
3978
  includeSnippet,
3932
3979
  maxSnippetLines,
3933
3980
  runtimeContext: requestRuntimeContext,
3934
3981
  screenshotContext: requestScreenshotContext,
3935
3982
  cssContextPrompt: requestCssContextPrompt
3936
- });
3983
+ }));
3937
3984
  yield openAndSendInspectPrompt({
3938
3985
  location,
3939
3986
  promptText: built.prompt,
@@ -4624,6 +4671,10 @@ function handleMouseMove(ctx, event) {
4624
4671
  state.lastPointerX = event.clientX;
4625
4672
  state.lastPointerY = event.clientY;
4626
4673
  state.updateLauncherEye();
4674
+ if (state.cleanupMenu !== null) {
4675
+ state.overlay.hide();
4676
+ return;
4677
+ }
4627
4678
  const isActive = state.isInspectorActive(event);
4628
4679
  if (!isActive) {
4629
4680
  state.overlay.hide();
@@ -4645,8 +4696,8 @@ function handleMouseMove(ctx, event) {
4645
4696
  event.stopPropagation();
4646
4697
  }
4647
4698
  function handleTrigger(ctx, event) {
4648
- var _a2;
4649
4699
  const state = asInteractionContext(ctx);
4700
+ if (state.cleanupMenu !== null) return;
4650
4701
  if (!state.isInspectorActive(event)) return;
4651
4702
  const target = findInspectable(event.target);
4652
4703
  if (!target) return;
@@ -4665,11 +4716,12 @@ function handleTrigger(ctx, event) {
4665
4716
  return;
4666
4717
  }
4667
4718
  if (state.shouldQuickJumpOnTrigger(event)) {
4668
- (_a2 = state.cleanupMenu) == null ? void 0 : _a2.call(state);
4719
+ state.overlay.hide();
4669
4720
  state.cleanupMenu = null;
4670
4721
  void openFile(loc);
4671
4722
  return;
4672
4723
  }
4724
+ state.overlay.hide();
4673
4725
  state.openInspectMenu(loc, event.clientX, event.clientY, target);
4674
4726
  }
4675
4727
  function handleKeyDown(ctx, event) {
@@ -4697,6 +4749,7 @@ function openInspectMenu(ctx, loc, clientX, clientY, targetElement) {
4697
4749
  var _a2, _b;
4698
4750
  const state = asInteractionContext(ctx);
4699
4751
  (_a2 = state.cleanupMenu) == null ? void 0 : _a2.call(state);
4752
+ state.style.pointerEvents = "auto";
4700
4753
  state.cleanupMenu = showIntentMenu(
4701
4754
  state.shadowRootEl,
4702
4755
  loc,
@@ -4704,6 +4757,7 @@ function openInspectMenu(ctx, loc, clientX, clientY, targetElement) {
4704
4757
  clientY,
4705
4758
  state.options,
4706
4759
  () => {
4760
+ state.style.pointerEvents = "none";
4707
4761
  state.cleanupMenu = null;
4708
4762
  },
4709
4763
  {
@@ -5204,11 +5258,14 @@ function createAnnotateSidebarRenderers({
5204
5258
  titleEl.style.letterSpacing = "0.04em";
5205
5259
  titleEl.textContent = title;
5206
5260
  const contentEl = document.createElement("div");
5261
+ contentEl.style.minWidth = "0";
5262
+ contentEl.style.whiteSpace = "normal";
5263
+ contentEl.style.overflowWrap = "anywhere";
5264
+ contentEl.style.wordBreak = "break-word";
5207
5265
  if (typeof content === "string") {
5208
5266
  contentEl.style.fontSize = "13px";
5209
5267
  contentEl.style.color = "rgba(255, 255, 255, 0.9)";
5210
5268
  contentEl.style.lineHeight = "1.4";
5211
- contentEl.style.wordBreak = "break-word";
5212
5269
  if (title === "NOTE" && !chip.note.trim()) {
5213
5270
  contentEl.style.fontStyle = "italic";
5214
5271
  contentEl.style.color = "rgba(255, 255, 255, 0.4)";
@@ -5221,9 +5278,13 @@ function createAnnotateSidebarRenderers({
5221
5278
  return section;
5222
5279
  };
5223
5280
  const elementValue = document.createElement("div");
5281
+ elementValue.style.minWidth = "0";
5224
5282
  elementValue.style.fontFamily = "monospace";
5225
5283
  elementValue.style.fontSize = "13px";
5226
5284
  elementValue.style.color = "#9cdcfe";
5285
+ elementValue.style.whiteSpace = "normal";
5286
+ elementValue.style.overflowWrap = "anywhere";
5287
+ elementValue.style.wordBreak = "break-word";
5227
5288
  elementValue.textContent = chip.label;
5228
5289
  activeTooltip.appendChild(createSection("ELEMENT", elementValue));
5229
5290
  activeTooltip.appendChild(createSection("NOTE", chip.note.trim() || "No note provided"));
@@ -5258,9 +5319,12 @@ function createAnnotateSidebarRenderers({
5258
5319
  chipElement.className = annotateSidebarChipClass;
5259
5320
  chipElement.contentEditable = "false";
5260
5321
  chipElement.style.margin = "0 4px";
5322
+ chipElement.style.boxSizing = "border-box";
5261
5323
  chipElement.style.display = "inline-flex";
5262
5324
  chipElement.style.alignItems = "center";
5263
5325
  chipElement.style.gap = "5px";
5326
+ chipElement.style.minWidth = "0";
5327
+ chipElement.style.maxWidth = "calc(100% - 8px)";
5264
5328
  chipElement.style.verticalAlign = "middle";
5265
5329
  chipElement.tabIndex = 0;
5266
5330
  chipElement.setAttribute("role", "button");
@@ -5268,6 +5332,11 @@ function createAnnotateSidebarRenderers({
5268
5332
  chipElement.dataset.state = chip.state;
5269
5333
  const label = document.createElement("span");
5270
5334
  label.dataset.annotateChipLabel = "true";
5335
+ label.style.flex = "1 1 auto";
5336
+ label.style.minWidth = "0";
5337
+ label.style.overflow = "hidden";
5338
+ label.style.textOverflow = "ellipsis";
5339
+ label.style.whiteSpace = "nowrap";
5271
5340
  label.textContent = chip.label;
5272
5341
  const actionSlot = document.createElement("span");
5273
5342
  actionSlot.style.position = "relative";
@@ -5702,6 +5771,7 @@ function teardownListeners(_ctx, handlers) {
5702
5771
  // src/overlay.ts
5703
5772
  var GAP = 8;
5704
5773
  var EDGE_MARGIN = 4;
5774
+ var MAX_CLASS_SUMMARY_LENGTH = 96;
5705
5775
  function createOverlay(shadowRoot) {
5706
5776
  const overlay = document.createElement("div");
5707
5777
  overlay.className = overlayClass;
@@ -5740,7 +5810,7 @@ function createOverlay(shadowRoot) {
5740
5810
  tagSpan.textContent = tagName;
5741
5811
  idSpan.textContent = el.id ? `#${el.id}` : "";
5742
5812
  const classes = Array.from(el.classList).map((c) => `.${c}`).join("");
5743
- classSpan.textContent = classes;
5813
+ classSpan.textContent = summarizeClasses(classes);
5744
5814
  dimSpan.textContent = `${Math.round(rect.width)} \xD7 ${Math.round(rect.height)}`;
5745
5815
  sourceSpan.textContent = sourceLabel;
5746
5816
  tooltip.style.visibility = "hidden";
@@ -5780,6 +5850,10 @@ function createOverlay(shadowRoot) {
5780
5850
  }
5781
5851
  return { show, hide };
5782
5852
  }
5853
+ function summarizeClasses(classes) {
5854
+ if (classes.length <= MAX_CLASS_SUMMARY_LENGTH) return classes;
5855
+ return `${classes.slice(0, MAX_CLASS_SUMMARY_LENGTH - 3)}...`;
5856
+ }
5783
5857
 
5784
5858
  // src/component-lifecycle.ts
5785
5859
  function asLifecycleContext(ctx) {
@@ -5805,6 +5879,11 @@ function resetAnnotateState(state) {
5805
5879
  }
5806
5880
  function connect(ctx, createAnnotateOverlay2) {
5807
5881
  const state = asLifecycleContext(ctx);
5882
+ const host = state;
5883
+ host.style.position = "fixed";
5884
+ host.style.inset = "0";
5885
+ host.style.pointerEvents = "none";
5886
+ host.style.zIndex = "2147483646";
5808
5887
  state.shadowRootEl = state.attachShadow({ mode: "open" });
5809
5888
  const style = document.createElement("style");
5810
5889
  style.textContent = inspectorStyles;
@@ -6316,10 +6395,10 @@ var InspectoElement = class extends BaseElement {
6316
6395
  });
6317
6396
  }
6318
6397
  };
6319
- if (typeof customElements !== "undefined") {
6398
+ if (typeof customElements !== "undefined" && !customElements.get("inspecto-overlay")) {
6320
6399
  customElements.define("inspecto-overlay", InspectoElement);
6321
6400
  }
6322
6401
  export {
6323
6402
  InspectoElement
6324
6403
  };
6325
- //# sourceMappingURL=component-M23S536R.js.map
6404
+ //# sourceMappingURL=component-RQ76TEPZ.js.map