@ewjdev/anyclick-react 1.4.1 → 3.0.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 +24 -1
- package/dist/index.d.mts +373 -171
- package/dist/index.d.ts +373 -171
- package/dist/index.js +3986 -6450
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4004 -6447
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React$1 from 'react';
|
|
3
|
-
import React__default, {
|
|
3
|
+
import React__default, { CSSProperties, ReactNode } from 'react';
|
|
4
4
|
import { AnyclickAdapter, AnyclickType, AnyclickPayload, ScreenshotConfig, AnyclickTriggerEvent, ScreenshotData, AnyclickMenuEvent } from '@ewjdev/anyclick-core';
|
|
5
5
|
export { ALL_CURATED_PROPERTIES, AccessibilityInfo, AnyclickAdapter, AnyclickPayload, AnyclickType, BoxModelInfo, CURATED_STYLE_PROPERTIES, ComputedStylesInfo, DEFAULT_SCREENSHOT_CONFIG, DEFAULT_SENSITIVE_SELECTORS, ElementContext, ElementInspectInfo, PageContext, ScreenshotCapture, ScreenshotCaptureMode, ScreenshotConfig, ScreenshotData, captureAllScreenshots, captureScreenshot, estimateTotalSize, formatBoxModel, formatBytes, formatStylesAsCSS, getAccessibilityInfo, getAttributes, getBoxModelInfo, getComputedStyles, getElementInspectInfo, isScreenshotSupported } from '@ewjdev/anyclick-core';
|
|
6
6
|
import * as zustand from 'zustand';
|
|
7
|
-
import * as zustand_middleware from 'zustand/middleware';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* IDE protocol handler integration for opening files directly in IDEs.
|
|
@@ -76,18 +75,9 @@ declare function createIDEOpener(config?: Partial<IDEConfig>): (location: Source
|
|
|
76
75
|
*/
|
|
77
76
|
declare function formatSourceLocation(location: SourceLocation): string;
|
|
78
77
|
|
|
79
|
-
/**
|
|
80
|
-
* Position where the dialog is pinned
|
|
81
|
-
*/
|
|
82
78
|
type PinnedPosition = "left" | "right" | "top" | "bottom" | "floating";
|
|
83
|
-
/**
|
|
84
|
-
* Compact mode configuration type
|
|
85
|
-
* Adjust these values to control compact styling
|
|
86
|
-
*/
|
|
87
79
|
interface CompactModeConfig {
|
|
88
|
-
/** Base scaling factor (0.75 = 75% of normal size) */
|
|
89
80
|
scale: number;
|
|
90
|
-
/** Font sizes in pixels */
|
|
91
81
|
fonts: {
|
|
92
82
|
base: number;
|
|
93
83
|
title: number;
|
|
@@ -99,7 +89,6 @@ interface CompactModeConfig {
|
|
|
99
89
|
styleRow: number;
|
|
100
90
|
button: number;
|
|
101
91
|
};
|
|
102
|
-
/** Spacing (padding/margins) as CSS values */
|
|
103
92
|
spacing: {
|
|
104
93
|
headerPadding: string;
|
|
105
94
|
identityPadding: string;
|
|
@@ -114,7 +103,6 @@ interface CompactModeConfig {
|
|
|
114
103
|
propertyRowPadding: string;
|
|
115
104
|
styleRowPadding: string;
|
|
116
105
|
};
|
|
117
|
-
/** Gap values as CSS values */
|
|
118
106
|
gaps: {
|
|
119
107
|
headerTitle: string;
|
|
120
108
|
pinButtons: string;
|
|
@@ -123,7 +111,6 @@ interface CompactModeConfig {
|
|
|
123
111
|
button: string;
|
|
124
112
|
footer: string;
|
|
125
113
|
};
|
|
126
|
-
/** Size values in pixels */
|
|
127
114
|
sizes: {
|
|
128
115
|
dialogWidth: number;
|
|
129
116
|
closeButton: number;
|
|
@@ -132,44 +119,179 @@ interface CompactModeConfig {
|
|
|
132
119
|
categoryMarginBottom: number;
|
|
133
120
|
styleCategoryHeaderMarginBottom: number;
|
|
134
121
|
};
|
|
135
|
-
/** Letter spacing values */
|
|
136
122
|
letterSpacing: {
|
|
137
123
|
sectionTitle: string;
|
|
138
124
|
};
|
|
139
125
|
}
|
|
140
|
-
/**
|
|
141
|
-
* Default compact mode configuration
|
|
142
|
-
* Use this as a base to create custom configurations
|
|
143
|
-
*/
|
|
144
126
|
declare const DEFAULT_COMPACT_CONFIG: CompactModeConfig;
|
|
145
|
-
|
|
146
|
-
* Props for the InspectDialog component
|
|
147
|
-
*/
|
|
148
|
-
interface InspectDialogProps {
|
|
149
|
-
/** Whether the dialog is visible */
|
|
127
|
+
interface InspectSimpleProps {
|
|
150
128
|
visible: boolean;
|
|
151
|
-
/** The element being inspected */
|
|
152
129
|
targetElement: Element | null;
|
|
153
|
-
/** Callback when dialog is closed */
|
|
154
130
|
onClose: () => void;
|
|
155
|
-
/** Callback when selecting a different element (e.g., from modified elements list) */
|
|
156
131
|
onSelectElement?: (element: Element) => void;
|
|
157
|
-
/** IDE configuration for "Open in IDE" feature */
|
|
158
132
|
ideConfig?: Partial<IDEConfig>;
|
|
159
|
-
/** Custom styles for the dialog */
|
|
160
133
|
style?: React__default.CSSProperties;
|
|
161
|
-
/** Custom class name */
|
|
162
134
|
className?: string;
|
|
163
|
-
/** Custom highlight colors */
|
|
164
135
|
highlightColors?: HighlightColors;
|
|
165
|
-
/** Whether to show box model overlay (padding/margin visualization) */
|
|
166
136
|
showBoxModelOverlay?: boolean;
|
|
167
|
-
/** Initial pinned position. Defaults to "floating" (centered) */
|
|
168
137
|
initialPinnedPosition?: PinnedPosition;
|
|
169
|
-
/** Custom compact mode configuration. Partially override DEFAULT_COMPACT_CONFIG */
|
|
170
138
|
compactConfig?: Partial<CompactModeConfig>;
|
|
171
139
|
}
|
|
172
|
-
declare function
|
|
140
|
+
declare function InspectSimple({ visible, targetElement, onClose, ideConfig, style, className, highlightColors, }: InspectSimpleProps): react_jsx_runtime.JSX.Element | null;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Type definitions for QuickChat component.
|
|
144
|
+
*
|
|
145
|
+
* @module QuickChat/types
|
|
146
|
+
* @since 2.0.0
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Context payload chunk that can be included or excluded by the user.
|
|
151
|
+
*/
|
|
152
|
+
interface ContextChunk {
|
|
153
|
+
/** Unique identifier for the chunk */
|
|
154
|
+
id: string;
|
|
155
|
+
/** Human-readable label for the chunk */
|
|
156
|
+
label: string;
|
|
157
|
+
/** The actual content/data */
|
|
158
|
+
content: string;
|
|
159
|
+
/** Type of context (element, text, error, etc.) */
|
|
160
|
+
type: "element" | "text" | "error" | "navigation" | "custom";
|
|
161
|
+
/** Whether this chunk is included in the payload (default: true) */
|
|
162
|
+
included: boolean;
|
|
163
|
+
/** Size in characters */
|
|
164
|
+
size: number;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* A suggested prompt from the AI pre-pass.
|
|
168
|
+
*/
|
|
169
|
+
interface SuggestedPrompt {
|
|
170
|
+
/** Unique identifier */
|
|
171
|
+
id: string;
|
|
172
|
+
/** The prompt text */
|
|
173
|
+
text: string;
|
|
174
|
+
/** Optional category */
|
|
175
|
+
category?: string;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Quick action available for AI responses.
|
|
179
|
+
*/
|
|
180
|
+
interface QuickAction {
|
|
181
|
+
/** Unique identifier */
|
|
182
|
+
id: string;
|
|
183
|
+
/** Label to display */
|
|
184
|
+
label: string;
|
|
185
|
+
/** Icon to display */
|
|
186
|
+
icon?: ReactNode;
|
|
187
|
+
/** Action handler */
|
|
188
|
+
onClick: () => void;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* A single chat message.
|
|
192
|
+
*/
|
|
193
|
+
interface ChatMessage {
|
|
194
|
+
/** Unique identifier */
|
|
195
|
+
id: string;
|
|
196
|
+
/** Role of the sender */
|
|
197
|
+
role: "user" | "assistant" | "system";
|
|
198
|
+
/** Message content */
|
|
199
|
+
content: string;
|
|
200
|
+
/** Timestamp */
|
|
201
|
+
timestamp: number;
|
|
202
|
+
/** Whether the message is currently streaming */
|
|
203
|
+
isStreaming?: boolean;
|
|
204
|
+
/** Quick actions available for this message */
|
|
205
|
+
actions?: QuickAction[];
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Configuration for t3.chat integration.
|
|
209
|
+
*/
|
|
210
|
+
interface T3ChatIntegrationConfig {
|
|
211
|
+
/** Whether to show the "Send to t3.chat" button */
|
|
212
|
+
enabled?: boolean;
|
|
213
|
+
/** Base URL for t3.chat (default: https://t3.chat) */
|
|
214
|
+
baseUrl?: string;
|
|
215
|
+
/** Label for the button (default: "Ask t3.chat") */
|
|
216
|
+
label?: string;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Configuration for the QuickChat component.
|
|
220
|
+
*/
|
|
221
|
+
interface QuickChatConfig {
|
|
222
|
+
/** API endpoint for chat requests */
|
|
223
|
+
endpoint?: string;
|
|
224
|
+
/** Model to use for the main chat (default: auto) */
|
|
225
|
+
model?: string;
|
|
226
|
+
/** Model to use for pre-pass suggestions (default: gpt-5-nano) */
|
|
227
|
+
prePassModel?: string;
|
|
228
|
+
/** Maximum response length in characters */
|
|
229
|
+
maxResponseLength?: number;
|
|
230
|
+
/** Whether to show context redaction UI */
|
|
231
|
+
showRedactionUI?: boolean;
|
|
232
|
+
/** Whether to show suggested prompts */
|
|
233
|
+
showSuggestions?: boolean;
|
|
234
|
+
/** Custom system prompt */
|
|
235
|
+
systemPrompt?: string;
|
|
236
|
+
/** Placeholder text for input */
|
|
237
|
+
placeholder?: string;
|
|
238
|
+
/** Header title */
|
|
239
|
+
title?: string;
|
|
240
|
+
/** t3.chat integration settings */
|
|
241
|
+
t3chat?: T3ChatIntegrationConfig;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Props for the QuickChat component.
|
|
245
|
+
*/
|
|
246
|
+
interface QuickChatProps {
|
|
247
|
+
/** Whether the chat is visible */
|
|
248
|
+
visible: boolean;
|
|
249
|
+
/** Target element that was right-clicked */
|
|
250
|
+
targetElement: Element | null;
|
|
251
|
+
/** Container element */
|
|
252
|
+
containerElement: Element | null;
|
|
253
|
+
/** Callback when chat is closed */
|
|
254
|
+
onClose: () => void;
|
|
255
|
+
/** Callback when user wants to pin the chat */
|
|
256
|
+
onPin?: (pinned: boolean) => void;
|
|
257
|
+
/** Whether the chat is pinned */
|
|
258
|
+
isPinned?: boolean;
|
|
259
|
+
/** Configuration options */
|
|
260
|
+
config?: QuickChatConfig;
|
|
261
|
+
/** Custom styles */
|
|
262
|
+
style?: CSSProperties;
|
|
263
|
+
/** Custom class name */
|
|
264
|
+
className?: string;
|
|
265
|
+
/** Initial input value (for type-to-chat feature) */
|
|
266
|
+
initialInput?: string;
|
|
267
|
+
/** Callback when initial input has been consumed */
|
|
268
|
+
onInitialInputConsumed?: () => void;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* State for the QuickChat hook.
|
|
272
|
+
*/
|
|
273
|
+
interface QuickChatState {
|
|
274
|
+
/** Current input value */
|
|
275
|
+
input: string;
|
|
276
|
+
/** Chat messages */
|
|
277
|
+
messages: ChatMessage[];
|
|
278
|
+
/** Whether we're loading suggestions */
|
|
279
|
+
isLoadingSuggestions: boolean;
|
|
280
|
+
/** Whether we're sending a message */
|
|
281
|
+
isSending: boolean;
|
|
282
|
+
/** Whether we're streaming a response */
|
|
283
|
+
isStreaming: boolean;
|
|
284
|
+
/** Suggested prompts from pre-pass */
|
|
285
|
+
suggestedPrompts: SuggestedPrompt[];
|
|
286
|
+
/** Context chunks with redaction state */
|
|
287
|
+
contextChunks: ContextChunk[];
|
|
288
|
+
/** Error message if any */
|
|
289
|
+
error: string | null;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Default configuration values.
|
|
293
|
+
*/
|
|
294
|
+
declare const DEFAULT_QUICK_CHAT_CONFIG: Required<QuickChatConfig>;
|
|
173
295
|
|
|
174
296
|
/**
|
|
175
297
|
* Type definitions for @ewjdev/anyclick-react.
|
|
@@ -471,6 +593,11 @@ interface AnyclickProviderProps {
|
|
|
471
593
|
onSubmitError?: (error: Error, payload: AnyclickPayload) => void;
|
|
472
594
|
/** Callback after successful submission */
|
|
473
595
|
onSubmitSuccess?: (payload: AnyclickPayload) => void;
|
|
596
|
+
/**
|
|
597
|
+
* Configuration for QuickChat AI assistant.
|
|
598
|
+
* Set to enable the lightweight AI chat in the context menu.
|
|
599
|
+
*/
|
|
600
|
+
quickChatConfig?: QuickChatConfig;
|
|
474
601
|
/**
|
|
475
602
|
* Whether to scope this provider to its children only.
|
|
476
603
|
* When true, events will only be captured for elements within this provider's subtree.
|
|
@@ -573,6 +700,11 @@ interface ContextMenuProps {
|
|
|
573
700
|
};
|
|
574
701
|
/** Menu positioning mode (default: 'inView') */
|
|
575
702
|
positionMode?: MenuPositionMode;
|
|
703
|
+
/**
|
|
704
|
+
* Configuration for QuickChat AI assistant.
|
|
705
|
+
* When provided, shows the QuickChat interface in the context menu.
|
|
706
|
+
*/
|
|
707
|
+
quickChatConfig?: QuickChatConfig;
|
|
576
708
|
/** Configuration for screenshot capture */
|
|
577
709
|
screenshotConfig?: ScreenshotConfig;
|
|
578
710
|
/** Custom styles */
|
|
@@ -623,7 +755,7 @@ interface ScreenshotPreviewProps {
|
|
|
623
755
|
*
|
|
624
756
|
* @since 1.0.0
|
|
625
757
|
*/
|
|
626
|
-
declare function AnyclickProvider({ adapter, children, cooldownMs, disabled, header, highlightConfig, maxAncestors, maxInnerTextLength, maxOuterHTMLLength, menuClassName, menuItems, menuStyle, metadata, onSubmitError, onSubmitSuccess, scoped, screenshotConfig, stripAttributes, targetFilter, theme, touchHoldDurationMs, touchMoveThreshold, }: AnyclickProviderProps): react_jsx_runtime.JSX.Element;
|
|
758
|
+
declare function AnyclickProvider({ adapter, children, cooldownMs, disabled, header, highlightConfig, maxAncestors, maxInnerTextLength, maxOuterHTMLLength, menuClassName, menuItems, menuStyle, metadata, onSubmitError, onSubmitSuccess, quickChatConfig, scoped, screenshotConfig, stripAttributes, targetFilter, theme, touchHoldDurationMs, touchMoveThreshold, }: AnyclickProviderProps): react_jsx_runtime.JSX.Element;
|
|
627
759
|
/**
|
|
628
760
|
* @deprecated Use {@link AnyclickProvider} instead. Will be removed in v2.0.0.
|
|
629
761
|
*/
|
|
@@ -649,7 +781,7 @@ declare function FunModeBridge(): null;
|
|
|
649
781
|
*
|
|
650
782
|
* @since 1.0.0
|
|
651
783
|
*/
|
|
652
|
-
declare function ContextMenu({ className, containerElement, footer, header, highlightConfig, isSubmitting, items, onClose, onSelect, position, positionMode, screenshotConfig, style, targetElement, visible, }: ContextMenuProps): react_jsx_runtime.JSX.Element
|
|
784
|
+
declare function ContextMenu({ className, containerElement, footer, header, highlightConfig, isSubmitting, items, onClose, onSelect, position, positionMode, quickChatConfig, screenshotConfig, style, targetElement, visible, }: ContextMenuProps): react_jsx_runtime.JSX.Element;
|
|
653
785
|
|
|
654
786
|
/**
|
|
655
787
|
* Screenshot preview component - shows captured screenshots before sending.
|
|
@@ -1019,6 +1151,160 @@ declare function createPresetMenu(role: PresetRole, options?: CreatePresetMenuOp
|
|
|
1019
1151
|
*/
|
|
1020
1152
|
declare function listPresets(): PresetConfig[];
|
|
1021
1153
|
|
|
1154
|
+
/**
|
|
1155
|
+
* Creates a menu item for sending selected text or a query to t3.chat.
|
|
1156
|
+
*
|
|
1157
|
+
* Can be added to any custom menu configuration. Uses the current text
|
|
1158
|
+
* selection if available, otherwise opens t3.chat without a pre-filled query.
|
|
1159
|
+
*
|
|
1160
|
+
* @param options - Optional customization for the menu item
|
|
1161
|
+
* @returns A ContextMenuItem configured for t3.chat
|
|
1162
|
+
*
|
|
1163
|
+
* @example
|
|
1164
|
+
* ```tsx
|
|
1165
|
+
* import { createT3ChatMenuItem } from "@ewjdev/anyclick-react";
|
|
1166
|
+
*
|
|
1167
|
+
* const menuItems = [
|
|
1168
|
+
* { label: "Bug", type: "bug", showComment: true },
|
|
1169
|
+
* createT3ChatMenuItem(),
|
|
1170
|
+
* ];
|
|
1171
|
+
* ```
|
|
1172
|
+
*
|
|
1173
|
+
* @since 1.5.0
|
|
1174
|
+
*/
|
|
1175
|
+
declare function createT3ChatMenuItem(options?: {
|
|
1176
|
+
/** Custom label for the menu item */
|
|
1177
|
+
label?: string;
|
|
1178
|
+
/** Base URL for t3.chat */
|
|
1179
|
+
baseUrl?: string;
|
|
1180
|
+
}): ContextMenuItem;
|
|
1181
|
+
/**
|
|
1182
|
+
* Gets the currently selected text on the page.
|
|
1183
|
+
*
|
|
1184
|
+
* Useful for checking if text is selected before showing certain menu items.
|
|
1185
|
+
*
|
|
1186
|
+
* @returns The selected text, or empty string if nothing is selected
|
|
1187
|
+
*
|
|
1188
|
+
* @example
|
|
1189
|
+
* ```tsx
|
|
1190
|
+
* const selection = getSelectedText();
|
|
1191
|
+
* if (selection) {
|
|
1192
|
+
* console.log("Selected:", selection);
|
|
1193
|
+
* }
|
|
1194
|
+
* ```
|
|
1195
|
+
*
|
|
1196
|
+
* @since 1.5.0
|
|
1197
|
+
*/
|
|
1198
|
+
declare function getSelectedText(): string;
|
|
1199
|
+
/**
|
|
1200
|
+
* Checks if there is currently any text selected on the page.
|
|
1201
|
+
*
|
|
1202
|
+
* @returns true if text is selected
|
|
1203
|
+
*
|
|
1204
|
+
* @since 1.5.0
|
|
1205
|
+
*/
|
|
1206
|
+
declare function hasTextSelection(): boolean;
|
|
1207
|
+
/**
|
|
1208
|
+
* Detects if an element is or contains an image that can be uploaded.
|
|
1209
|
+
*
|
|
1210
|
+
* Checks for:
|
|
1211
|
+
* - `<img>` elements
|
|
1212
|
+
* - `<picture>` elements
|
|
1213
|
+
* - `<canvas>` elements
|
|
1214
|
+
* - `<svg>` elements
|
|
1215
|
+
* - CSS background images
|
|
1216
|
+
*
|
|
1217
|
+
* @param element - The element to check
|
|
1218
|
+
* @returns Object with isImage flag and optional image source
|
|
1219
|
+
*
|
|
1220
|
+
* @since 1.5.0
|
|
1221
|
+
*/
|
|
1222
|
+
declare function detectImageElement(element: Element | null): {
|
|
1223
|
+
isImage: boolean;
|
|
1224
|
+
src?: string;
|
|
1225
|
+
type?: "img" | "picture" | "svg" | "canvas" | "background";
|
|
1226
|
+
};
|
|
1227
|
+
/**
|
|
1228
|
+
* Creates a menu item for uploading images to UploadThing.
|
|
1229
|
+
*
|
|
1230
|
+
* The menu item will upload the target element if it's an image,
|
|
1231
|
+
* or a screenshot of the element otherwise.
|
|
1232
|
+
*
|
|
1233
|
+
* Requires an UploadThing adapter to be configured. The onClick handler
|
|
1234
|
+
* receives the target element and can use detectImageElement to determine
|
|
1235
|
+
* if it's an image.
|
|
1236
|
+
*
|
|
1237
|
+
* @param options - Configuration options
|
|
1238
|
+
* @returns A ContextMenuItem configured for UploadThing
|
|
1239
|
+
*
|
|
1240
|
+
* @example
|
|
1241
|
+
* ```tsx
|
|
1242
|
+
* import { createUploadThingMenuItem } from "@ewjdev/anyclick-react";
|
|
1243
|
+
*
|
|
1244
|
+
* const menuItems = [
|
|
1245
|
+
* createUploadThingMenuItem({
|
|
1246
|
+
* endpoint: "/api/uploadthing",
|
|
1247
|
+
* onUploadComplete: (result) => {
|
|
1248
|
+
* console.log("Uploaded:", result.url);
|
|
1249
|
+
* },
|
|
1250
|
+
* }),
|
|
1251
|
+
* ];
|
|
1252
|
+
* ```
|
|
1253
|
+
*
|
|
1254
|
+
* @since 1.5.0
|
|
1255
|
+
*/
|
|
1256
|
+
declare function createUploadThingMenuItem(options?: {
|
|
1257
|
+
/** Custom label for the menu item */
|
|
1258
|
+
label?: string;
|
|
1259
|
+
/** API endpoint for uploading */
|
|
1260
|
+
endpoint?: string;
|
|
1261
|
+
/** Callback when upload completes */
|
|
1262
|
+
onUploadComplete?: (result: {
|
|
1263
|
+
url?: string;
|
|
1264
|
+
error?: string;
|
|
1265
|
+
}) => void;
|
|
1266
|
+
/** Callback when upload fails */
|
|
1267
|
+
onUploadError?: (error: Error) => void;
|
|
1268
|
+
}): ContextMenuItem;
|
|
1269
|
+
/**
|
|
1270
|
+
* Creates a menu item for uploading screenshots to UploadThing.
|
|
1271
|
+
*
|
|
1272
|
+
* This captures a screenshot of the target element and uploads it.
|
|
1273
|
+
* Requires the screenshot preview to be enabled for best results.
|
|
1274
|
+
*
|
|
1275
|
+
* @param options - Configuration options
|
|
1276
|
+
* @returns A ContextMenuItem configured for screenshot uploads
|
|
1277
|
+
*
|
|
1278
|
+
* @example
|
|
1279
|
+
* ```tsx
|
|
1280
|
+
* import { createUploadScreenshotMenuItem } from "@ewjdev/anyclick-react";
|
|
1281
|
+
*
|
|
1282
|
+
* const menuItems = [
|
|
1283
|
+
* createUploadScreenshotMenuItem({
|
|
1284
|
+
* endpoint: "/api/uploadthing",
|
|
1285
|
+
* onUploadComplete: (result) => {
|
|
1286
|
+
* navigator.clipboard.writeText(result.url);
|
|
1287
|
+
* },
|
|
1288
|
+
* }),
|
|
1289
|
+
* ];
|
|
1290
|
+
* ```
|
|
1291
|
+
*
|
|
1292
|
+
* @since 1.5.0
|
|
1293
|
+
*/
|
|
1294
|
+
declare function createUploadScreenshotMenuItem(options?: {
|
|
1295
|
+
/** Custom label for the menu item */
|
|
1296
|
+
label?: string;
|
|
1297
|
+
/** API endpoint for uploading */
|
|
1298
|
+
endpoint?: string;
|
|
1299
|
+
/** Callback when upload completes */
|
|
1300
|
+
onUploadComplete?: (result: {
|
|
1301
|
+
url?: string;
|
|
1302
|
+
error?: string;
|
|
1303
|
+
}) => void;
|
|
1304
|
+
/** Callback when upload fails */
|
|
1305
|
+
onUploadError?: (error: Error) => void;
|
|
1306
|
+
}): ContextMenuItem;
|
|
1307
|
+
|
|
1022
1308
|
/**
|
|
1023
1309
|
* Style definitions for anyclick-react components.
|
|
1024
1310
|
*
|
|
@@ -1287,118 +1573,6 @@ interface InspectDialogManagerProps {
|
|
|
1287
1573
|
*/
|
|
1288
1574
|
declare function InspectDialogManager({ ideConfig, dialogStyle, dialogClassName, highlightColors, showBoxModelOverlay, initialPinnedPosition, compactConfig, }: InspectDialogManagerProps): react_jsx_runtime.JSX.Element;
|
|
1289
1575
|
|
|
1290
|
-
/**
|
|
1291
|
-
* Represents a modification made to an element
|
|
1292
|
-
*/
|
|
1293
|
-
interface ElementModification {
|
|
1294
|
-
/** Unique identifier for the element (generated selector or path) */
|
|
1295
|
-
elementId: string;
|
|
1296
|
-
/** CSS selector to find the element */
|
|
1297
|
-
selector: string;
|
|
1298
|
-
/** Human-readable description of the element */
|
|
1299
|
-
description: string;
|
|
1300
|
-
/** Timestamp of the last modification */
|
|
1301
|
-
lastModified: number;
|
|
1302
|
-
/** Original inline styles before modification */
|
|
1303
|
-
originalStyles: Record<string, string>;
|
|
1304
|
-
/** Current modified inline styles */
|
|
1305
|
-
modifiedStyles: Record<string, string>;
|
|
1306
|
-
/** Original attributes before modification */
|
|
1307
|
-
originalAttributes: Record<string, string>;
|
|
1308
|
-
/** Current modified attributes */
|
|
1309
|
-
modifiedAttributes: Record<string, string>;
|
|
1310
|
-
/** Whether the element was deleted */
|
|
1311
|
-
isDeleted?: boolean;
|
|
1312
|
-
}
|
|
1313
|
-
/**
|
|
1314
|
-
* Represents a deleted (hidden) element that can be restored
|
|
1315
|
-
* Elements are hidden with display:none rather than removed from DOM
|
|
1316
|
-
* for easier persistence and recovery
|
|
1317
|
-
*/
|
|
1318
|
-
interface DeletedElement {
|
|
1319
|
-
/** Unique identifier for the element */
|
|
1320
|
-
elementId: string;
|
|
1321
|
-
/** CSS selector to find the element */
|
|
1322
|
-
selector: string;
|
|
1323
|
-
/** Human-readable description */
|
|
1324
|
-
description: string;
|
|
1325
|
-
/** Original display value before hiding */
|
|
1326
|
-
originalDisplay: string;
|
|
1327
|
-
/** Timestamp of deletion */
|
|
1328
|
-
deletedAt: number;
|
|
1329
|
-
}
|
|
1330
|
-
/**
|
|
1331
|
-
* Generate a unique ID for an element based on its position in the DOM
|
|
1332
|
-
* Uses only simple, reliable selectors to avoid issues with special characters
|
|
1333
|
-
*/
|
|
1334
|
-
declare function generateElementId(element: Element): string;
|
|
1335
|
-
/**
|
|
1336
|
-
* Get a human-readable description of an element
|
|
1337
|
-
*/
|
|
1338
|
-
declare function getElementDescription(element: Element): string;
|
|
1339
|
-
/**
|
|
1340
|
-
* Persisted state shape (what gets saved to localStorage)
|
|
1341
|
-
*/
|
|
1342
|
-
interface PersistedState {
|
|
1343
|
-
pinnedPosition: PinnedPosition;
|
|
1344
|
-
modifiedElements: Record<string, ElementModification>;
|
|
1345
|
-
deletedElements: Record<string, DeletedElement>;
|
|
1346
|
-
}
|
|
1347
|
-
interface InspectStore extends PersistedState {
|
|
1348
|
-
/** Persisted pinned position */
|
|
1349
|
-
setPinnedPosition: (position: PinnedPosition) => void;
|
|
1350
|
-
/** Whether the store has been hydrated from storage */
|
|
1351
|
-
_hasHydrated: boolean;
|
|
1352
|
-
setHasHydrated: (state: boolean) => void;
|
|
1353
|
-
/** Whether modifications were auto-applied on page load */
|
|
1354
|
-
hasAutoAppliedModifications: boolean;
|
|
1355
|
-
setHasAutoAppliedModifications: (value: boolean) => void;
|
|
1356
|
-
/** Track a modification to an element */
|
|
1357
|
-
trackModification: (element: Element, type: "style" | "attribute", key: string, oldValue: string | null, newValue: string | null) => void;
|
|
1358
|
-
/** Track an element deletion */
|
|
1359
|
-
trackDeletion: (element: Element) => void;
|
|
1360
|
-
/** Get modification record for an element */
|
|
1361
|
-
getModification: (element: Element) => ElementModification | null;
|
|
1362
|
-
/** Reset all modifications for a specific element */
|
|
1363
|
-
resetElement: (elementId: string) => void;
|
|
1364
|
-
/** Reset all modifications for all elements (including restoring deleted elements) */
|
|
1365
|
-
resetAllElements: () => void;
|
|
1366
|
-
/** Get all modified elements that still exist in the DOM */
|
|
1367
|
-
getModifiedElementsInDOM: () => Array<{
|
|
1368
|
-
modification: ElementModification;
|
|
1369
|
-
element: Element | null;
|
|
1370
|
-
}>;
|
|
1371
|
-
/** Get count of deleted elements */
|
|
1372
|
-
getDeletedCount: () => number;
|
|
1373
|
-
/** Apply persisted modifications to the DOM */
|
|
1374
|
-
applyPersistedModifications: () => number;
|
|
1375
|
-
/** Clear persisted state (for testing) */
|
|
1376
|
-
clearPersistedState: () => void;
|
|
1377
|
-
}
|
|
1378
|
-
declare const useInspectStore: zustand.UseBoundStore<Omit<zustand.StoreApi<InspectStore>, "setState" | "persist"> & {
|
|
1379
|
-
setState(partial: InspectStore | Partial<InspectStore> | ((state: InspectStore) => InspectStore | Partial<InspectStore>), replace?: false | undefined): unknown;
|
|
1380
|
-
setState(state: InspectStore | ((state: InspectStore) => InspectStore), replace: true): unknown;
|
|
1381
|
-
persist: {
|
|
1382
|
-
setOptions: (options: Partial<zustand_middleware.PersistOptions<InspectStore, unknown, unknown>>) => void;
|
|
1383
|
-
clearStorage: () => void;
|
|
1384
|
-
rehydrate: () => Promise<void> | void;
|
|
1385
|
-
hasHydrated: () => boolean;
|
|
1386
|
-
onHydrate: (fn: (state: InspectStore) => void) => () => void;
|
|
1387
|
-
onFinishHydration: (fn: (state: InspectStore) => void) => () => void;
|
|
1388
|
-
getOptions: () => Partial<zustand_middleware.PersistOptions<InspectStore, unknown, unknown>>;
|
|
1389
|
-
};
|
|
1390
|
-
}>;
|
|
1391
|
-
/**
|
|
1392
|
-
* Custom hook to check if the store has been hydrated
|
|
1393
|
-
* Use this to prevent hydration mismatches in SSR
|
|
1394
|
-
*/
|
|
1395
|
-
declare function useHasHydrated(): boolean;
|
|
1396
|
-
/**
|
|
1397
|
-
* Wait for hydration to complete before accessing persisted data
|
|
1398
|
-
* Useful for ensuring data is available before rendering
|
|
1399
|
-
*/
|
|
1400
|
-
declare function waitForHydration(): Promise<void>;
|
|
1401
|
-
|
|
1402
1576
|
interface AnyclickLogoProps {
|
|
1403
1577
|
/** Size of the logo in pixels. Defaults to 64 */
|
|
1404
1578
|
size?: number;
|
|
@@ -1421,29 +1595,57 @@ interface AnyclickLogoProps {
|
|
|
1421
1595
|
*/
|
|
1422
1596
|
declare function AnyclickLogo({ size, borderWidth, primaryColor, backgroundColor, className, style, onClick, }: AnyclickLogoProps): react_jsx_runtime.JSX.Element;
|
|
1423
1597
|
|
|
1424
|
-
interface ModificationIndicatorProps {
|
|
1425
|
-
/** Position of the indicator. Defaults to "bottom-right" */
|
|
1426
|
-
position?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
1427
|
-
/** Size of the logo in pixels. Defaults to 48 */
|
|
1428
|
-
size?: number;
|
|
1429
|
-
/** Whether to auto-apply persisted modifications on mount. Defaults to true */
|
|
1430
|
-
autoApply?: boolean;
|
|
1431
|
-
/** Offset from edge in pixels. Defaults to 16 */
|
|
1432
|
-
offset?: number;
|
|
1433
|
-
/** Primary color for the logo */
|
|
1434
|
-
primaryColor?: string;
|
|
1435
|
-
/** Background color for the logo */
|
|
1436
|
-
backgroundColor?: string;
|
|
1437
|
-
}
|
|
1438
1598
|
/**
|
|
1439
|
-
*
|
|
1599
|
+
* QuickChat component.
|
|
1600
|
+
*/
|
|
1601
|
+
declare function QuickChat({ visible, targetElement, containerElement, onClose, onPin, isPinned: isPinnedProp, config, style, className, initialInput, onInitialInputConsumed, }: QuickChatProps): react_jsx_runtime.JSX.Element | null;
|
|
1602
|
+
|
|
1603
|
+
/**
|
|
1604
|
+
* Hook for managing QuickChat state and interactions.
|
|
1605
|
+
*/
|
|
1606
|
+
declare function useQuickChat(targetElement: Element | null, containerElement: Element | null, config?: QuickChatConfig): {
|
|
1607
|
+
config: {
|
|
1608
|
+
endpoint: string;
|
|
1609
|
+
model: string;
|
|
1610
|
+
prePassModel: string;
|
|
1611
|
+
maxResponseLength: number;
|
|
1612
|
+
showRedactionUI: boolean;
|
|
1613
|
+
showSuggestions: boolean;
|
|
1614
|
+
systemPrompt: string;
|
|
1615
|
+
placeholder: string;
|
|
1616
|
+
title: string;
|
|
1617
|
+
t3chat: T3ChatIntegrationConfig;
|
|
1618
|
+
};
|
|
1619
|
+
setInput: (value: string) => void;
|
|
1620
|
+
toggleChunk: (chunkId: string) => void;
|
|
1621
|
+
toggleAllChunks: (included: boolean) => void;
|
|
1622
|
+
selectSuggestion: (prompt: SuggestedPrompt) => void;
|
|
1623
|
+
sendMessage: (messageText?: string) => Promise<void>;
|
|
1624
|
+
clearMessages: () => void;
|
|
1625
|
+
input: string;
|
|
1626
|
+
messages: ChatMessage[];
|
|
1627
|
+
isLoadingSuggestions: boolean;
|
|
1628
|
+
isSending: boolean;
|
|
1629
|
+
isStreaming: boolean;
|
|
1630
|
+
suggestedPrompts: SuggestedPrompt[];
|
|
1631
|
+
contextChunks: ContextChunk[];
|
|
1632
|
+
error: string | null;
|
|
1633
|
+
};
|
|
1634
|
+
|
|
1635
|
+
/**
|
|
1636
|
+
* Style definitions for QuickChat component.
|
|
1440
1637
|
*
|
|
1441
|
-
*
|
|
1442
|
-
*
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1638
|
+
* @module QuickChat/styles
|
|
1639
|
+
* @since 2.0.0
|
|
1640
|
+
*/
|
|
1641
|
+
|
|
1642
|
+
/**
|
|
1643
|
+
* QuickChat component styles.
|
|
1644
|
+
*/
|
|
1645
|
+
declare const quickChatStyles: Record<string, CSSProperties>;
|
|
1646
|
+
/**
|
|
1647
|
+
* CSS keyframes for animations (to be injected).
|
|
1446
1648
|
*/
|
|
1447
|
-
declare
|
|
1649
|
+
declare const quickChatKeyframes = "\n@keyframes blink {\n 0%, 50% { opacity: 1; }\n 51%, 100% { opacity: 0; }\n}\n\n@keyframes bounce {\n 0%, 80%, 100% { transform: scale(0); }\n 40% { transform: scale(1); }\n}\n\n@keyframes slideIn {\n from {\n opacity: 0;\n transform: translateY(-8px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes slideInFromRight {\n from {\n transform: translateX(100%);\n }\n to {\n transform: translateX(0);\n }\n}\n\n@keyframes slideOutToRight {\n from {\n transform: translateX(0);\n }\n to {\n transform: translateX(100%);\n }\n}\n\n@keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n@keyframes spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n\n@keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n}\n";
|
|
1448
1650
|
|
|
1449
|
-
export { AnyclickContext, type AnyclickContextValue, AnyclickLogo, type AnyclickLogoProps, AnyclickProvider, type AnyclickProviderProps, type AnyclickTheme, type AnyclickUserContext, type CompactModeConfig, ContextMenu, type ContextMenuItem, type ContextMenuProps, type CreatePresetMenuOptions, DEFAULT_COMPACT_CONFIG,
|
|
1651
|
+
export { AnyclickContext, type AnyclickContextValue, AnyclickLogo, type AnyclickLogoProps, AnyclickProvider, type AnyclickProviderProps, type AnyclickTheme, type AnyclickUserContext, type ChatMessage, type CompactModeConfig, type ContextChunk, ContextMenu, type ContextMenuItem, type ContextMenuProps, type CreatePresetMenuOptions, DEFAULT_COMPACT_CONFIG, DEFAULT_QUICK_CHAT_CONFIG, FeedbackContext, type FeedbackMenuBadge, type FeedbackMenuStatus, FeedbackProvider, FunModeBridge, type FunModeThemeConfig, type HighlightColors, type HighlightConfig, type IDEConfig, type IDEProtocol, INSPECT_DIALOG_EVENT, type InspectDialogEventDetail, InspectDialogManager, type InspectDialogManagerProps, InspectSimple, type InspectSimpleProps, type MenuPositionMode, type PinnedPosition, type PresetConfig, type PresetRole, type ProviderInstance, type QuickAction, QuickChat, type QuickChatConfig, type QuickChatProps, type QuickChatState, ScreenshotPreview, type ScreenshotPreviewProps, type SourceLocation, type SuggestedPrompt, type T3ChatIntegrationConfig, applyHighlights, buildIDEUrl, clearHighlights, createIDEOpener, createPresetMenu, createT3ChatMenuItem, createUploadScreenshotMenuItem, createUploadThingMenuItem, darkMenuStyles, defaultContainerSelectors, defaultHighlightColors, detectImageElement, detectPreferredIDE, dispatchContextMenuEvent, filterMenuItemsByRole, findContainerParent, findSourceLocationInAncestors, formatSourceLocation, generateProviderId, getBadgeStyle, getSelectedText, getSourceLocationFromElement, hasTextSelection, highlightContainer, highlightTarget, isIDEProtocolSupported, listPresets, menuCSSVariables, menuStyles, openInIDE, openInspectDialog, presetDefaults, quickChatKeyframes, quickChatStyles, useAnyclick, useFeedback, useProviderStore, useQuickChat };
|