@devaccel-labs/app-comments-toolbar 1.1.0 → 1.3.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 +148 -30
- package/dist/react.js +417 -64
- package/dist/server.js +342 -14
- package/dist/types/capture/api.d.ts +30 -0
- package/dist/types/capture/editor.d.ts +10 -0
- package/dist/types/capture/ignore.d.ts +19 -0
- package/dist/types/capture/index.d.ts +1 -0
- package/dist/types/capture/picker.d.ts +9 -0
- package/dist/types/capture/picture.d.ts +29 -0
- package/dist/types/capture/surface.d.ts +39 -0
- package/dist/types/core/index.d.ts +2 -2
- package/dist/types/core/resolve.d.ts +2 -1
- package/dist/types/core/types.d.ts +11 -0
- package/dist/types/debug-context.d.ts +7 -0
- package/dist/types/dictation.d.ts +9 -0
- package/dist/types/embed/controller.d.ts +61 -0
- package/dist/types/embed/index.d.ts +1 -0
- package/dist/types/embed/options.d.ts +35 -0
- package/dist/types/help/index.d.ts +1 -0
- package/dist/types/help/panel-index.d.ts +1 -0
- package/dist/types/help/panel-styles.d.ts +1 -0
- package/dist/types/help/panel.d.ts +4 -0
- package/dist/types/help/pill-styles.d.ts +11 -0
- package/dist/types/help/pill.d.ts +44 -0
- package/dist/types/help/react.d.ts +12 -0
- package/dist/types/help/requests.d.ts +2 -0
- package/dist/types/help/types.d.ts +119 -0
- package/dist/types/help/wire.d.ts +61 -0
- package/dist/types/native-wire.d.ts +63 -0
- package/dist/types/native.d.ts +43 -0
- package/dist/types/react.d.ts +7 -0
- package/dist/types/replay.d.ts +6 -0
- package/dist/types/runtime/api.d.ts +250 -0
- package/dist/types/runtime/attachment-model.d.ts +16 -0
- package/dist/types/runtime/attachments.d.ts +43 -7
- package/dist/types/runtime/boot.d.ts +39 -0
- package/dist/types/runtime/browser-label.d.ts +5 -0
- package/dist/types/runtime/build-id.d.ts +1 -0
- package/dist/types/runtime/capture-ui.d.ts +45 -21
- package/dist/types/runtime/clarity-model.d.ts +260 -0
- package/dist/types/runtime/clarity-ui.d.ts +62 -0
- package/dist/types/runtime/client.d.ts +6 -197
- package/dist/types/runtime/composer-size.d.ts +30 -0
- package/dist/types/runtime/dashboard.d.ts +17 -2
- package/dist/types/runtime/debug-context-core.d.ts +88 -0
- package/dist/types/runtime/debug-context-host.d.ts +39 -0
- package/dist/types/runtime/debug-context-model.d.ts +352 -0
- package/dist/types/runtime/debug-context-redact.d.ts +48 -0
- package/dist/types/runtime/debug-context.d.ts +36 -0
- package/dist/types/runtime/details-model.d.ts +7 -0
- package/dist/types/runtime/details.d.ts +7 -5
- package/dist/types/runtime/dictation-engine.d.ts +98 -0
- package/dist/types/runtime/dictation-model.d.ts +28 -0
- package/dist/types/runtime/dictation-ui.d.ts +56 -0
- package/dist/types/runtime/dictation.d.ts +66 -0
- package/dist/types/runtime/draft-dock.d.ts +32 -0
- package/dist/types/runtime/draft-model.d.ts +104 -0
- package/dist/types/runtime/draft-store.d.ts +15 -0
- package/dist/types/runtime/edits.d.ts +1 -1
- package/dist/types/runtime/font.d.ts +16 -0
- package/dist/types/runtime/format.d.ts +30 -1
- package/dist/types/runtime/host-watch.d.ts +20 -0
- package/dist/types/runtime/icons.d.ts +16 -2
- package/dist/types/runtime/index.d.ts +2 -0
- package/dist/types/runtime/ink.d.ts +8 -0
- package/dist/types/runtime/kind-model.d.ts +14 -0
- package/dist/types/runtime/live-model.d.ts +25 -0
- package/dist/types/runtime/loader.d.ts +5 -3
- package/dist/types/runtime/markup-editor.d.ts +54 -0
- package/dist/types/runtime/markup-model.d.ts +126 -0
- package/dist/types/runtime/markup.d.ts +69 -0
- package/dist/types/runtime/mention-parse.d.ts +18 -0
- package/dist/types/runtime/mentions.d.ts +4 -4
- package/dist/types/runtime/page-background.d.ts +9 -0
- package/dist/types/runtime/page-image.d.ts +64 -11
- package/dist/types/runtime/placement.d.ts +6 -3
- package/dist/types/runtime/record.d.ts +18 -2
- package/dist/types/runtime/related.d.ts +1 -1
- package/dist/types/runtime/replay-model.d.ts +80 -0
- package/dist/types/runtime/replay.d.ts +5 -38
- package/dist/types/runtime/screen.d.ts +47 -0
- package/dist/types/runtime/screenshot.d.ts +60 -8
- package/dist/types/runtime/session-source.d.ts +45 -0
- package/dist/types/runtime/session.d.ts +20 -18
- package/dist/types/runtime/shield.d.ts +9 -0
- package/dist/types/runtime/shot.d.ts +45 -0
- package/dist/types/runtime/sketch.d.ts +26 -0
- package/dist/types/runtime/styles.d.ts +1 -1
- package/dist/types/runtime/sync.d.ts +1 -0
- package/dist/types/runtime/thread-model.d.ts +18 -0
- package/dist/types/runtime/ticket-form-model.d.ts +57 -0
- package/dist/types/runtime/ticket-form.d.ts +9 -0
- package/dist/types/runtime/toolbar.d.ts +37 -1
- package/dist/types/runtime/ui-scale.d.ts +17 -0
- package/dist/types/runtime/update.d.ts +32 -8
- package/dist/types/runtime/use-debug-context.d.ts +27 -0
- package/dist/types/server/index.d.ts +22 -0
- package/dist/types/server/support.d.ts +20 -0
- package/dist/types/server.d.ts +2 -0
- package/dist/types/vite/plugin.d.ts +15 -0
- package/dist/vite.js +121 -41
- package/package.json +24 -11
- package/src/capture/api.ts +128 -0
- package/src/capture/editor.tsx +178 -0
- package/src/capture/ignore.ts +38 -0
- package/src/capture/index.ts +27 -0
- package/src/capture/picker.tsx +171 -0
- package/src/capture/picture.ts +90 -0
- package/src/capture/surface.tsx +185 -0
- package/src/compiler/annotate.ts +202 -0
- package/src/compiler/babel.d.ts +11 -0
- package/src/compiler/enabled.ts +55 -0
- package/src/compiler/index.ts +2 -0
- package/src/core/index.ts +8 -0
- package/src/core/resolve.ts +307 -0
- package/src/core/types.ts +58 -0
- package/src/debug-context.ts +47 -0
- package/src/dictation.ts +17 -0
- package/src/embed/controller.ts +215 -0
- package/src/embed/index.ts +68 -0
- package/src/embed/options.ts +100 -0
- package/src/help/index.ts +38 -0
- package/src/help/panel-index.ts +17 -0
- package/src/help/panel-styles.ts +123 -0
- package/src/help/panel.ts +840 -0
- package/src/help/pill-styles.ts +75 -0
- package/src/help/pill.ts +338 -0
- package/src/help/react.tsx +143 -0
- package/src/help/requests.ts +111 -0
- package/src/help/types.ts +124 -0
- package/src/help/wire.ts +55 -0
- package/src/native-wire.ts +124 -0
- package/src/native.ts +282 -0
- package/src/react.ts +27 -0
- package/src/replay.ts +13 -0
- package/src/runtime/api.ts +531 -0
- package/src/runtime/attachment-model.ts +42 -0
- package/src/runtime/attachments.tsx +1260 -0
- package/src/runtime/boot.ts +95 -0
- package/src/runtime/browser-label.ts +31 -0
- package/src/runtime/build-id.ts +10 -0
- package/src/runtime/capture-ui.tsx +306 -0
- package/src/runtime/capture.ts +508 -0
- package/src/runtime/clarity-model.ts +634 -0
- package/src/runtime/clarity-ui.tsx +454 -0
- package/src/runtime/client.ts +151 -0
- package/src/runtime/composer-size.tsx +146 -0
- package/src/runtime/dashboard.tsx +1130 -0
- package/src/runtime/debug-context-core.ts +681 -0
- package/src/runtime/debug-context-host.ts +56 -0
- package/src/runtime/debug-context-model.ts +1319 -0
- package/src/runtime/debug-context-redact.ts +259 -0
- package/src/runtime/debug-context.ts +613 -0
- package/src/runtime/details-model.ts +30 -0
- package/src/runtime/details.tsx +395 -0
- package/src/runtime/dictation-engine.ts +616 -0
- package/src/runtime/dictation-model.ts +79 -0
- package/src/runtime/dictation-ui.tsx +363 -0
- package/src/runtime/dictation.ts +271 -0
- package/src/runtime/dock.ts +108 -0
- package/src/runtime/draft-dock.tsx +124 -0
- package/src/runtime/draft-model.ts +251 -0
- package/src/runtime/draft-store.ts +149 -0
- package/src/runtime/edits.tsx +165 -0
- package/src/runtime/font.ts +42 -0
- package/src/runtime/format.ts +129 -0
- package/src/runtime/freshness.ts +23 -0
- package/src/runtime/handoff.ts +76 -0
- package/src/runtime/host-watch.ts +64 -0
- package/src/runtime/icons.tsx +295 -0
- package/src/runtime/idle.ts +20 -0
- package/src/runtime/index.ts +11 -0
- package/src/runtime/ink.ts +6 -0
- package/src/runtime/kind-model.ts +20 -0
- package/src/runtime/live-model.ts +32 -0
- package/src/runtime/loader.tsx +87 -0
- package/src/runtime/markup-editor.tsx +1333 -0
- package/src/runtime/markup-model.ts +485 -0
- package/src/runtime/markup.ts +382 -0
- package/src/runtime/members.ts +58 -0
- package/src/runtime/mention-parse.ts +56 -0
- package/src/runtime/mentions.tsx +205 -0
- package/src/runtime/page-background.ts +51 -0
- package/src/runtime/page-image.ts +1592 -0
- package/src/runtime/placement.ts +336 -0
- package/src/runtime/record.ts +402 -0
- package/src/runtime/redact.ts +30 -0
- package/src/runtime/related.ts +34 -0
- package/src/runtime/render-page.ts +2 -0
- package/src/runtime/replay-model.ts +232 -0
- package/src/runtime/replay.ts +173 -0
- package/src/runtime/runtime-version.ts +7 -0
- package/src/runtime/runtime.tsx +51 -0
- package/src/runtime/screen.ts +182 -0
- package/src/runtime/screenshot.ts +260 -0
- package/src/runtime/session-source.ts +112 -0
- package/src/runtime/session.ts +108 -0
- package/src/runtime/shield.ts +34 -0
- package/src/runtime/shot.tsx +422 -0
- package/src/runtime/sketch.ts +139 -0
- package/src/runtime/styles.ts +1541 -0
- package/src/runtime/sync.ts +300 -0
- package/src/runtime/thread-model.ts +71 -0
- package/src/runtime/ticket-form-model.ts +128 -0
- package/src/runtime/ticket-form.tsx +342 -0
- package/src/runtime/toolbar.tsx +4427 -0
- package/src/runtime/ui-scale.ts +75 -0
- package/src/runtime/update.ts +98 -0
- package/src/runtime/use-debug-context.ts +81 -0
- package/src/server/index.ts +133 -0
- package/src/server/support.ts +499 -0
- package/src/server.ts +4 -0
- package/src/vite/plugin.ts +102 -0
- package/src/vite.ts +1 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { useEffect, useLayoutEffect, useRef, type KeyboardEvent } from "react";
|
|
2
|
+
|
|
3
|
+
/** The composer's size the person dragged it to. Kept in the toolbar prefs, so every new comment opens at it. */
|
|
4
|
+
export type ComposerSize = { width: number; height: number };
|
|
5
|
+
|
|
6
|
+
/** The composer's own width; it never gets narrower than it is by default. */
|
|
7
|
+
export const COMPOSER_MIN_WIDTH = 240;
|
|
8
|
+
export const COMPOSER_MIN_HEIGHT = 100;
|
|
9
|
+
export const COMPOSER_MAX_WIDTH = 720;
|
|
10
|
+
const KEY_STEP = 16;
|
|
11
|
+
const MARGIN = 6;
|
|
12
|
+
|
|
13
|
+
export function clampComposerSize(
|
|
14
|
+
size: ComposerSize,
|
|
15
|
+
room: { width: number; height: number },
|
|
16
|
+
): ComposerSize {
|
|
17
|
+
const maxWidth = Math.max(
|
|
18
|
+
COMPOSER_MIN_WIDTH,
|
|
19
|
+
Math.min(COMPOSER_MAX_WIDTH, room.width - MARGIN * 2),
|
|
20
|
+
);
|
|
21
|
+
const maxHeight = Math.max(COMPOSER_MIN_HEIGHT, room.height - MARGIN * 2);
|
|
22
|
+
return {
|
|
23
|
+
width: Math.round(Math.max(COMPOSER_MIN_WIDTH, Math.min(maxWidth, size.width))),
|
|
24
|
+
height: Math.round(Math.max(COMPOSER_MIN_HEIGHT, Math.min(maxHeight, size.height))),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** A saved size, or nothing when the stored value is missing or malformed. */
|
|
29
|
+
export function readComposerSize(value: unknown): ComposerSize | undefined {
|
|
30
|
+
if (typeof value !== "object" || value === null) return undefined;
|
|
31
|
+
const width: unknown = Reflect.get(value, "width");
|
|
32
|
+
const height: unknown = Reflect.get(value, "height");
|
|
33
|
+
if (typeof width !== "number" || typeof height !== "number") return undefined;
|
|
34
|
+
if (!Number.isFinite(width) || !Number.isFinite(height)) return undefined;
|
|
35
|
+
return { width, height };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function cardSize(grip: HTMLElement): ComposerSize | null {
|
|
39
|
+
const card = grip.parentElement;
|
|
40
|
+
return card ? { width: card.offsetWidth, height: card.offsetHeight } : null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The composer's resize handle, in its bottom-right corner. Dragging right widens it and dragging down makes it
|
|
45
|
+
* taller (the top stays put); arrow keys do the same in steps; a double-click goes back to the default.
|
|
46
|
+
*/
|
|
47
|
+
export function ResizeGrip(props: {
|
|
48
|
+
room: () => { width: number; height: number };
|
|
49
|
+
/** Every step of a drag. */
|
|
50
|
+
onResize: (size: ComposerSize) => void;
|
|
51
|
+
/** The drag ended (or a key was pressed) at `size`: save it. Not called for a press that didn't move. */
|
|
52
|
+
onEnd: (size: ComposerSize) => void;
|
|
53
|
+
onReset: () => void;
|
|
54
|
+
}) {
|
|
55
|
+
const { room, onEnd, onReset } = props;
|
|
56
|
+
const grip = useRef<HTMLSpanElement>(null);
|
|
57
|
+
const latest = useRef(props);
|
|
58
|
+
useLayoutEffect(() => {
|
|
59
|
+
latest.current = props;
|
|
60
|
+
});
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
// The toolbar's shield (`shield.ts`) stops presses at the window in the capture phase, before they reach
|
|
63
|
+
// the grip or React, so the drag is tracked from window capture listeners of its own.
|
|
64
|
+
let drag: {
|
|
65
|
+
pointer: number;
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
from: ComposerSize;
|
|
69
|
+
last: ComposerSize;
|
|
70
|
+
} | null = null;
|
|
71
|
+
const down = (event: PointerEvent) => {
|
|
72
|
+
const node = grip.current;
|
|
73
|
+
if (!node || event.button !== 0 || event.target !== node) return;
|
|
74
|
+
const from = cardSize(node);
|
|
75
|
+
if (!from) return;
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
drag = { pointer: event.pointerId, x: event.clientX, y: event.clientY, from, last: from };
|
|
78
|
+
};
|
|
79
|
+
const move = (event: PointerEvent) => {
|
|
80
|
+
if (!drag || event.pointerId !== drag.pointer) return;
|
|
81
|
+
const size = clampComposerSize(
|
|
82
|
+
{
|
|
83
|
+
width: drag.from.width + event.clientX - drag.x,
|
|
84
|
+
height: drag.from.height + (event.clientY - drag.y),
|
|
85
|
+
},
|
|
86
|
+
latest.current.room(),
|
|
87
|
+
);
|
|
88
|
+
if (size.width === drag.last.width && size.height === drag.last.height) return;
|
|
89
|
+
drag.last = size;
|
|
90
|
+
latest.current.onResize(size);
|
|
91
|
+
};
|
|
92
|
+
const end = (event: PointerEvent) => {
|
|
93
|
+
if (!drag || event.pointerId !== drag.pointer) return;
|
|
94
|
+
const { from, last } = drag;
|
|
95
|
+
drag = null;
|
|
96
|
+
if (last !== from) latest.current.onEnd(last);
|
|
97
|
+
};
|
|
98
|
+
window.addEventListener("pointerdown", down, true);
|
|
99
|
+
window.addEventListener("pointermove", move, true);
|
|
100
|
+
window.addEventListener("pointerup", end, true);
|
|
101
|
+
window.addEventListener("pointercancel", end, true);
|
|
102
|
+
return () => {
|
|
103
|
+
window.removeEventListener("pointerdown", down, true);
|
|
104
|
+
window.removeEventListener("pointermove", move, true);
|
|
105
|
+
window.removeEventListener("pointerup", end, true);
|
|
106
|
+
window.removeEventListener("pointercancel", end, true);
|
|
107
|
+
};
|
|
108
|
+
}, []);
|
|
109
|
+
return (
|
|
110
|
+
<span
|
|
111
|
+
ref={grip}
|
|
112
|
+
className="cs-resize-grip"
|
|
113
|
+
data-cs-ui="composer-resize"
|
|
114
|
+
role="separator"
|
|
115
|
+
aria-orientation="horizontal"
|
|
116
|
+
aria-label="Resize. Drag, or use the arrow keys. Double-click to reset."
|
|
117
|
+
title="Drag to resize · double-click to reset"
|
|
118
|
+
tabIndex={0}
|
|
119
|
+
onDoubleClick={(event) => {
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
onReset();
|
|
122
|
+
}}
|
|
123
|
+
onKeyDown={(event: KeyboardEvent<HTMLSpanElement>) => {
|
|
124
|
+
const delta: Partial<Record<string, [number, number]>> = {
|
|
125
|
+
ArrowRight: [KEY_STEP, 0],
|
|
126
|
+
ArrowLeft: [-KEY_STEP, 0],
|
|
127
|
+
ArrowUp: [0, -KEY_STEP],
|
|
128
|
+
ArrowDown: [0, KEY_STEP],
|
|
129
|
+
};
|
|
130
|
+
if (event.key === "Home") {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
onReset();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const step = delta[event.key];
|
|
136
|
+
const from = step ? cardSize(event.currentTarget) : null;
|
|
137
|
+
if (!step || !from) return;
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
event.stopPropagation();
|
|
140
|
+
onEnd(
|
|
141
|
+
clampComposerSize({ width: from.width + step[0], height: from.height + step[1] }, room()),
|
|
142
|
+
);
|
|
143
|
+
}}
|
|
144
|
+
/>
|
|
145
|
+
);
|
|
146
|
+
}
|