@insitue/sdk 0.1.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/dist/babel.d.ts +13 -0
- package/dist/babel.js +36 -0
- package/dist/capture-only.d.ts +26 -0
- package/dist/capture-only.js +7 -0
- package/dist/chunk-6SMY7D6U.js +1715 -0
- package/dist/chunk-BYR4ZXVS.js +300 -0
- package/dist/chunk-LGN4LKXD.js +973 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +52 -0
- package/dist/overlay.d.ts +6 -0
- package/dist/overlay.js +7 -0
- package/package.json +86 -0
package/dist/babel.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface BabelTypes {
|
|
2
|
+
jsxAttribute(name: unknown, value: unknown): unknown;
|
|
3
|
+
jsxIdentifier(name: string): unknown;
|
|
4
|
+
stringLiteral(value: string): unknown;
|
|
5
|
+
}
|
|
6
|
+
declare function insituSourcePlugin(babel: {
|
|
7
|
+
types: BabelTypes;
|
|
8
|
+
}): {
|
|
9
|
+
name: string;
|
|
10
|
+
visitor: Record<string, unknown>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { insituSourcePlugin as default };
|
package/dist/babel.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/babel.ts
|
|
2
|
+
import { relative, sep } from "path";
|
|
3
|
+
function insituSourcePlugin(babel) {
|
|
4
|
+
const t = babel.types;
|
|
5
|
+
return {
|
|
6
|
+
name: "insitu-source",
|
|
7
|
+
visitor: {
|
|
8
|
+
JSXOpeningElement(path, state) {
|
|
9
|
+
const node = path.node;
|
|
10
|
+
if (node.name.type !== "JSXIdentifier" || !node.name.name) return;
|
|
11
|
+
const c0 = node.name.name[0];
|
|
12
|
+
if (c0 < "a" || c0 > "z") return;
|
|
13
|
+
if (node.attributes.some(
|
|
14
|
+
(a) => a.type === "JSXAttribute" && a.name?.name === "data-insitu-source"
|
|
15
|
+
))
|
|
16
|
+
return;
|
|
17
|
+
const loc = node.loc;
|
|
18
|
+
if (!loc) return;
|
|
19
|
+
const filename = state.file?.opts?.filename ?? state.filename;
|
|
20
|
+
if (!filename) return;
|
|
21
|
+
const root = state.opts?.root ?? process.cwd();
|
|
22
|
+
const rel = relative(root, filename).split(sep).join("/");
|
|
23
|
+
const value = `${rel}:${loc.start.line}:${loc.start.column + 1}`;
|
|
24
|
+
node.attributes.push(
|
|
25
|
+
t.jsxAttribute(
|
|
26
|
+
t.jsxIdentifier("data-insitu-source"),
|
|
27
|
+
t.stringLiteral(value)
|
|
28
|
+
)
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
insituSourcePlugin as default
|
|
36
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IssueDraft, CaptureBundle } from '@insitue/capture-core';
|
|
2
|
+
|
|
3
|
+
interface CaptureOnlyOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Publishable project key (e.g. `pk_…`). When set, captures POST
|
|
6
|
+
* to the InSitue cloud automatically — no `onCapture` plumbing
|
|
7
|
+
* required. The key is publishable (Origin-pinned + quota-gated
|
|
8
|
+
* server-side) so it's safe to ship in your production bundle.
|
|
9
|
+
*/
|
|
10
|
+
projectKey?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Ingest endpoint. Defaults to the InSitue cloud. Override only if
|
|
13
|
+
* you self-host the ingest service or proxy it from your own
|
|
14
|
+
* origin.
|
|
15
|
+
*/
|
|
16
|
+
endpoint?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Take over delivery yourself. Wins over `projectKey` if both are
|
|
19
|
+
* set. Default (neither set): console + JSON download +
|
|
20
|
+
* `window.__insitu_capture__` (useful for prod validation).
|
|
21
|
+
*/
|
|
22
|
+
onCapture?: (draft: IssueDraft, bundle: CaptureBundle) => void;
|
|
23
|
+
}
|
|
24
|
+
declare function mountCaptureOnly(opts?: CaptureOnlyOptions): () => void;
|
|
25
|
+
|
|
26
|
+
export { type CaptureOnlyOptions, mountCaptureOnly };
|