@insitue/sdk 0.3.2 → 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 +4 -4
- package/dist/babel.d.ts +2 -2
- package/dist/babel.js +5 -5
- package/dist/capture-only.d.ts +1 -1
- package/dist/capture-only.js +1 -1
- package/dist/{chunk-YU5T67XL.js → chunk-S25J3BL6.js} +44 -32
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/package.json +2 -2
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-
|
|
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-
|
|
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
|
|
138
|
+
import insitueBabel from "@insitue/sdk/babel";
|
|
139
139
|
|
|
140
140
|
export default {
|
|
141
141
|
plugins: [
|
|
142
142
|
react({
|
|
143
143
|
babel: {
|
|
144
|
-
plugins: [[
|
|
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
|
|
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 {
|
|
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
|
|
3
|
+
function insitueSourcePlugin(babel) {
|
|
4
4
|
const t = babel.types;
|
|
5
5
|
return {
|
|
6
|
-
name: "
|
|
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-
|
|
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-
|
|
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
|
-
|
|
35
|
+
insitueSourcePlugin as default
|
|
36
36
|
};
|
package/dist/capture-only.d.ts
CHANGED
|
@@ -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.
|
|
25
|
+
* download + `window.__insitue_capture__` (useful for prod
|
|
26
26
|
* validation).
|
|
27
27
|
*/
|
|
28
28
|
onCapture?: (draft: IssueDraft, bundle: CaptureBundle) => void;
|
package/dist/capture-only.js
CHANGED
|
@@ -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-
|
|
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-
|
|
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?.("#
|
|
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-
|
|
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 "
|
|
1600
|
-
return `
|
|
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?.("#
|
|
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?.("#
|
|
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?.("#
|
|
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?.("#
|
|
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 = "
|
|
2005
|
+
const id = "insitue-capture-hide";
|
|
2006
2006
|
const style = document.createElement("style");
|
|
2007
2007
|
style.id = id;
|
|
2008
2008
|
style.textContent = `
|
|
2009
|
-
#
|
|
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 `
|
|
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}/
|
|
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.
|
|
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.
|
|
2537
|
+
globalThis.__insitue_capture__ = {
|
|
2538
2538
|
title: draft.title,
|
|
2539
2539
|
body: draft.body,
|
|
2540
2540
|
bundle: draft.bundle
|
|
@@ -2634,34 +2634,46 @@ function CaptureApp(props) {
|
|
|
2634
2634
|
if (phase === "idle" || phase === "picking") {
|
|
2635
2635
|
const picking = phase === "picking";
|
|
2636
2636
|
const offline = isDev && companionState !== "connected";
|
|
2637
|
+
if (isDev) {
|
|
2638
|
+
const dotColor = offline ? "#9a9aa4" : CLOUD.accentSolid;
|
|
2639
|
+
const innerShadow = offline ? "none" : `0 1px 4px ${CLOUD.accentRing}`;
|
|
2640
|
+
return k(
|
|
2641
|
+
"button",
|
|
2642
|
+
{
|
|
2643
|
+
onClick: picking ? void 0 : () => void startPick(),
|
|
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
|
+
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
|
+
},
|
|
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
|
+
]
|
|
2657
|
+
);
|
|
2658
|
+
}
|
|
2637
2659
|
return k(
|
|
2638
2660
|
"button",
|
|
2639
2661
|
{
|
|
2640
2662
|
onClick: picking ? void 0 : () => void startPick(),
|
|
2641
2663
|
style: `all:unset;position:fixed;bottom:20px;right:20px;z-index:2147483000;display:flex;align-items:center;gap:9px;cursor:${picking ? "default" : "pointer"};padding:11px 16px;font:600 13.5px/1 ${C3.sans};color:${C3.ink};background:${C3.surface};border:1px solid ${C3.line};border-radius:999px;box-shadow:${C3.shadow};letter-spacing:-.01em`,
|
|
2642
|
-
title:
|
|
2664
|
+
title: "Report a problem"
|
|
2643
2665
|
},
|
|
2644
2666
|
picking ? [
|
|
2645
2667
|
k("span", {
|
|
2646
2668
|
style: `width:9px;height:9px;border-radius:50%;background:${C3.accentSolid};animation:ipulse 1.1s ease-in-out infinite`
|
|
2647
2669
|
}),
|
|
2648
|
-
k("span", { style: `color:${C3.sub}` },
|
|
2670
|
+
k("span", { style: `color:${C3.sub}` }, "Click the broken element"),
|
|
2649
2671
|
k("span", { style: `color:${C3.faint}` }, "\xB7 Esc to cancel"),
|
|
2650
2672
|
k(
|
|
2651
2673
|
"style",
|
|
2652
2674
|
{},
|
|
2653
2675
|
"@keyframes ipulse{0%,100%{opacity:.35}50%{opacity:1}}"
|
|
2654
2676
|
)
|
|
2655
|
-
] : isDev ? [
|
|
2656
|
-
k("span", {
|
|
2657
|
-
style: `width:9px;height:9px;border-radius:50%;background:${offline ? "#9a9aa4" : "#5fd190"};box-shadow:${offline ? "none" : "0 0 6px #5fd190"}`
|
|
2658
|
-
}),
|
|
2659
|
-
k("span", {}, "InSitue Dev"),
|
|
2660
|
-
k(
|
|
2661
|
-
"span",
|
|
2662
|
-
{ style: `color:${C3.faint};font-family:${C3.mono};font-size:11px` },
|
|
2663
|
-
offline ? "offline" : "\u2192 claude"
|
|
2664
|
-
)
|
|
2665
2677
|
] : [dot, "Report a problem"]
|
|
2666
2678
|
);
|
|
2667
2679
|
}
|
|
@@ -2905,8 +2917,8 @@ function CaptureApp(props) {
|
|
|
2905
2917
|
k("span", {}, isDev ? "InSitue Dev \xB7 pick + describe \u2192 CLI" : ""),
|
|
2906
2918
|
k(
|
|
2907
2919
|
"span",
|
|
2908
|
-
{ title: `@insitue/sdk@${"0.
|
|
2909
|
-
`InSitue \xB7 v${"0.
|
|
2920
|
+
{ title: `@insitue/sdk@${"0.4.0"}` },
|
|
2921
|
+
`InSitue \xB7 v${"0.4.0"}`
|
|
2910
2922
|
)
|
|
2911
2923
|
]
|
|
2912
2924
|
)
|
|
@@ -2919,8 +2931,8 @@ function mountCaptureOnly(opts = {}) {
|
|
|
2919
2931
|
}
|
|
2920
2932
|
const sink = resolveSink(opts);
|
|
2921
2933
|
const host = document.createElement("div");
|
|
2922
|
-
host.id = "
|
|
2923
|
-
host.setAttribute("data-
|
|
2934
|
+
host.id = "insitue-capture-root";
|
|
2935
|
+
host.setAttribute("data-insitue", "");
|
|
2924
2936
|
document.body.appendChild(host);
|
|
2925
2937
|
const shadow = host.attachShadow({ mode: "open" });
|
|
2926
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.
|
|
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-
|
|
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.
|
|
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
|
+
"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.
|
|
54
|
+
"@insitue/capture-core": "0.3.0"
|
|
55
55
|
},
|
|
56
56
|
"repository": {
|
|
57
57
|
"type": "git",
|