reflet-sdk 0.5.0 → 0.5.2
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/CHANGELOG.md +18 -0
- package/README.md +11 -2
- package/dist/{devtools-layer-BYGuFmhg.js → devtools-layer-N5ptXXK4.js} +1526 -1394
- package/dist/devtools-layer-N5ptXXK4.js.map +1 -0
- package/dist/devtools-next.d.ts +1 -1
- package/dist/devtools-next.d.ts.map +1 -1
- package/dist/devtools-next.js +1 -1
- package/dist/devtools-vite.d.ts +1 -1
- package/dist/devtools-vite.d.ts.map +1 -1
- package/dist/devtools-vite.js +3 -3
- package/dist/devtools-vite.js.map +1 -1
- package/dist/feedback.d.ts.map +1 -1
- package/dist/feedback.js +44 -136
- package/dist/feedback.js.map +1 -1
- package/dist/{handler-CHP0m7KF.js → handler-CyR6Ht99.js} +321 -44
- package/dist/handler-CyR6Ht99.js.map +1 -0
- package/dist/{options-7KtQZJj8.d.ts → options-CIBazDPp.d.ts} +3 -1
- package/dist/options-CIBazDPp.d.ts.map +1 -0
- package/dist/{picker-DDDpVcfr.js → picker-HLPIR-l6.js} +64 -59
- package/dist/picker-HLPIR-l6.js.map +1 -0
- package/dist/{protocol-Bn6Bg_0r.js → protocol-ClqTFzwR.js} +4 -1
- package/dist/protocol-ClqTFzwR.js.map +1 -0
- package/package.json +3 -2
- package/dist/devtools-layer-BYGuFmhg.js.map +0 -1
- package/dist/handler-CHP0m7KF.js.map +0 -1
- package/dist/options-7KtQZJj8.d.ts.map +0 -1
- package/dist/picker-DDDpVcfr.js.map +0 -1
- package/dist/protocol-Bn6Bg_0r.js.map +0 -1
package/dist/devtools-next.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools-next.d.ts","names":[],"sources":["../src/devtools/server/handler.ts","../src/devtools/server/next.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"devtools-next.d.ts","names":[],"sources":["../src/devtools/server/handler.ts","../src/devtools/server/next.ts"],"mappings":";;KA8BY,mBAAmB,SAAS,YAAY,QAAQ;;;iBCzB3C;EACf,KAAK;EACL,MAAM;;;;;;wBAOQ,oBACd,UAAS,wBACR;qBAcU,KAAG;qBACH,MAAI"}
|
package/dist/devtools-next.js
CHANGED
package/dist/devtools-vite.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as DevtoolsServerOptions } from "./options-
|
|
1
|
+
import { t as DevtoolsServerOptions } from "./options-CIBazDPp.js";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
//#region src/devtools/server/vite.d.ts
|
|
4
4
|
/** Serves the Reflet devtools route from the Vite dev server; never part of a build. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools-vite.d.ts","names":[],"sources":["../src/devtools/server/vite.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"devtools-vite.d.ts","names":[],"sources":["../src/devtools/server/vite.ts"],"mappings":";;;;wBAiFgB,eAAe,UAAS,wBAA6B"}
|
package/dist/devtools-vite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as DEVTOOLS_ROUTE_BASE } from "./protocol-
|
|
2
|
-
import { n as errorResponse, t as createDevtoolsHandler } from "./handler-
|
|
1
|
+
import { r as DEVTOOLS_ROUTE_BASE } from "./protocol-ClqTFzwR.js";
|
|
2
|
+
import { n as errorResponse, t as createDevtoolsHandler } from "./handler-CyR6Ht99.js";
|
|
3
3
|
import { loadEnv } from "vite";
|
|
4
4
|
//#region src/devtools/server/vite.ts
|
|
5
5
|
const MAX_BODY_BYTES = 1048576;
|
|
@@ -15,7 +15,7 @@ async function readBody(request) {
|
|
|
15
15
|
return size > MAX_BODY_BYTES ? null : Buffer.concat(chunks).toString("utf8");
|
|
16
16
|
}
|
|
17
17
|
function toWebRequest(request, method, body) {
|
|
18
|
-
const origin =
|
|
18
|
+
const origin = `${"encrypted" in request.socket && request.socket.encrypted === true ? "https" : "http"}://${request.headers.host ?? "localhost"}`;
|
|
19
19
|
const url = new URL(request.originalUrl ?? request.url ?? "/", origin);
|
|
20
20
|
const headers = new Headers();
|
|
21
21
|
for (const [name, value] of Object.entries(request.headers)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools-vite.js","names":[],"sources":["../src/devtools/server/vite.ts"],"sourcesContent":["import type { ServerResponse } from \"node:http\";\nimport { type Connect, loadEnv, type Plugin } from \"vite\";\nimport { DEVTOOLS_ROUTE_BASE } from \"../protocol\";\nimport { createDevtoolsHandler, type DevtoolsHandler } from \"./handler\";\nimport { errorResponse } from \"./json-response\";\nimport type { DevtoolsServerOptions } from \"./options\";\n\nexport type { DevtoolsServerOptions } from \"./options\";\n\nconst MAX_BODY_BYTES = 1_048_576;\nconst ENV_PREFIX = \"REFLET_\";\n\nasync function readBody(\n request: Connect.IncomingMessage\n): Promise<string | null> {\n const chunks: Buffer[] = [];\n let size = 0;\n for await (const chunk of request) {\n const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));\n size += buffer.length;\n // Keep draining: leaving the loop early destroys the socket before the 413 is sent.\n if (size <= MAX_BODY_BYTES) {\n chunks.push(buffer);\n }\n }\n return size > MAX_BODY_BYTES ? null : Buffer.concat(chunks).toString(\"utf8\");\n}\n\nfunction toWebRequest(\n request: Connect.IncomingMessage,\n method: string,\n body: string | undefined\n): Request {\n const origin =
|
|
1
|
+
{"version":3,"file":"devtools-vite.js","names":[],"sources":["../src/devtools/server/vite.ts"],"sourcesContent":["import type { ServerResponse } from \"node:http\";\nimport { type Connect, loadEnv, type Plugin } from \"vite\";\nimport { DEVTOOLS_ROUTE_BASE } from \"../protocol\";\nimport { createDevtoolsHandler, type DevtoolsHandler } from \"./handler\";\nimport { errorResponse } from \"./json-response\";\nimport type { DevtoolsServerOptions } from \"./options\";\n\nexport type { DevtoolsServerOptions } from \"./options\";\n\nconst MAX_BODY_BYTES = 1_048_576;\nconst ENV_PREFIX = \"REFLET_\";\n\nasync function readBody(\n request: Connect.IncomingMessage\n): Promise<string | null> {\n const chunks: Buffer[] = [];\n let size = 0;\n for await (const chunk of request) {\n const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));\n size += buffer.length;\n // Keep draining: leaving the loop early destroys the socket before the 413 is sent.\n if (size <= MAX_BODY_BYTES) {\n chunks.push(buffer);\n }\n }\n return size > MAX_BODY_BYTES ? null : Buffer.concat(chunks).toString(\"utf8\");\n}\n\nfunction toWebRequest(\n request: Connect.IncomingMessage,\n method: string,\n body: string | undefined\n): Request {\n const isTls =\n \"encrypted\" in request.socket && request.socket.encrypted === true;\n const protocol = isTls ? \"https\" : \"http\";\n const origin = `${protocol}://${request.headers.host ?? \"localhost\"}`;\n const url = new URL(request.originalUrl ?? request.url ?? \"/\", origin);\n const headers = new Headers();\n for (const [name, value] of Object.entries(request.headers)) {\n if (name.startsWith(\":\") || value === undefined) {\n continue;\n }\n for (const item of Array.isArray(value) ? value : [value]) {\n headers.append(name, item);\n }\n }\n return new Request(url, { body, headers, method });\n}\n\nasync function sendWebResponse(\n response: Response,\n serverResponse: ServerResponse\n): Promise<void> {\n serverResponse.statusCode = response.status;\n for (const [name, value] of response.headers) {\n serverResponse.setHeader(name, value);\n }\n serverResponse.end(Buffer.from(await response.arrayBuffer()));\n}\n\nasync function serveDevtoolsRequest(\n handler: DevtoolsHandler,\n request: Connect.IncomingMessage,\n serverResponse: ServerResponse\n): Promise<void> {\n const method = request.method ?? \"GET\";\n const hasBody = method !== \"GET\" && method !== \"HEAD\";\n const body = hasBody ? await readBody(request) : undefined;\n if (body === null) {\n await sendWebResponse(\n errorResponse(\"Reflet devtools requests are limited to 1 MB.\", 413),\n serverResponse\n );\n return;\n }\n const response = await handler(toWebRequest(request, method, body));\n await sendWebResponse(response, serverResponse);\n}\n\n/** Serves the Reflet devtools route from the Vite dev server; never part of a build. */\nexport function refletDevtools(options: DevtoolsServerOptions = {}): Plugin {\n let handler: DevtoolsHandler | null = null;\n\n return {\n apply: \"serve\",\n configResolved(config) {\n const env = loadEnv(config.mode, config.envDir, ENV_PREFIX);\n handler = createDevtoolsHandler(\n { ...options, root: options.root ?? config.root },\n { ...process.env, ...env }\n );\n },\n configureServer(server) {\n server.middlewares.use(DEVTOOLS_ROUTE_BASE, (request, response, next) => {\n if (!handler) {\n next();\n return;\n }\n serveDevtoolsRequest(handler, request, response).catch(next);\n });\n },\n name: \"reflet-devtools\",\n };\n}\n"],"mappings":";;;;AASA,MAAM,iBAAiB;AACvB,MAAM,aAAa;AAEnB,eAAe,SACb,SACwB;CACxB,MAAM,SAAmB,CAAC;CAC1B,IAAI,OAAO;CACX,WAAW,MAAM,SAAS,SAAS;EACjC,MAAM,SAAS,OAAO,SAAS,KAAK,IAAI,QAAQ,OAAO,KAAK,OAAO,KAAK,CAAC;EACzE,QAAQ,OAAO;EAEf,IAAI,QAAQ,gBACV,OAAO,KAAK,MAAM;CAEtB;CACA,OAAO,OAAO,iBAAiB,OAAO,OAAO,OAAO,MAAM,CAAC,CAAC,SAAS,MAAM;AAC7E;AAEA,SAAS,aACP,SACA,QACA,MACS;CAIT,MAAM,SAAS,GAFb,eAAe,QAAQ,UAAU,QAAQ,OAAO,cAAc,OACvC,UAAU,OACR,KAAK,QAAQ,QAAQ,QAAQ;CACxD,MAAM,MAAM,IAAI,IAAI,QAAQ,eAAe,QAAQ,OAAO,KAAK,MAAM;CACrE,MAAM,UAAU,IAAI,QAAQ;CAC5B,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,QAAQ,OAAO,GAAG;EAC3D,IAAI,KAAK,WAAW,GAAG,KAAK,UAAU,KAAA,GACpC;EAEF,KAAK,MAAM,QAAQ,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK,GACtD,QAAQ,OAAO,MAAM,IAAI;CAE7B;CACA,OAAO,IAAI,QAAQ,KAAK;EAAE;EAAM;EAAS;CAAO,CAAC;AACnD;AAEA,eAAe,gBACb,UACA,gBACe;CACf,eAAe,aAAa,SAAS;CACrC,KAAK,MAAM,CAAC,MAAM,UAAU,SAAS,SACnC,eAAe,UAAU,MAAM,KAAK;CAEtC,eAAe,IAAI,OAAO,KAAK,MAAM,SAAS,YAAY,CAAC,CAAC;AAC9D;AAEA,eAAe,qBACb,SACA,SACA,gBACe;CACf,MAAM,SAAS,QAAQ,UAAU;CAEjC,MAAM,OADU,WAAW,SAAS,WAAW,SACxB,MAAM,SAAS,OAAO,IAAI,KAAA;CACjD,IAAI,SAAS,MAAM;EACjB,MAAM,gBACJ,cAAc,iDAAiD,GAAG,GAClE,cACF;EACA;CACF;CAEA,MAAM,gBAAgB,MADC,QAAQ,aAAa,SAAS,QAAQ,IAAI,CAAC,GAClC,cAAc;AAChD;;AAGA,SAAgB,eAAe,UAAiC,CAAC,GAAW;CAC1E,IAAI,UAAkC;CAEtC,OAAO;EACL,OAAO;EACP,eAAe,QAAQ;GACrB,MAAM,MAAM,QAAQ,OAAO,MAAM,OAAO,QAAQ,UAAU;GAC1D,UAAU,sBACR;IAAE,GAAG;IAAS,MAAM,QAAQ,QAAQ,OAAO;GAAK,GAChD;IAAE,GAAG,QAAQ;IAAK,GAAG;GAAI,CAC3B;EACF;EACA,gBAAgB,QAAQ;GACtB,OAAO,YAAY,IAAI,sBAAsB,SAAS,UAAU,SAAS;IACvE,IAAI,CAAC,SAAS;KACZ,KAAK;KACL;IACF;IACA,qBAAqB,SAAS,SAAS,QAAQ,CAAC,CAAC,MAAM,IAAI;GAC7D,CAAC;EACH;EACA,MAAM;CACR;AACF"}
|
package/dist/feedback.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feedback.d.ts","names":[],"sources":["../src/feedback/types.ts","../src/feedback/core/capture.ts","../src/feedback/core/element-selector.ts","../src/feedback/core/page-context.ts","../src/feedback/widget.tsx"],"mappings":";;cAKM;KAUM,yBAAyB;UAEpB;EACf;EACA;;UAGe;EACf;EACA,KAAK;EACL;;EAEA,SAAS;EACT,OAAO;EACP;EACA,MAAM;;UAGS;EACf,MAAM;EACN;EACA;;EAEA;EACA;;
|
|
1
|
+
{"version":3,"file":"feedback.d.ts","names":[],"sources":["../src/feedback/types.ts","../src/feedback/core/capture.ts","../src/feedback/core/element-selector.ts","../src/feedback/core/page-context.ts","../src/feedback/widget.tsx"],"mappings":";;cAKM;KAUM,yBAAyB;UAEpB;EACf;EACA;;UAGe;EACf;EACA,KAAK;EACL;;EAEA,SAAS;EACT,OAAO;EACP;EACA,MAAM;;UAGS;EACf,MAAM;EACN;EACA;;EAEA;EACA;;UAae;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAgDe;;EAEf;;EAEA;;EAEA;;;;;EAKA;;EAEA;;EAEA;;EAEA;EACA,SAAS,QAAQ;;EAEjB,WAAW;;EAEX;EACA;EACA,aAAa;IAAU;;EACvB;EACA,YAAY;IAAU;;EACtB;EACA;EACA;EACA;EACA,OAAO;EACP;;;;UC8De;;EAEf,UAAU;EACV;EACA;;EAEA;;;;;;;;;;wBA2GoB,gBACpB,UAAS,iBACR,QAAQ;wBAiDK,eAAe,OAAO;;;;wBCjHtB,sBAAsB,SAAS,UAAU;;;;wBCjMzC,mBAAmB;EACjC;IACE;;;wBCtEY,eAAe,OAAO,sCAAmB,IAAA"}
|
package/dist/feedback.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { n as Reflet } from "./client-BWEBWk1k.js";
|
|
3
|
-
import { A as
|
|
3
|
+
import { A as TargetIcon, B as buildElementSelection, C as GripIcon, D as SpotlightIcon, E as PencilIcon, F as normalizeRect, G as WIDGET_MARKER, I as DEFAULT_WIDGET_LABELS, J as releaseCapture, K as captureViewport, L as SDK_VERSION, M as TrashIcon, N as UndoIcon, O as SquareIcon, P as isDegenerate, R as collectPageContext, S as CloseIcon, T as MoreIcon, _ as BlurIcon, b as CheckIcon, d as SelectionOutline, f as drawAnnotations, g as ArrowIcon, h as stopClicksAtHost, j as TextIcon, l as submitWidgetFeedback, m as listenToKeydown, o as attachPreparedScreenshots, p as listenOnPageAndWidget, r as useFloatingPosition, s as createFeedbackTransport, t as ElementPicker, v as CameraIcon, w as HighlightIcon, x as ChevronDownIcon, y as ChatIcon, z as MAX_SELECTION_COMMENT_LENGTH } from "./picker-HLPIR-l6.js";
|
|
4
4
|
import { n as RefletContext, t as REFLET_Z_INDEX } from "./z-index-CKxBgZTG.js";
|
|
5
5
|
import { Suspense, lazy, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -163,11 +163,11 @@ function useDetailsPopover() {
|
|
|
163
163
|
setOpen(false);
|
|
164
164
|
summaryRef.current?.focus();
|
|
165
165
|
};
|
|
166
|
-
|
|
166
|
+
const stopOutsidePress = listenOnPageAndWidget(detailsRef.current, "pointerdown", dismissOutside);
|
|
167
167
|
const stopListeningToKeys = listenToKeydown(detailsRef.current, dismissWithEscape, true);
|
|
168
168
|
window.addEventListener("resize", reposition);
|
|
169
169
|
return () => {
|
|
170
|
-
|
|
170
|
+
stopOutsidePress();
|
|
171
171
|
stopListeningToKeys();
|
|
172
172
|
window.removeEventListener("resize", reposition);
|
|
173
173
|
};
|
|
@@ -743,45 +743,8 @@ function CaptureSlot({ labels, state }) {
|
|
|
743
743
|
}
|
|
744
744
|
//#endregion
|
|
745
745
|
//#region src/feedback/core/element-capture.ts
|
|
746
|
-
const MIN_CONTEXT_PADDING = 24;
|
|
747
|
-
const MAX_CONTEXT_WIDTH = 2e3;
|
|
748
|
-
const CLOSE_UP_MAX_WIDTH = 1200;
|
|
749
746
|
const SELECTION_COLOR = "#4f46e5";
|
|
750
747
|
const SELECTION_ANNOTATION_PREFIX = "selection-";
|
|
751
|
-
const OUTLINE_COLOR = "#4f46e5";
|
|
752
|
-
const OUTLINE_GLOW = "#ffffff";
|
|
753
|
-
const OUTLINE_WIDTH = 3;
|
|
754
|
-
const GLOW_WIDTH = 6;
|
|
755
|
-
const DIM_OVERLAY = "rgba(15, 23, 42, 0.45)";
|
|
756
|
-
/**
|
|
757
|
-
* Tightest ancestor that keeps some breathing room around the pick — the zoom
|
|
758
|
-
* stays zoomed instead of growing to a giant section. Only when nothing up
|
|
759
|
-
* the tree clears the minimum does the widest candidate below the cap win.
|
|
760
|
-
*/
|
|
761
|
-
function contextRootFor(element) {
|
|
762
|
-
const target = element.getBoundingClientRect();
|
|
763
|
-
const coversAtLeast = (box, margin) => box.left <= target.left - margin && box.right >= target.right + margin && box.top <= target.top - margin && box.bottom >= target.bottom + margin;
|
|
764
|
-
let tightest = null;
|
|
765
|
-
let current = element.parentElement;
|
|
766
|
-
while (current && current !== document.documentElement) {
|
|
767
|
-
const box = current.getBoundingClientRect();
|
|
768
|
-
if (coversAtLeast(box, MIN_CONTEXT_PADDING)) return current;
|
|
769
|
-
tightest ??= box.width < MAX_CONTEXT_WIDTH ? current : null;
|
|
770
|
-
current = current.parentElement;
|
|
771
|
-
}
|
|
772
|
-
return tightest ?? element;
|
|
773
|
-
}
|
|
774
|
-
/** Where the picked element sits inside the context shot, in image pixels. */
|
|
775
|
-
function closeUpGeometry(params) {
|
|
776
|
-
const scale = params.rootRect.width > 0 ? params.capture.width / params.rootRect.width : 1;
|
|
777
|
-
return {
|
|
778
|
-
height: Math.round(params.elementRect.height * scale),
|
|
779
|
-
scale,
|
|
780
|
-
width: Math.round(params.elementRect.width * scale),
|
|
781
|
-
x: Math.round((params.elementRect.left - params.rootRect.left) * scale),
|
|
782
|
-
y: Math.round((params.elementRect.top - params.rootRect.top) * scale)
|
|
783
|
-
};
|
|
784
|
-
}
|
|
785
748
|
function isSelectionAnnotation({ id }) {
|
|
786
749
|
return id.startsWith(SELECTION_ANNOTATION_PREFIX);
|
|
787
750
|
}
|
|
@@ -802,70 +765,6 @@ function highlightFor(selection, capture) {
|
|
|
802
765
|
tool: "rectangle"
|
|
803
766
|
};
|
|
804
767
|
}
|
|
805
|
-
function drawZoneOverlay(context, zone) {
|
|
806
|
-
context.save();
|
|
807
|
-
context.fillStyle = DIM_OVERLAY;
|
|
808
|
-
context.beginPath();
|
|
809
|
-
context.rect(0, 0, context.canvas.width, context.canvas.height);
|
|
810
|
-
context.rect(zone.x, zone.y, zone.width, zone.height);
|
|
811
|
-
context.fill("evenodd");
|
|
812
|
-
for (const [color, width] of [[OUTLINE_GLOW, GLOW_WIDTH], [OUTLINE_COLOR, OUTLINE_WIDTH]]) {
|
|
813
|
-
context.strokeStyle = color;
|
|
814
|
-
context.lineWidth = width * zone.scale;
|
|
815
|
-
context.strokeRect(zone.x, zone.y, zone.width, zone.height);
|
|
816
|
-
}
|
|
817
|
-
context.restore();
|
|
818
|
-
}
|
|
819
|
-
function drawCloseUp(capture, zone) {
|
|
820
|
-
return new Promise((resolve) => {
|
|
821
|
-
const canvas = document.createElement("canvas");
|
|
822
|
-
canvas.width = capture.width;
|
|
823
|
-
canvas.height = capture.height;
|
|
824
|
-
const context = canvas.getContext("2d");
|
|
825
|
-
const image = new Image();
|
|
826
|
-
image.onload = () => {
|
|
827
|
-
if (!context) {
|
|
828
|
-
resolve(null);
|
|
829
|
-
return;
|
|
830
|
-
}
|
|
831
|
-
context.drawImage(image, 0, 0, capture.width, capture.height);
|
|
832
|
-
drawZoneOverlay(context, zone);
|
|
833
|
-
resolve(capturedFromCanvas(canvas, CLOSE_UP_MAX_WIDTH));
|
|
834
|
-
};
|
|
835
|
-
image.onerror = () => resolve(null);
|
|
836
|
-
image.src = capture.objectUrl;
|
|
837
|
-
});
|
|
838
|
-
}
|
|
839
|
-
/**
|
|
840
|
-
* Zoomed view of the picked zone: the surrounding area captured for context,
|
|
841
|
-
* everything outside the selection dimmed and the zone framed with a glowing
|
|
842
|
-
* outline — unambiguous to eyes and vision models alike.
|
|
843
|
-
* Falls back to the plain context shot when the overlay cannot be drawn.
|
|
844
|
-
*/
|
|
845
|
-
async function captureElementCloseUp(element) {
|
|
846
|
-
try {
|
|
847
|
-
const root = contextRootFor(element);
|
|
848
|
-
const rootRect = root.getBoundingClientRect();
|
|
849
|
-
const elementRect = element.getBoundingClientRect();
|
|
850
|
-
const capture = await captureViewport({
|
|
851
|
-
element: root,
|
|
852
|
-
maxWidth: CLOSE_UP_MAX_WIDTH
|
|
853
|
-
});
|
|
854
|
-
if (!capture || root === element) return capture;
|
|
855
|
-
const outlined = await drawCloseUp(capture, closeUpGeometry({
|
|
856
|
-
capture,
|
|
857
|
-
elementRect,
|
|
858
|
-
rootRect
|
|
859
|
-
}));
|
|
860
|
-
if (outlined) {
|
|
861
|
-
releaseCapture(capture);
|
|
862
|
-
return outlined;
|
|
863
|
-
}
|
|
864
|
-
return capture;
|
|
865
|
-
} catch {
|
|
866
|
-
return null;
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
768
|
//#endregion
|
|
870
769
|
//#region src/feedback/ui/annotation/screenshot-preview.tsx
|
|
871
770
|
function ScreenshotPreview({ annotations, capture }) {
|
|
@@ -1372,7 +1271,6 @@ function useFeedbackSubmission(options) {
|
|
|
1372
1271
|
//#region src/feedback/ui/state/use-screenshot-drafts.ts
|
|
1373
1272
|
function releaseDraft(draft) {
|
|
1374
1273
|
releaseCapture(draft?.image);
|
|
1375
|
-
releaseCapture(draft?.closeUp);
|
|
1376
1274
|
}
|
|
1377
1275
|
function useScreenshotDrafts(captureFailed, onError) {
|
|
1378
1276
|
const [screenshots, setScreenshots] = useState([]);
|
|
@@ -1474,9 +1372,12 @@ function useScreenshotDrafts(captureFailed, onError) {
|
|
|
1474
1372
|
}
|
|
1475
1373
|
} : item));
|
|
1476
1374
|
}, []);
|
|
1375
|
+
const activeScreenshot = screenshots.find(({ id }) => id === activeId) ?? screenshots.at(-1) ?? null;
|
|
1376
|
+
const firstCapture = pendingCapture ?? screenshots[0];
|
|
1477
1377
|
return {
|
|
1478
|
-
activeScreenshot
|
|
1378
|
+
activeScreenshot,
|
|
1479
1379
|
cancelPendingCapture,
|
|
1380
|
+
canRefreshAutomatically: screenshots.length <= 1 && firstCapture?.source === "automatic" && (activeScreenshot?.annotations.length ?? 0) === 0 && !screenshots.some((draft) => draft.selection),
|
|
1480
1381
|
pendingCapture,
|
|
1481
1382
|
refreshAutomatic,
|
|
1482
1383
|
removeCapture,
|
|
@@ -1515,7 +1416,8 @@ function useWidgetConfig(props) {
|
|
|
1515
1416
|
]),
|
|
1516
1417
|
dismissalKey: `reflet-feedback-dismissed:${publicKey ?? "default"}:${user?.id ?? "anonymous"}`,
|
|
1517
1418
|
dismissForDays: dismissalDuration(props.dismissForDays),
|
|
1518
|
-
isAnonymous: !(user || userToken)
|
|
1419
|
+
isAnonymous: !(user || userToken),
|
|
1420
|
+
publicKey: publicKey ?? null
|
|
1519
1421
|
};
|
|
1520
1422
|
}
|
|
1521
1423
|
//#endregion
|
|
@@ -1599,7 +1501,7 @@ function matchesHotkey(event, hotkey, platform = typeof navigator === "undefined
|
|
|
1599
1501
|
return event.altKey === expected.alt && event.ctrlKey === expected.ctrl && event.metaKey === expected.meta && event.shiftKey === expected.shift;
|
|
1600
1502
|
}
|
|
1601
1503
|
function useWidgetState(props) {
|
|
1602
|
-
const { client, dismissalKey, dismissForDays, isAnonymous } = useWidgetConfig(props);
|
|
1504
|
+
const { client, dismissalKey, dismissForDays, isAnonymous, publicKey } = useWidgetConfig(props);
|
|
1603
1505
|
const [isOpen, setIsOpen] = useState(false);
|
|
1604
1506
|
const [annotationTrigger, setAnnotationTrigger] = useState(null);
|
|
1605
1507
|
const [step, setStep] = useState("compose");
|
|
@@ -1645,9 +1547,7 @@ function useWidgetState(props) {
|
|
|
1645
1547
|
partialUploadMessage: props.labels?.attachmentUploadFailed ?? DEFAULT_WIDGET_LABELS.attachmentUploadFailed
|
|
1646
1548
|
});
|
|
1647
1549
|
const { resetSubmission } = submission;
|
|
1648
|
-
|
|
1649
|
-
const canRefreshAutomatically = gallery.screenshots.length <= 1 && firstCapture?.source === "automatic";
|
|
1650
|
-
useCaptureSync(isOpen && !submission.isEditingDisabled && step === "compose" && canRefreshAutomatically && annotations.length === 0 && !gallery.screenshots.some((draft) => draft.selection) && props.captureOnOpen !== false, refreshAutomatic);
|
|
1550
|
+
useCaptureSync(isOpen && !submission.isEditingDisabled && step === "compose" && gallery.canRefreshAutomatically && props.captureOnOpen !== false, refreshAutomatic);
|
|
1651
1551
|
const reset = useCallback(() => {
|
|
1652
1552
|
if (successTimer.current) clearTimeout(successTimer.current);
|
|
1653
1553
|
setAnnotationTrigger(null);
|
|
@@ -1700,21 +1600,18 @@ function useWidgetState(props) {
|
|
|
1700
1600
|
setStep("compose");
|
|
1701
1601
|
const pick = ++pickRef.current;
|
|
1702
1602
|
const context = collectPageContext({ sdkVersion: SDK_VERSION });
|
|
1703
|
-
const
|
|
1603
|
+
const fresh = await captureViewport().catch(() => null);
|
|
1704
1604
|
if (pickRef.current !== pick) {
|
|
1705
1605
|
releaseCapture(fresh);
|
|
1706
|
-
releaseCapture(closeUp);
|
|
1707
1606
|
return;
|
|
1708
1607
|
}
|
|
1709
1608
|
setIsElementCapturing(false);
|
|
1710
1609
|
if (!fresh) {
|
|
1711
|
-
releaseCapture(closeUp);
|
|
1712
1610
|
setError(captureFailed);
|
|
1713
1611
|
return;
|
|
1714
1612
|
}
|
|
1715
1613
|
storeScreenshot({
|
|
1716
1614
|
annotations: [highlightFor(picked, fresh)],
|
|
1717
|
-
closeUp,
|
|
1718
1615
|
context,
|
|
1719
1616
|
id: crypto.randomUUID(),
|
|
1720
1617
|
image: fresh,
|
|
@@ -1738,7 +1635,7 @@ function useWidgetState(props) {
|
|
|
1738
1635
|
setStep("compose");
|
|
1739
1636
|
return submission.submit({
|
|
1740
1637
|
context: {
|
|
1741
|
-
...activeScreenshot?.context ?? collectPageContext({ sdkVersion: "0.5.
|
|
1638
|
+
...activeScreenshot?.context ?? collectPageContext({ sdkVersion: "0.5.2" }),
|
|
1742
1639
|
consoleEvents: consoleRef.current?.events(),
|
|
1743
1640
|
metadata: props.metadata,
|
|
1744
1641
|
selections
|
|
@@ -1784,6 +1681,7 @@ function useWidgetState(props) {
|
|
|
1784
1681
|
message,
|
|
1785
1682
|
open,
|
|
1786
1683
|
pendingCapture: gallery.pendingCapture,
|
|
1684
|
+
publicKey,
|
|
1787
1685
|
removeCapture: gallery.removeCapture,
|
|
1788
1686
|
requestSubmit,
|
|
1789
1687
|
retakeCapture: gallery.retakeCapture,
|
|
@@ -2197,6 +2095,7 @@ const PICKER_STYLES = `
|
|
|
2197
2095
|
//#region src/feedback/ui/styles.ts
|
|
2198
2096
|
const WIDGET_STYLES = `
|
|
2199
2097
|
:host {
|
|
2098
|
+
pointer-events: auto;
|
|
2200
2099
|
--rf-offset: 20px;
|
|
2201
2100
|
--rf-bg: #ffffff;
|
|
2202
2101
|
--rf-bg-subtle: rgb(55 53 47 / 4%);
|
|
@@ -2385,6 +2284,7 @@ function ShadowPortal({ children, offset, primaryColor, theme }) {
|
|
|
2385
2284
|
useEffect(() => {
|
|
2386
2285
|
const host = document.createElement("div");
|
|
2387
2286
|
host.setAttribute(WIDGET_MARKER, "");
|
|
2287
|
+
stopClicksAtHost(host);
|
|
2388
2288
|
const root = host.attachShadow({ mode: "open" });
|
|
2389
2289
|
const style = document.createElement("style");
|
|
2390
2290
|
style.textContent = WIDGET_STYLES;
|
|
@@ -2410,7 +2310,7 @@ function ShadowPortal({ children, offset, primaryColor, theme }) {
|
|
|
2410
2310
|
}
|
|
2411
2311
|
//#endregion
|
|
2412
2312
|
//#region src/feedback/widget.tsx
|
|
2413
|
-
const DevtoolsLayer = process.env.NODE_ENV === "development" ? lazy(() => import("./devtools-layer-
|
|
2313
|
+
const DevtoolsLayer = process.env.NODE_ENV === "development" ? lazy(() => import("./devtools-layer-N5ptXXK4.js").then((module) => ({ default: module.DevtoolsLayer }))) : null;
|
|
2414
2314
|
function RefletFeedback(props) {
|
|
2415
2315
|
const { devtools = true, enabled = true, hotkey = null, offset = 20, position = "bottom-right", theme = "auto" } = props;
|
|
2416
2316
|
const labels = {
|
|
@@ -2438,25 +2338,9 @@ function RefletFeedback(props) {
|
|
|
2438
2338
|
position,
|
|
2439
2339
|
state
|
|
2440
2340
|
}),
|
|
2441
|
-
|
|
2442
|
-
capture: state.activeScreenshot.image,
|
|
2443
|
-
editor: {
|
|
2444
|
-
annotations: state.annotations,
|
|
2445
|
-
onChange: state.setAnnotations,
|
|
2446
|
-
onDone: () => state.setStep("compose"),
|
|
2447
|
-
onRetake: state.activeScreenshot.selection ? void 0 : () => {
|
|
2448
|
-
state.setStep("compose");
|
|
2449
|
-
if (state.activeScreenshot) state.retakeCapture(state.activeScreenshot.id);
|
|
2450
|
-
},
|
|
2451
|
-
trigger: state.annotationTrigger?.thumbnail
|
|
2452
|
-
},
|
|
2341
|
+
/* @__PURE__ */ jsx(WidgetAnnotation, {
|
|
2453
2342
|
labels,
|
|
2454
|
-
|
|
2455
|
-
comment: state.activeScreenshot.selection.comment ?? "",
|
|
2456
|
-
onChange: (comment) => {
|
|
2457
|
-
if (state.activeScreenshot) state.setSelectionComment(state.activeScreenshot.id, comment);
|
|
2458
|
-
}
|
|
2459
|
-
}
|
|
2343
|
+
state
|
|
2460
2344
|
}),
|
|
2461
2345
|
isOpen && state.step === "picking" && /* @__PURE__ */ jsx(ElementPicker, {
|
|
2462
2346
|
labels,
|
|
@@ -2467,11 +2351,35 @@ function RefletFeedback(props) {
|
|
|
2467
2351
|
fallback: null,
|
|
2468
2352
|
children: /* @__PURE__ */ jsx(DevtoolsLayer, {
|
|
2469
2353
|
isWidgetOpen: showsWidget && isOpen,
|
|
2470
|
-
position
|
|
2354
|
+
position,
|
|
2355
|
+
publicKey: state.publicKey
|
|
2471
2356
|
})
|
|
2472
2357
|
})]
|
|
2473
2358
|
});
|
|
2474
2359
|
}
|
|
2360
|
+
function WidgetAnnotation({ labels, state }) {
|
|
2361
|
+
const screenshot = state.activeScreenshot;
|
|
2362
|
+
if (!(state.isOpen && state.step === "annotate" && screenshot !== null && screenshot)) return null;
|
|
2363
|
+
const retake = () => {
|
|
2364
|
+
state.setStep("compose");
|
|
2365
|
+
state.retakeCapture(screenshot.id);
|
|
2366
|
+
};
|
|
2367
|
+
return /* @__PURE__ */ jsx(Annotator, {
|
|
2368
|
+
capture: screenshot.image,
|
|
2369
|
+
editor: {
|
|
2370
|
+
annotations: state.annotations,
|
|
2371
|
+
onChange: state.setAnnotations,
|
|
2372
|
+
onDone: () => state.setStep("compose"),
|
|
2373
|
+
onRetake: screenshot.selection ? void 0 : retake,
|
|
2374
|
+
trigger: state.annotationTrigger?.thumbnail
|
|
2375
|
+
},
|
|
2376
|
+
labels,
|
|
2377
|
+
note: screenshot.selection && {
|
|
2378
|
+
comment: screenshot.selection.comment ?? "",
|
|
2379
|
+
onChange: (comment) => state.setSelectionComment(screenshot.id, comment)
|
|
2380
|
+
}
|
|
2381
|
+
});
|
|
2382
|
+
}
|
|
2475
2383
|
//#endregion
|
|
2476
2384
|
export { RefletFeedback, buildElementSelection, captureViewport, collectPageContext, releaseCapture };
|
|
2477
2385
|
|