@insitue/sdk 0.3.3 → 0.4.1
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-4NBN3ZZC.js → chunk-CZVN4TEZ.js} +36 -28
- 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
|
|
@@ -2635,20 +2635,28 @@ function CaptureApp(props) {
|
|
|
2635
2635
|
const picking = phase === "picking";
|
|
2636
2636
|
const offline = isDev && companionState !== "connected";
|
|
2637
2637
|
if (isDev) {
|
|
2638
|
-
const
|
|
2639
|
-
const
|
|
2638
|
+
const containerBg = offline ? C3.surface : CLOUD.accentSolid;
|
|
2639
|
+
const containerBorder = offline ? `1px solid ${C3.line}` : "1px solid transparent";
|
|
2640
|
+
const containerShadow = offline ? C3.shadow : `0 0 0 4px rgba(91,91,240,.16),0 12px 30px rgba(60,55,200,.42)`;
|
|
2641
|
+
const innerBg = offline ? "#9a9aa4" : "#ffffff";
|
|
2642
|
+
const innerShadow = offline ? "none" : "0 1px 3px rgba(0,0,0,.20)";
|
|
2640
2643
|
return k(
|
|
2641
2644
|
"button",
|
|
2642
2645
|
{
|
|
2643
2646
|
onClick: picking ? void 0 : () => void startPick(),
|
|
2644
|
-
style: `all:unset;position:fixed;bottom:20px;right:20px;z-index:2147483000;
|
|
2647
|
+
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:${containerBg};border:${containerBorder};border-radius:50%;box-shadow:${containerShadow};transition:background .18s ease,box-shadow .18s ease`,
|
|
2645
2648
|
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
2649
|
},
|
|
2647
|
-
|
|
2648
|
-
"
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2650
|
+
[
|
|
2651
|
+
k("span", {
|
|
2652
|
+
style: `width:11px;height:11px;border-radius:3px;background:${innerBg};box-shadow:${innerShadow};${picking ? "animation:ipulse 1.1s ease-in-out infinite" : ""}`
|
|
2653
|
+
}),
|
|
2654
|
+
picking ? k(
|
|
2655
|
+
"style",
|
|
2656
|
+
{},
|
|
2657
|
+
"@keyframes ipulse{0%,100%{opacity:.45}50%{opacity:1}}"
|
|
2658
|
+
) : null
|
|
2659
|
+
]
|
|
2652
2660
|
);
|
|
2653
2661
|
}
|
|
2654
2662
|
return k(
|
|
@@ -2912,8 +2920,8 @@ function CaptureApp(props) {
|
|
|
2912
2920
|
k("span", {}, isDev ? "InSitue Dev \xB7 pick + describe \u2192 CLI" : ""),
|
|
2913
2921
|
k(
|
|
2914
2922
|
"span",
|
|
2915
|
-
{ title: `@insitue/sdk@${"0.
|
|
2916
|
-
`InSitue \xB7 v${"0.
|
|
2923
|
+
{ title: `@insitue/sdk@${"0.4.1"}` },
|
|
2924
|
+
`InSitue \xB7 v${"0.4.1"}`
|
|
2917
2925
|
)
|
|
2918
2926
|
]
|
|
2919
2927
|
)
|
|
@@ -2926,8 +2934,8 @@ function mountCaptureOnly(opts = {}) {
|
|
|
2926
2934
|
}
|
|
2927
2935
|
const sink = resolveSink(opts);
|
|
2928
2936
|
const host = document.createElement("div");
|
|
2929
|
-
host.id = "
|
|
2930
|
-
host.setAttribute("data-
|
|
2937
|
+
host.id = "insitue-capture-root";
|
|
2938
|
+
host.setAttribute("data-insitue", "");
|
|
2931
2939
|
document.body.appendChild(host);
|
|
2932
2940
|
const shadow = host.attachShadow({ mode: "open" });
|
|
2933
2941
|
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-CZVN4TEZ.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.1";
|
|
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.1",
|
|
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",
|