@insitue/sdk 0.3.3 → 0.4.0

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/README.md CHANGED
@@ -116,7 +116,7 @@ interface InSitueCaptureProps {
116
116
 
117
117
  Every pick the widget submits has a usable source location.
118
118
  The picker walks React fiber `_debugSource` first (exact), then
119
- the `data-insitu-source` attribute injected by
119
+ the `data-insitue-source` attribute injected by
120
120
  [`@insitue/sdk/babel`](#babel-plugin) (exact), then the nearest
121
121
  owning component's source (approximate). If even that fails,
122
122
  the widget refuses to send and asks the user to pick a parent
@@ -130,18 +130,18 @@ Send.
130
130
 
131
131
  Optional — only needed when your bundler doesn't expose React
132
132
  fiber `_debugSource` (Vite, some Webpack setups). Adds a
133
- `data-insitu-source="file:line:col"` attribute to every
133
+ `data-insitue-source="file:line:col"` attribute to every
134
134
  intrinsic JSX element so source resolution stays exact.
135
135
 
136
136
  ```js
137
137
  // vite.config.ts
138
- import insituBabel from "@insitue/sdk/babel";
138
+ import insitueBabel from "@insitue/sdk/babel";
139
139
 
140
140
  export default {
141
141
  plugins: [
142
142
  react({
143
143
  babel: {
144
- plugins: [[insituBabel, { root: __dirname }]],
144
+ plugins: [[insitueBabel, { root: __dirname }]],
145
145
  },
146
146
  }),
147
147
  ],
package/dist/babel.d.ts CHANGED
@@ -3,11 +3,11 @@ interface BabelTypes {
3
3
  jsxIdentifier(name: string): unknown;
4
4
  stringLiteral(value: string): unknown;
5
5
  }
6
- declare function insituSourcePlugin(babel: {
6
+ declare function insitueSourcePlugin(babel: {
7
7
  types: BabelTypes;
8
8
  }): {
9
9
  name: string;
10
10
  visitor: Record<string, unknown>;
11
11
  };
12
12
 
13
- export { insituSourcePlugin as default };
13
+ export { insitueSourcePlugin as default };
package/dist/babel.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // src/babel.ts
2
2
  import { relative, sep } from "path";
3
- function insituSourcePlugin(babel) {
3
+ function insitueSourcePlugin(babel) {
4
4
  const t = babel.types;
5
5
  return {
6
- name: "insitu-source",
6
+ name: "insitue-source",
7
7
  visitor: {
8
8
  JSXOpeningElement(path, state) {
9
9
  const node = path.node;
@@ -11,7 +11,7 @@ function insituSourcePlugin(babel) {
11
11
  const c0 = node.name.name[0];
12
12
  if (c0 < "a" || c0 > "z") return;
13
13
  if (node.attributes.some(
14
- (a) => a.type === "JSXAttribute" && a.name?.name === "data-insitu-source"
14
+ (a) => a.type === "JSXAttribute" && a.name?.name === "data-insitue-source"
15
15
  ))
16
16
  return;
17
17
  const loc = node.loc;
@@ -23,7 +23,7 @@ function insituSourcePlugin(babel) {
23
23
  const value = `${rel}:${loc.start.line}:${loc.start.column + 1}`;
24
24
  node.attributes.push(
25
25
  t.jsxAttribute(
26
- t.jsxIdentifier("data-insitu-source"),
26
+ t.jsxIdentifier("data-insitue-source"),
27
27
  t.stringLiteral(value)
28
28
  )
29
29
  );
@@ -32,5 +32,5 @@ function insituSourcePlugin(babel) {
32
32
  };
33
33
  }
34
34
  export {
35
- insituSourcePlugin as default
35
+ insitueSourcePlugin as default
36
36
  };
@@ -22,7 +22,7 @@ interface CaptureOnlyOptions {
22
22
  /**
23
23
  * Take over delivery yourself. Wins over `projectKey` AND `sink`.
24
24
  * Default (neither set + no companion reachable): console + JSON
25
- * download + `window.__insitu_capture__` (useful for prod
25
+ * download + `window.__insitue_capture__` (useful for prod
26
26
  * validation).
27
27
  */
28
28
  onCapture?: (draft: IssueDraft, bundle: CaptureBundle) => void;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  mountCaptureOnly
3
- } from "./chunk-4NBN3ZZC.js";
3
+ } from "./chunk-S25J3BL6.js";
4
4
  export {
5
5
  mountCaptureOnly
6
6
  };
@@ -399,7 +399,7 @@ function D2(n2, t3) {
399
399
 
400
400
  // ../capture-core/dist/index.js
401
401
  var SKIP_TAGS = /* @__PURE__ */ new Set(["SCRIPT", "STYLE", "NOSCRIPT", "TEMPLATE"]);
402
- var ATTR_DENY = /^(on|data-insitu)/i;
402
+ var ATTR_DENY = /^(on|data-insitue)/i;
403
403
  var SECRETISH = /(token|secret|key|password|authorization|bearer)/i;
404
404
  function serializeNode(el, depth = 3, maxChildren = 12) {
405
405
  const attrs = {};
@@ -535,7 +535,7 @@ function toLoc(workspaceCwdRelative) {
535
535
  function fromAttribute(el) {
536
536
  let cur = el;
537
537
  for (let i3 = 0; cur && i3 < 8; i3++, cur = cur.parentElement) {
538
- const raw = cur.getAttribute("data-insitu-source");
538
+ const raw = cur.getAttribute("data-insitue-source");
539
539
  if (raw) {
540
540
  const m3 = /^(.*):(\d+):(\d+)$/.exec(raw);
541
541
  if (m3) return { file: m3[1], line: Number(m3[2]), column: Number(m3[3]) };
@@ -693,12 +693,12 @@ function runtimeSnapshot() {
693
693
  // src/picker.ts
694
694
  var ACCENT = "#ff6b00";
695
695
  function isOurs(el) {
696
- return !!el?.closest?.("#insitu-root, [data-insitu-layer]");
696
+ return !!el?.closest?.("#insitue-root, [data-insitue-layer]");
697
697
  }
698
698
  function beginPick(mode = "element") {
699
699
  return new Promise((resolve) => {
700
700
  const layer = document.createElement("div");
701
- layer.setAttribute("data-insitu-layer", "");
701
+ layer.setAttribute("data-insitue-layer", "");
702
702
  Object.assign(layer.style, {
703
703
  position: "fixed",
704
704
  inset: "0",
@@ -1596,8 +1596,8 @@ var DEFAULT_SETTINGS = {
1596
1596
  disableLayer2: false
1597
1597
  };
1598
1598
  function storageKey() {
1599
- if (typeof location === "undefined") return "insitu:capture-settings";
1600
- return `insitu:capture-settings:${location.host}`;
1599
+ if (typeof location === "undefined") return "insitue:capture-settings";
1600
+ return `insitue:capture-settings:${location.host}`;
1601
1601
  }
1602
1602
  var cached = null;
1603
1603
  function getCaptureSettings() {
@@ -1669,7 +1669,7 @@ async function renderViewportCrop(cropRect, pixelRatio) {
1669
1669
  cacheBust: true,
1670
1670
  backgroundColor,
1671
1671
  imagePlaceholder: IMAGE_PLACEHOLDER,
1672
- filter: (n2) => !(n2 instanceof Element && n2.closest?.("#insitu-root, [data-insitu-layer]"))
1672
+ filter: (n2) => !(n2 instanceof Element && n2.closest?.("#insitue-root, [data-insitue-layer]"))
1673
1673
  });
1674
1674
  const sx = window.scrollX;
1675
1675
  const sy = window.scrollY;
@@ -1700,7 +1700,7 @@ async function drawAbsoluteImagesOnto(ctx, cropRect, pixelRatio, failedImages) {
1700
1700
  const imgs = Array.from(
1701
1701
  document.querySelectorAll("img")
1702
1702
  ).filter(
1703
- (img) => !img.closest?.("#insitu-root, [data-insitu-layer]")
1703
+ (img) => !img.closest?.("#insitue-root, [data-insitue-layer]")
1704
1704
  );
1705
1705
  const PER_IMAGE_TIMEOUT_MS = 3e3;
1706
1706
  await Promise.allSettled(
@@ -1823,7 +1823,7 @@ function detectUnrenderedImages(cropCtx, cropRect, cropCanvas, pixelRatio, faile
1823
1823
  const imgs = Array.from(
1824
1824
  document.querySelectorAll("img")
1825
1825
  ).filter(
1826
- (img) => !img.closest?.("#insitu-root, [data-insitu-layer]")
1826
+ (img) => !img.closest?.("#insitue-root, [data-insitue-layer]")
1827
1827
  );
1828
1828
  for (const img of imgs) {
1829
1829
  if (failedImages.has(img)) continue;
@@ -1891,7 +1891,7 @@ function assessCaptureQuality(cropRect, failedImages) {
1891
1891
  };
1892
1892
  const all = document.querySelectorAll("img, video, canvas");
1893
1893
  for (const el of all) {
1894
- if (el instanceof Element && el.closest?.("#insitu-root, [data-insitu-layer]")) {
1894
+ if (el instanceof Element && el.closest?.("#insitue-root, [data-insitue-layer]")) {
1895
1895
  continue;
1896
1896
  }
1897
1897
  const r3 = el.getBoundingClientRect();
@@ -2002,11 +2002,11 @@ async function retryDisplayMedia() {
2002
2002
  return s3 != null;
2003
2003
  }
2004
2004
  function hideOverlayLayersBriefly() {
2005
- const id = "insitu-capture-hide";
2005
+ const id = "insitue-capture-hide";
2006
2006
  const style = document.createElement("style");
2007
2007
  style.id = id;
2008
2008
  style.textContent = `
2009
- #insitu-root, [data-insitu-layer] { visibility: hidden !important; }
2009
+ #insitue-root, [data-insitue-layer] { visibility: hidden !important; }
2010
2010
  `;
2011
2011
  document.head.appendChild(style);
2012
2012
  return () => {
@@ -2202,7 +2202,7 @@ async function buildBundle(sel) {
2202
2202
  // got set above (an unexpected fallthrough), surface that fact
2203
2203
  // so the widget never renders a blank where a result should be.
2204
2204
  // The structured diagnostic below tells future-me exactly which
2205
- // branch ran, surfaced as `__insitu_capture__.bundle` in dev.
2205
+ // branch ran, surfaced as `__insitue_capture__.bundle` in dev.
2206
2206
  ...screenshotUnavailable ? { screenshotUnavailable } : !screenshot ? {
2207
2207
  screenshotUnavailable: el ? `screenshot path didn't set a result (el=${el.tagName.toLowerCase()}; rasterisable=${el instanceof HTMLElement || el instanceof SVGElement})` : "no element selected"
2208
2208
  } : {},
@@ -2240,7 +2240,7 @@ var CompanionClient = class {
2240
2240
  this.events.onState("connecting");
2241
2241
  let token;
2242
2242
  try {
2243
- const res = await fetch(`${this.base}/insitu/handshake`);
2243
+ const res = await fetch(`${this.base}/insitue/handshake`);
2244
2244
  if (!res.ok) throw new Error(`handshake ${res.status}`);
2245
2245
  token = (await res.json()).token;
2246
2246
  } catch (e3) {
@@ -2448,7 +2448,7 @@ var DEV = {
2448
2448
  buttonInk: "#0f0f12"
2449
2449
  };
2450
2450
  function defaultDeliver(draft) {
2451
- globalThis.__insitu_capture__ = {
2451
+ globalThis.__insitue_capture__ = {
2452
2452
  title: draft.title,
2453
2453
  body: draft.body,
2454
2454
  bundle: draft.bundle
@@ -2534,7 +2534,7 @@ function CaptureApp(props) {
2534
2534
  }
2535
2535
  };
2536
2536
  const sink = new IssueTrackerSink(async (draft) => {
2537
- globalThis.__insitu_capture__ = {
2537
+ globalThis.__insitue_capture__ = {
2538
2538
  title: draft.title,
2539
2539
  body: draft.body,
2540
2540
  bundle: draft.bundle
@@ -2636,19 +2636,24 @@ function CaptureApp(props) {
2636
2636
  const offline = isDev && companionState !== "connected";
2637
2637
  if (isDev) {
2638
2638
  const dotColor = offline ? "#9a9aa4" : CLOUD.accentSolid;
2639
- const ringColor = offline ? "rgba(154,154,164,.4)" : "rgba(87,81,230,.45)";
2639
+ const innerShadow = offline ? "none" : `0 1px 4px ${CLOUD.accentRing}`;
2640
2640
  return k(
2641
2641
  "button",
2642
2642
  {
2643
2643
  onClick: picking ? void 0 : () => void startPick(),
2644
- style: `all:unset;position:fixed;bottom:20px;right:20px;z-index:2147483000;width:20px;height:20px;border-radius:5px;background:${dotColor};box-shadow:0 4px 14px ${ringColor};cursor:${picking ? "default" : "pointer"};${picking ? "animation:ipulse 1.1s ease-in-out infinite;" : ""}transition:transform .15s ease`,
2644
+ style: `all:unset;position:fixed;bottom:20px;right:20px;z-index:2147483000;display:flex;align-items:center;justify-content:center;width:38px;height:38px;cursor:${picking ? "default" : "pointer"};background:${C3.surface};border:1px solid ${C3.line};border-radius:50%;box-shadow:${C3.shadow}`,
2645
2645
  title: picking ? "Click an element \xB7 Esc to cancel" : offline ? "InSitue companion not running \u2014 start `claude` with /insitue:connect" : "Pick an element to talk to claude about"
2646
2646
  },
2647
- picking ? k(
2648
- "style",
2649
- {},
2650
- "@keyframes ipulse{0%,100%{opacity:.45}50%{opacity:1}}"
2651
- ) : null
2647
+ [
2648
+ k("span", {
2649
+ style: `width:11px;height:11px;border-radius:3px;background:${dotColor};box-shadow:${innerShadow};${picking ? "animation:ipulse 1.1s ease-in-out infinite" : ""}`
2650
+ }),
2651
+ picking ? k(
2652
+ "style",
2653
+ {},
2654
+ "@keyframes ipulse{0%,100%{opacity:.45}50%{opacity:1}}"
2655
+ ) : null
2656
+ ]
2652
2657
  );
2653
2658
  }
2654
2659
  return k(
@@ -2912,8 +2917,8 @@ function CaptureApp(props) {
2912
2917
  k("span", {}, isDev ? "InSitue Dev \xB7 pick + describe \u2192 CLI" : ""),
2913
2918
  k(
2914
2919
  "span",
2915
- { title: `@insitue/sdk@${"0.3.3"}` },
2916
- `InSitue \xB7 v${"0.3.3"}`
2920
+ { title: `@insitue/sdk@${"0.4.0"}` },
2921
+ `InSitue \xB7 v${"0.4.0"}`
2917
2922
  )
2918
2923
  ]
2919
2924
  )
@@ -2926,8 +2931,8 @@ function mountCaptureOnly(opts = {}) {
2926
2931
  }
2927
2932
  const sink = resolveSink(opts);
2928
2933
  const host = document.createElement("div");
2929
- host.id = "insitu-capture-root";
2930
- host.setAttribute("data-insitu", "");
2934
+ host.id = "insitue-capture-root";
2935
+ host.setAttribute("data-insitue", "");
2931
2936
  document.body.appendChild(host);
2932
2937
  const shadow = host.attachShadow({ mode: "open" });
2933
2938
  const mount = document.createElement("div");
package/dist/index.d.ts CHANGED
@@ -16,7 +16,7 @@ interface InSitueCaptureProps {
16
16
  /**
17
17
  * Take over delivery yourself. Wins over `projectKey` AND
18
18
  * `sink`. Default (none set + no companion reachable): console +
19
- * JSON download + `window.__insitu_capture__`.
19
+ * JSON download + `window.__insitue_capture__`.
20
20
  */
21
21
  onCapture?: (draft: IssueDraft, bundle: CaptureBundle) => void;
22
22
  /**
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  mountCaptureOnly
3
- } from "./chunk-4NBN3ZZC.js";
3
+ } from "./chunk-S25J3BL6.js";
4
4
 
5
5
  // src/InSitue.tsx
6
6
  import { useEffect } from "react";
@@ -54,7 +54,7 @@ function InSitue({ port }) {
54
54
  }
55
55
 
56
56
  // src/index.ts
57
- var SDK_VERSION = "0.3.3";
57
+ var SDK_VERSION = "0.4.0";
58
58
  export {
59
59
  InSitue,
60
60
  InSitueCapture,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insitue/sdk",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "description": "InSitue capture SDK — drop one snippet into your deployed app; your users point at a bug, InSitue opens a verified pull request.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -51,7 +51,7 @@
51
51
  "tsup": "^8.3.5",
52
52
  "typescript": "^5.6.3",
53
53
  "vitest": "^3.2.4",
54
- "@insitue/capture-core": "0.2.0"
54
+ "@insitue/capture-core": "0.3.0"
55
55
  },
56
56
  "repository": {
57
57
  "type": "git",