@perpetio/redline 2.1.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/LICENSE +56 -0
- package/README.md +763 -0
- package/bin/redline-mcp.cjs +30 -0
- package/docs/images/npm-banner.jpg +0 -0
- package/docs/images/npm-review.png +0 -0
- package/examples/plain-html.html +30 -0
- package/examples/playground.html +101 -0
- package/examples/react.jsx +23 -0
- package/examples/vue.vue +25 -0
- package/package.json +71 -0
- package/redline.d.cts +2 -0
- package/redline.d.mts +280 -0
- package/redline.d.ts +279 -0
- package/redline.js +2 -0
- package/redline.mjs +753 -0
package/redline.d.mts
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
// Generated from redline.d.ts. Do not edit directly.
|
|
2
|
+
export interface RedlineConfig {
|
|
3
|
+
/** Storage namespace shared by pages in one project. */
|
|
4
|
+
project?: string;
|
|
5
|
+
/** Fixed page key. By default Redline follows location.pathname. */
|
|
6
|
+
page?: string;
|
|
7
|
+
accent?: string;
|
|
8
|
+
theme?: 'auto' | 'light' | 'dark';
|
|
9
|
+
position?: 'bottom-right' | 'bottom-left';
|
|
10
|
+
blocks?: string;
|
|
11
|
+
startOpen?: boolean;
|
|
12
|
+
note?: string;
|
|
13
|
+
/** Email address or issue URL template. {page}, {count}, {summary} are URL encoded. */
|
|
14
|
+
shareEmail?: string;
|
|
15
|
+
/** Watch History API navigation and popstate. */
|
|
16
|
+
spa?: boolean;
|
|
17
|
+
/** HTTP endpoint receiving the JSON export on an explicit Send feedback action. */
|
|
18
|
+
postUrl?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Retries for postUrl, 0 to 5, default 3, on network errors, timeouts, 408,
|
|
21
|
+
* 429 and 5xx. Waits 1 s, 2 s, 4 s…, or the receiver's Retry-After (up to 30 s)
|
|
22
|
+
* when the browser can read it.
|
|
23
|
+
*/
|
|
24
|
+
postRetries?: number;
|
|
25
|
+
/** Redline Cloud review to sync with, or "local" for the coding agent's redline-mcp (localhost and 127.0.0.1 pages only). */
|
|
26
|
+
reviewId?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Redline Cloud workspace id (ws_…). The Cloud names the review this site
|
|
29
|
+
* uses in the workspace; reviewId, when set, pins the page instead.
|
|
30
|
+
*/
|
|
31
|
+
workspace?: string;
|
|
32
|
+
/** Query parameter carrying the invite token. Default "an_invite". */
|
|
33
|
+
inviteParam?: string;
|
|
34
|
+
/** Poll interval in milliseconds for remote reads. Default 20000, minimum 500. */
|
|
35
|
+
pollInterval?: number;
|
|
36
|
+
/** Fetch credentials mode for postUrl requests. Default "omit". Requests to Redline Cloud and the local agent never carry cookies. */
|
|
37
|
+
credentials?: 'omit' | 'same-origin' | 'include';
|
|
38
|
+
/**
|
|
39
|
+
* Extras each new comment records besides the element description:
|
|
40
|
+
* "styles", "components", both comma-separated (default), or "off".
|
|
41
|
+
*/
|
|
42
|
+
capture?: string | Array<'styles' | 'components'>;
|
|
43
|
+
/**
|
|
44
|
+
* "Open in editor" link template. {path}, {line}, {column} come from the
|
|
45
|
+
* comment's component source, e.g. "vscode://file/Users/me/app/{path}:{line}".
|
|
46
|
+
*/
|
|
47
|
+
editorUrl?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface ResolvedRedlineConfig {
|
|
51
|
+
project: string;
|
|
52
|
+
page: string;
|
|
53
|
+
accent: string;
|
|
54
|
+
theme: 'auto' | 'light' | 'dark';
|
|
55
|
+
position: 'bottom-right' | 'bottom-left';
|
|
56
|
+
blocks: string;
|
|
57
|
+
startOpen: boolean;
|
|
58
|
+
note: string;
|
|
59
|
+
share: string;
|
|
60
|
+
spa: boolean;
|
|
61
|
+
postUrl: string;
|
|
62
|
+
postRetries: number;
|
|
63
|
+
reviewId: string;
|
|
64
|
+
workspace: string;
|
|
65
|
+
inviteParam: string;
|
|
66
|
+
pollInterval: number;
|
|
67
|
+
credentials: 'omit' | 'same-origin' | 'include';
|
|
68
|
+
capture: 'styles,components' | 'styles' | 'components' | 'off';
|
|
69
|
+
editorUrl: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type RedlineStatus = 'open' | 'in_progress' | 'resolved' | 'wont_fix';
|
|
73
|
+
|
|
74
|
+
export type RedlineGeom =
|
|
75
|
+
| { kind: 'rect' | 'circle'; selector: string; x: number; y: number; w: number; h: number; vw?: number; vh?: number }
|
|
76
|
+
| { kind: 'pin'; selector?: string; x: number; y: number; vw?: number; vh?: number }
|
|
77
|
+
| { kind: 'pen'; selector: string; points: Array<[number, number]>; vw?: number; vh?: number }
|
|
78
|
+
| { kind: 'block'; selector: string }
|
|
79
|
+
| { kind: 'group'; selectors: string[]; vw?: number; vh?: number };
|
|
80
|
+
|
|
81
|
+
export interface RedlineAssignee {
|
|
82
|
+
id: string | null;
|
|
83
|
+
name: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface RedlineReply {
|
|
87
|
+
id: string;
|
|
88
|
+
author: string;
|
|
89
|
+
authorId: string | null;
|
|
90
|
+
text: string;
|
|
91
|
+
createdAt: string;
|
|
92
|
+
editedAt: string | null;
|
|
93
|
+
/** Member ids mentioned (synced reviews). */
|
|
94
|
+
mentions?: string[];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type RedlineStyleKey =
|
|
98
|
+
| 'display' | 'position' | 'width' | 'height' | 'margin' | 'padding' | 'gap' | 'font-family' | 'font-size'
|
|
99
|
+
| 'font-weight' | 'line-height' | 'color' | 'background-color' | 'border' | 'border-radius' | 'box-shadow'
|
|
100
|
+
| 'opacity' | 'object-fit';
|
|
101
|
+
|
|
102
|
+
/** The element a comment is about, recorded once when it is made (1.6+). */
|
|
103
|
+
export interface RedlineTarget {
|
|
104
|
+
label: string;
|
|
105
|
+
tag: string;
|
|
106
|
+
role: string | null;
|
|
107
|
+
name: string | null;
|
|
108
|
+
id: string | null;
|
|
109
|
+
testId: string | null;
|
|
110
|
+
classes: string[];
|
|
111
|
+
selector: string;
|
|
112
|
+
heading: string | null;
|
|
113
|
+
box: { x: number; y: number; w: number; h: number };
|
|
114
|
+
styles: Partial<Record<RedlineStyleKey, string>> | null;
|
|
115
|
+
component: { framework: 'react' | 'vue' | 'svelte'; chain: string[]; source: string | null } | null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface RedlineMarkdownOptions {
|
|
119
|
+
detail?: 'compact' | 'standard' | 'detailed';
|
|
120
|
+
scope?: 'page' | 'site';
|
|
121
|
+
/** Include resolved and won't-fix comments. Default false. */
|
|
122
|
+
includeClosed?: boolean;
|
|
123
|
+
/** Only these comment ids. */
|
|
124
|
+
ids?: string[];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface RedlineCopyOptions {
|
|
128
|
+
format?: 'markdown' | 'json';
|
|
129
|
+
detail?: 'compact' | 'standard' | 'detailed';
|
|
130
|
+
scope?: 'page' | 'site';
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Record schema v2 (docs/backlog/wire-protocol.md). */
|
|
134
|
+
export interface RedlineComment {
|
|
135
|
+
schema: 2;
|
|
136
|
+
id: string;
|
|
137
|
+
page: string;
|
|
138
|
+
url: string;
|
|
139
|
+
type: 'highlight' | 'shape' | 'pin' | 'pen' | 'note' | 'block' | 'group';
|
|
140
|
+
author: string;
|
|
141
|
+
authorId: string | null;
|
|
142
|
+
text: string;
|
|
143
|
+
color: string;
|
|
144
|
+
anchor: { exact: string; prefix: string; suffix: string } | null;
|
|
145
|
+
geom: RedlineGeom | null;
|
|
146
|
+
/** Absent on comments made before 1.6 or where nothing could be described. */
|
|
147
|
+
target?: RedlineTarget;
|
|
148
|
+
/** Group comments only: one entry per `geom.selectors` item, `null` where nothing could be described. Create-only. */
|
|
149
|
+
targets?: (RedlineTarget | null)[];
|
|
150
|
+
visibility: 'shared' | 'private';
|
|
151
|
+
status: RedlineStatus;
|
|
152
|
+
/** Derived: true when status is "resolved" or "wont_fix". */
|
|
153
|
+
resolved: boolean;
|
|
154
|
+
resolvedBy: string | null;
|
|
155
|
+
resolvedAt: string | null;
|
|
156
|
+
assignee: RedlineAssignee | null;
|
|
157
|
+
/** Member ids mentioned (synced reviews). */
|
|
158
|
+
mentions?: string[];
|
|
159
|
+
assignedAt: string | null;
|
|
160
|
+
replies: RedlineReply[];
|
|
161
|
+
createdAt: string;
|
|
162
|
+
updatedAt: string;
|
|
163
|
+
editedAt: string | null;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface RedlineSyncState {
|
|
167
|
+
state: 'local' | 'idle' | 'pending' | 'offline' | 'error';
|
|
168
|
+
pending: number;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export interface FeedbackExport {
|
|
172
|
+
annotate: string;
|
|
173
|
+
schema: 2;
|
|
174
|
+
kind: 'annotate-export';
|
|
175
|
+
exportedAt: string;
|
|
176
|
+
page: string;
|
|
177
|
+
url: string;
|
|
178
|
+
project: string;
|
|
179
|
+
exportedViewport: { vw: number; vh: number; dpr: number };
|
|
180
|
+
/** "site" when the file holds every page of the project; absent for a page export. */
|
|
181
|
+
scope?: 'site';
|
|
182
|
+
comments: RedlineComment[];
|
|
183
|
+
/** Set when the body was POSTed to postUrl; the same value on every retry of one submit. */
|
|
184
|
+
deliveryId?: string;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export interface RedlineAPI {
|
|
188
|
+
readonly version: string;
|
|
189
|
+
readonly config: ResolvedRedlineConfig | null;
|
|
190
|
+
init(config?: RedlineConfig): RedlineAPI;
|
|
191
|
+
destroy(): void;
|
|
192
|
+
open(): void;
|
|
193
|
+
close(): void;
|
|
194
|
+
toggle(): void;
|
|
195
|
+
enable(): void;
|
|
196
|
+
disable(): void;
|
|
197
|
+
setTool(tool: 'cursor' | 'highlight' | 'rect' | 'circle' | 'pen' | 'pin'): void;
|
|
198
|
+
refresh(): void;
|
|
199
|
+
comments(): RedlineComment[];
|
|
200
|
+
focus(id: string): void;
|
|
201
|
+
toast(message: string, options?: { kind?: 'info' | 'error' | 'success'; duration?: number }): void;
|
|
202
|
+
/** Download this page's comments, or every page's with { scope: 'site' } (local mode). */
|
|
203
|
+
export(options?: { scope?: 'page' | 'site' }): void;
|
|
204
|
+
import(): void;
|
|
205
|
+
/**
|
|
206
|
+
* Local mode: sends the current page's export JSON to postUrl; rejects on failure.
|
|
207
|
+
* In a synced review: resolves once every queued change is acknowledged by the backend
|
|
208
|
+
* (then also POSTs to postUrl when set).
|
|
209
|
+
*/
|
|
210
|
+
submit(): Promise<FeedbackExport>;
|
|
211
|
+
/** Moves a comment through its lifecycle. The creator and review authors may do this. */
|
|
212
|
+
setStatus(id: string, status: RedlineStatus): RedlineComment | null;
|
|
213
|
+
/** Assigns a comment to someone, or clears the assignee with null. Review authors only; the backend rejects a reviewer's change. */
|
|
214
|
+
assign(id: string, assignee: RedlineAssignee | null): RedlineComment | null;
|
|
215
|
+
/** Remote sync status; "local" when no backend is configured. */
|
|
216
|
+
syncState(): RedlineSyncState;
|
|
217
|
+
/** Markdown made for AI coding agents. "" when no comment qualifies. */
|
|
218
|
+
markdown(options?: RedlineMarkdownOptions): string;
|
|
219
|
+
/** Copies Markdown (default) or the JSON export to the clipboard. */
|
|
220
|
+
copy(options?: RedlineCopyOptions): Promise<void>;
|
|
221
|
+
/** Pauses page animations, transitions and media while reviewers comment. Refused (returns false) while the tools are hidden. Returns the new state. */
|
|
222
|
+
setFrozen(on: boolean): boolean;
|
|
223
|
+
/** Whether motion is currently frozen. */
|
|
224
|
+
isFrozen(): boolean;
|
|
225
|
+
/** Local mode: removes this page's comments. In a synced review: removes only your own. */
|
|
226
|
+
clear(): void;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
declare const Redline: RedlineAPI;
|
|
230
|
+
export function init(config?: RedlineConfig): RedlineAPI;
|
|
231
|
+
export function destroy(): void;
|
|
232
|
+
export default Redline;
|
|
233
|
+
|
|
234
|
+
export interface RedlineEventMap {
|
|
235
|
+
'annotate:sync': CustomEvent<RedlineSyncState>;
|
|
236
|
+
'annotate:freeze': CustomEvent<{ frozen: boolean }>;
|
|
237
|
+
'annotate:auth': CustomEvent<{ reviewer: { id: string; name: string; role: 'reviewer' | 'author' } | null }>;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// annotate.js's type names, kept as aliases so code written for it compiles.
|
|
241
|
+
/** @deprecated Use {@link RedlineAPI}. */
|
|
242
|
+
export type AnnotateAPI = RedlineAPI;
|
|
243
|
+
/** @deprecated Use {@link RedlineAssignee}. */
|
|
244
|
+
export type AnnotateAssignee = RedlineAssignee;
|
|
245
|
+
/** @deprecated Use {@link RedlineComment}. */
|
|
246
|
+
export type AnnotateComment = RedlineComment;
|
|
247
|
+
/** @deprecated Use {@link RedlineConfig}. */
|
|
248
|
+
export type AnnotateConfig = RedlineConfig;
|
|
249
|
+
/** @deprecated Use {@link RedlineCopyOptions}. */
|
|
250
|
+
export type AnnotateCopyOptions = RedlineCopyOptions;
|
|
251
|
+
/** @deprecated Use {@link RedlineEventMap}. */
|
|
252
|
+
export type AnnotateEventMap = RedlineEventMap;
|
|
253
|
+
/** @deprecated Use {@link RedlineGeom}. */
|
|
254
|
+
export type AnnotateGeom = RedlineGeom;
|
|
255
|
+
/** @deprecated Use {@link RedlineMarkdownOptions}. */
|
|
256
|
+
export type AnnotateMarkdownOptions = RedlineMarkdownOptions;
|
|
257
|
+
/** @deprecated Use {@link RedlineReply}. */
|
|
258
|
+
export type AnnotateReply = RedlineReply;
|
|
259
|
+
/** @deprecated Use {@link RedlineStatus}. */
|
|
260
|
+
export type AnnotateStatus = RedlineStatus;
|
|
261
|
+
/** @deprecated Use {@link RedlineStyleKey}. */
|
|
262
|
+
export type AnnotateStyleKey = RedlineStyleKey;
|
|
263
|
+
/** @deprecated Use {@link RedlineSyncState}. */
|
|
264
|
+
export type AnnotateSyncState = RedlineSyncState;
|
|
265
|
+
/** @deprecated Use {@link RedlineTarget}. */
|
|
266
|
+
export type AnnotateTarget = RedlineTarget;
|
|
267
|
+
/** @deprecated Use {@link ResolvedRedlineConfig}. */
|
|
268
|
+
export type ResolvedAnnotateConfig = ResolvedRedlineConfig;
|
|
269
|
+
|
|
270
|
+
declare global {
|
|
271
|
+
interface WindowEventMap extends RedlineEventMap {}
|
|
272
|
+
interface Window {
|
|
273
|
+
Redline?: RedlineAPI;
|
|
274
|
+
RedlineConfig?: RedlineConfig;
|
|
275
|
+
/** @deprecated annotate.js's name; the same object as window.Redline. */
|
|
276
|
+
Annotate?: RedlineAPI;
|
|
277
|
+
/** @deprecated annotate.js's name; use window.RedlineConfig. */
|
|
278
|
+
AnnotateConfig?: RedlineConfig;
|
|
279
|
+
}
|
|
280
|
+
}
|
package/redline.d.ts
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
export interface RedlineConfig {
|
|
2
|
+
/** Storage namespace shared by pages in one project. */
|
|
3
|
+
project?: string;
|
|
4
|
+
/** Fixed page key. By default Redline follows location.pathname. */
|
|
5
|
+
page?: string;
|
|
6
|
+
accent?: string;
|
|
7
|
+
theme?: 'auto' | 'light' | 'dark';
|
|
8
|
+
position?: 'bottom-right' | 'bottom-left';
|
|
9
|
+
blocks?: string;
|
|
10
|
+
startOpen?: boolean;
|
|
11
|
+
note?: string;
|
|
12
|
+
/** Email address or issue URL template. {page}, {count}, {summary} are URL encoded. */
|
|
13
|
+
shareEmail?: string;
|
|
14
|
+
/** Watch History API navigation and popstate. */
|
|
15
|
+
spa?: boolean;
|
|
16
|
+
/** HTTP endpoint receiving the JSON export on an explicit Send feedback action. */
|
|
17
|
+
postUrl?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Retries for postUrl, 0 to 5, default 3, on network errors, timeouts, 408,
|
|
20
|
+
* 429 and 5xx. Waits 1 s, 2 s, 4 s…, or the receiver's Retry-After (up to 30 s)
|
|
21
|
+
* when the browser can read it.
|
|
22
|
+
*/
|
|
23
|
+
postRetries?: number;
|
|
24
|
+
/** Redline Cloud review to sync with, or "local" for the coding agent's redline-mcp (localhost and 127.0.0.1 pages only). */
|
|
25
|
+
reviewId?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Redline Cloud workspace id (ws_…). The Cloud names the review this site
|
|
28
|
+
* uses in the workspace; reviewId, when set, pins the page instead.
|
|
29
|
+
*/
|
|
30
|
+
workspace?: string;
|
|
31
|
+
/** Query parameter carrying the invite token. Default "an_invite". */
|
|
32
|
+
inviteParam?: string;
|
|
33
|
+
/** Poll interval in milliseconds for remote reads. Default 20000, minimum 500. */
|
|
34
|
+
pollInterval?: number;
|
|
35
|
+
/** Fetch credentials mode for postUrl requests. Default "omit". Requests to Redline Cloud and the local agent never carry cookies. */
|
|
36
|
+
credentials?: 'omit' | 'same-origin' | 'include';
|
|
37
|
+
/**
|
|
38
|
+
* Extras each new comment records besides the element description:
|
|
39
|
+
* "styles", "components", both comma-separated (default), or "off".
|
|
40
|
+
*/
|
|
41
|
+
capture?: string | Array<'styles' | 'components'>;
|
|
42
|
+
/**
|
|
43
|
+
* "Open in editor" link template. {path}, {line}, {column} come from the
|
|
44
|
+
* comment's component source, e.g. "vscode://file/Users/me/app/{path}:{line}".
|
|
45
|
+
*/
|
|
46
|
+
editorUrl?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ResolvedRedlineConfig {
|
|
50
|
+
project: string;
|
|
51
|
+
page: string;
|
|
52
|
+
accent: string;
|
|
53
|
+
theme: 'auto' | 'light' | 'dark';
|
|
54
|
+
position: 'bottom-right' | 'bottom-left';
|
|
55
|
+
blocks: string;
|
|
56
|
+
startOpen: boolean;
|
|
57
|
+
note: string;
|
|
58
|
+
share: string;
|
|
59
|
+
spa: boolean;
|
|
60
|
+
postUrl: string;
|
|
61
|
+
postRetries: number;
|
|
62
|
+
reviewId: string;
|
|
63
|
+
workspace: string;
|
|
64
|
+
inviteParam: string;
|
|
65
|
+
pollInterval: number;
|
|
66
|
+
credentials: 'omit' | 'same-origin' | 'include';
|
|
67
|
+
capture: 'styles,components' | 'styles' | 'components' | 'off';
|
|
68
|
+
editorUrl: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type RedlineStatus = 'open' | 'in_progress' | 'resolved' | 'wont_fix';
|
|
72
|
+
|
|
73
|
+
export type RedlineGeom =
|
|
74
|
+
| { kind: 'rect' | 'circle'; selector: string; x: number; y: number; w: number; h: number; vw?: number; vh?: number }
|
|
75
|
+
| { kind: 'pin'; selector?: string; x: number; y: number; vw?: number; vh?: number }
|
|
76
|
+
| { kind: 'pen'; selector: string; points: Array<[number, number]>; vw?: number; vh?: number }
|
|
77
|
+
| { kind: 'block'; selector: string }
|
|
78
|
+
| { kind: 'group'; selectors: string[]; vw?: number; vh?: number };
|
|
79
|
+
|
|
80
|
+
export interface RedlineAssignee {
|
|
81
|
+
id: string | null;
|
|
82
|
+
name: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface RedlineReply {
|
|
86
|
+
id: string;
|
|
87
|
+
author: string;
|
|
88
|
+
authorId: string | null;
|
|
89
|
+
text: string;
|
|
90
|
+
createdAt: string;
|
|
91
|
+
editedAt: string | null;
|
|
92
|
+
/** Member ids mentioned (synced reviews). */
|
|
93
|
+
mentions?: string[];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export type RedlineStyleKey =
|
|
97
|
+
| 'display' | 'position' | 'width' | 'height' | 'margin' | 'padding' | 'gap' | 'font-family' | 'font-size'
|
|
98
|
+
| 'font-weight' | 'line-height' | 'color' | 'background-color' | 'border' | 'border-radius' | 'box-shadow'
|
|
99
|
+
| 'opacity' | 'object-fit';
|
|
100
|
+
|
|
101
|
+
/** The element a comment is about, recorded once when it is made (1.6+). */
|
|
102
|
+
export interface RedlineTarget {
|
|
103
|
+
label: string;
|
|
104
|
+
tag: string;
|
|
105
|
+
role: string | null;
|
|
106
|
+
name: string | null;
|
|
107
|
+
id: string | null;
|
|
108
|
+
testId: string | null;
|
|
109
|
+
classes: string[];
|
|
110
|
+
selector: string;
|
|
111
|
+
heading: string | null;
|
|
112
|
+
box: { x: number; y: number; w: number; h: number };
|
|
113
|
+
styles: Partial<Record<RedlineStyleKey, string>> | null;
|
|
114
|
+
component: { framework: 'react' | 'vue' | 'svelte'; chain: string[]; source: string | null } | null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface RedlineMarkdownOptions {
|
|
118
|
+
detail?: 'compact' | 'standard' | 'detailed';
|
|
119
|
+
scope?: 'page' | 'site';
|
|
120
|
+
/** Include resolved and won't-fix comments. Default false. */
|
|
121
|
+
includeClosed?: boolean;
|
|
122
|
+
/** Only these comment ids. */
|
|
123
|
+
ids?: string[];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface RedlineCopyOptions {
|
|
127
|
+
format?: 'markdown' | 'json';
|
|
128
|
+
detail?: 'compact' | 'standard' | 'detailed';
|
|
129
|
+
scope?: 'page' | 'site';
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Record schema v2 (docs/backlog/wire-protocol.md). */
|
|
133
|
+
export interface RedlineComment {
|
|
134
|
+
schema: 2;
|
|
135
|
+
id: string;
|
|
136
|
+
page: string;
|
|
137
|
+
url: string;
|
|
138
|
+
type: 'highlight' | 'shape' | 'pin' | 'pen' | 'note' | 'block' | 'group';
|
|
139
|
+
author: string;
|
|
140
|
+
authorId: string | null;
|
|
141
|
+
text: string;
|
|
142
|
+
color: string;
|
|
143
|
+
anchor: { exact: string; prefix: string; suffix: string } | null;
|
|
144
|
+
geom: RedlineGeom | null;
|
|
145
|
+
/** Absent on comments made before 1.6 or where nothing could be described. */
|
|
146
|
+
target?: RedlineTarget;
|
|
147
|
+
/** Group comments only: one entry per `geom.selectors` item, `null` where nothing could be described. Create-only. */
|
|
148
|
+
targets?: (RedlineTarget | null)[];
|
|
149
|
+
visibility: 'shared' | 'private';
|
|
150
|
+
status: RedlineStatus;
|
|
151
|
+
/** Derived: true when status is "resolved" or "wont_fix". */
|
|
152
|
+
resolved: boolean;
|
|
153
|
+
resolvedBy: string | null;
|
|
154
|
+
resolvedAt: string | null;
|
|
155
|
+
assignee: RedlineAssignee | null;
|
|
156
|
+
/** Member ids mentioned (synced reviews). */
|
|
157
|
+
mentions?: string[];
|
|
158
|
+
assignedAt: string | null;
|
|
159
|
+
replies: RedlineReply[];
|
|
160
|
+
createdAt: string;
|
|
161
|
+
updatedAt: string;
|
|
162
|
+
editedAt: string | null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface RedlineSyncState {
|
|
166
|
+
state: 'local' | 'idle' | 'pending' | 'offline' | 'error';
|
|
167
|
+
pending: number;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export interface FeedbackExport {
|
|
171
|
+
annotate: string;
|
|
172
|
+
schema: 2;
|
|
173
|
+
kind: 'annotate-export';
|
|
174
|
+
exportedAt: string;
|
|
175
|
+
page: string;
|
|
176
|
+
url: string;
|
|
177
|
+
project: string;
|
|
178
|
+
exportedViewport: { vw: number; vh: number; dpr: number };
|
|
179
|
+
/** "site" when the file holds every page of the project; absent for a page export. */
|
|
180
|
+
scope?: 'site';
|
|
181
|
+
comments: RedlineComment[];
|
|
182
|
+
/** Set when the body was POSTed to postUrl; the same value on every retry of one submit. */
|
|
183
|
+
deliveryId?: string;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface RedlineAPI {
|
|
187
|
+
readonly version: string;
|
|
188
|
+
readonly config: ResolvedRedlineConfig | null;
|
|
189
|
+
init(config?: RedlineConfig): RedlineAPI;
|
|
190
|
+
destroy(): void;
|
|
191
|
+
open(): void;
|
|
192
|
+
close(): void;
|
|
193
|
+
toggle(): void;
|
|
194
|
+
enable(): void;
|
|
195
|
+
disable(): void;
|
|
196
|
+
setTool(tool: 'cursor' | 'highlight' | 'rect' | 'circle' | 'pen' | 'pin'): void;
|
|
197
|
+
refresh(): void;
|
|
198
|
+
comments(): RedlineComment[];
|
|
199
|
+
focus(id: string): void;
|
|
200
|
+
toast(message: string, options?: { kind?: 'info' | 'error' | 'success'; duration?: number }): void;
|
|
201
|
+
/** Download this page's comments, or every page's with { scope: 'site' } (local mode). */
|
|
202
|
+
export(options?: { scope?: 'page' | 'site' }): void;
|
|
203
|
+
import(): void;
|
|
204
|
+
/**
|
|
205
|
+
* Local mode: sends the current page's export JSON to postUrl; rejects on failure.
|
|
206
|
+
* In a synced review: resolves once every queued change is acknowledged by the backend
|
|
207
|
+
* (then also POSTs to postUrl when set).
|
|
208
|
+
*/
|
|
209
|
+
submit(): Promise<FeedbackExport>;
|
|
210
|
+
/** Moves a comment through its lifecycle. The creator and review authors may do this. */
|
|
211
|
+
setStatus(id: string, status: RedlineStatus): RedlineComment | null;
|
|
212
|
+
/** Assigns a comment to someone, or clears the assignee with null. Review authors only; the backend rejects a reviewer's change. */
|
|
213
|
+
assign(id: string, assignee: RedlineAssignee | null): RedlineComment | null;
|
|
214
|
+
/** Remote sync status; "local" when no backend is configured. */
|
|
215
|
+
syncState(): RedlineSyncState;
|
|
216
|
+
/** Markdown made for AI coding agents. "" when no comment qualifies. */
|
|
217
|
+
markdown(options?: RedlineMarkdownOptions): string;
|
|
218
|
+
/** Copies Markdown (default) or the JSON export to the clipboard. */
|
|
219
|
+
copy(options?: RedlineCopyOptions): Promise<void>;
|
|
220
|
+
/** Pauses page animations, transitions and media while reviewers comment. Refused (returns false) while the tools are hidden. Returns the new state. */
|
|
221
|
+
setFrozen(on: boolean): boolean;
|
|
222
|
+
/** Whether motion is currently frozen. */
|
|
223
|
+
isFrozen(): boolean;
|
|
224
|
+
/** Local mode: removes this page's comments. In a synced review: removes only your own. */
|
|
225
|
+
clear(): void;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
declare const Redline: RedlineAPI;
|
|
229
|
+
export function init(config?: RedlineConfig): RedlineAPI;
|
|
230
|
+
export function destroy(): void;
|
|
231
|
+
export default Redline;
|
|
232
|
+
|
|
233
|
+
export interface RedlineEventMap {
|
|
234
|
+
'annotate:sync': CustomEvent<RedlineSyncState>;
|
|
235
|
+
'annotate:freeze': CustomEvent<{ frozen: boolean }>;
|
|
236
|
+
'annotate:auth': CustomEvent<{ reviewer: { id: string; name: string; role: 'reviewer' | 'author' } | null }>;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// annotate.js's type names, kept as aliases so code written for it compiles.
|
|
240
|
+
/** @deprecated Use {@link RedlineAPI}. */
|
|
241
|
+
export type AnnotateAPI = RedlineAPI;
|
|
242
|
+
/** @deprecated Use {@link RedlineAssignee}. */
|
|
243
|
+
export type AnnotateAssignee = RedlineAssignee;
|
|
244
|
+
/** @deprecated Use {@link RedlineComment}. */
|
|
245
|
+
export type AnnotateComment = RedlineComment;
|
|
246
|
+
/** @deprecated Use {@link RedlineConfig}. */
|
|
247
|
+
export type AnnotateConfig = RedlineConfig;
|
|
248
|
+
/** @deprecated Use {@link RedlineCopyOptions}. */
|
|
249
|
+
export type AnnotateCopyOptions = RedlineCopyOptions;
|
|
250
|
+
/** @deprecated Use {@link RedlineEventMap}. */
|
|
251
|
+
export type AnnotateEventMap = RedlineEventMap;
|
|
252
|
+
/** @deprecated Use {@link RedlineGeom}. */
|
|
253
|
+
export type AnnotateGeom = RedlineGeom;
|
|
254
|
+
/** @deprecated Use {@link RedlineMarkdownOptions}. */
|
|
255
|
+
export type AnnotateMarkdownOptions = RedlineMarkdownOptions;
|
|
256
|
+
/** @deprecated Use {@link RedlineReply}. */
|
|
257
|
+
export type AnnotateReply = RedlineReply;
|
|
258
|
+
/** @deprecated Use {@link RedlineStatus}. */
|
|
259
|
+
export type AnnotateStatus = RedlineStatus;
|
|
260
|
+
/** @deprecated Use {@link RedlineStyleKey}. */
|
|
261
|
+
export type AnnotateStyleKey = RedlineStyleKey;
|
|
262
|
+
/** @deprecated Use {@link RedlineSyncState}. */
|
|
263
|
+
export type AnnotateSyncState = RedlineSyncState;
|
|
264
|
+
/** @deprecated Use {@link RedlineTarget}. */
|
|
265
|
+
export type AnnotateTarget = RedlineTarget;
|
|
266
|
+
/** @deprecated Use {@link ResolvedRedlineConfig}. */
|
|
267
|
+
export type ResolvedAnnotateConfig = ResolvedRedlineConfig;
|
|
268
|
+
|
|
269
|
+
declare global {
|
|
270
|
+
interface WindowEventMap extends RedlineEventMap {}
|
|
271
|
+
interface Window {
|
|
272
|
+
Redline?: RedlineAPI;
|
|
273
|
+
RedlineConfig?: RedlineConfig;
|
|
274
|
+
/** @deprecated annotate.js's name; the same object as window.Redline. */
|
|
275
|
+
Annotate?: RedlineAPI;
|
|
276
|
+
/** @deprecated annotate.js's name; use window.RedlineConfig. */
|
|
277
|
+
AnnotateConfig?: RedlineConfig;
|
|
278
|
+
}
|
|
279
|
+
}
|