proto-plugin 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +350 -0
- package/README.md +279 -0
- package/components.json +18 -0
- package/package.json +73 -0
- package/scripts/download-mobbin-reference-images.mjs +112 -0
- package/scripts/lib/host-config.example.sh +48 -0
- package/scripts/lib/host-config.sh +25 -0
- package/scripts/lib/resolve-host-root.mjs +18 -0
- package/scripts/lib/source-path.sh +49 -0
- package/scripts/link-source-db.sh +128 -0
- package/scripts/link-source.sh +40 -0
- package/scripts/publish-package.sh +147 -0
- package/scripts/share-prototype.sh +279 -0
- package/scripts/sync-from-source.sh +74 -0
- package/scripts/verify-prototype-component-ids.mjs +151 -0
- package/scripts/verify-prototype-preview-states.mjs +135 -0
- package/src/app.ts +4 -0
- package/src/components/platform-ui/code-block.tsx +21 -0
- package/src/components/platform-ui/controls-panel-options.tsx +71 -0
- package/src/components/platform-ui/controls-panel-select.tsx +438 -0
- package/src/components/platform-ui/empty-state.tsx +15 -0
- package/src/components/platform-ui/icon-button.tsx +18 -0
- package/src/components/platform-ui/panel-select.tsx +123 -0
- package/src/components/platform-ui/panel.tsx +97 -0
- package/src/components/platform-ui/review-dropdown-menu.tsx +35 -0
- package/src/components/platform-ui/sidebar.tsx +293 -0
- package/src/components/platform-ui/toolbar-icon-button.tsx +34 -0
- package/src/components/platform-ui/toolbar.tsx +37 -0
- package/src/components/prototype-gallery-client.tsx +57 -0
- package/src/components/prototype-provider.tsx +20 -0
- package/src/components/prototypes/mini-pill-label.tsx +37 -0
- package/src/components/prototypes/prototype-change-log-panel.tsx +207 -0
- package/src/components/prototypes/prototype-comment-provider.tsx +61 -0
- package/src/components/prototypes/prototype-comment-toolbar.tsx +65 -0
- package/src/components/prototypes/prototype-control.tsx +31 -0
- package/src/components/prototypes/prototype-controls.tsx +553 -0
- package/src/components/prototypes/prototype-create-exploration-modal.tsx +117 -0
- package/src/components/prototypes/prototype-create-state-modal.tsx +117 -0
- package/src/components/prototypes/prototype-default-state-map-page.tsx +66 -0
- package/src/components/prototypes/prototype-design-brief-modal.tsx +128 -0
- package/src/components/prototypes/prototype-design-brief-panel.tsx +525 -0
- package/src/components/prototypes/prototype-design-context-panel.tsx +65 -0
- package/src/components/prototypes/prototype-floating-pill.module.scss +1341 -0
- package/src/components/prototypes/prototype-mobbin-gallery.tsx +330 -0
- package/src/components/prototypes/prototype-reference-docs.tsx +222 -0
- package/src/components/prototypes/prototype-review-chrome.module.scss +630 -0
- package/src/components/prototypes/prototype-review-chrome.tsx +1241 -0
- package/src/components/prototypes/prototype-review-dropdown-menu-item.tsx +1 -0
- package/src/components/prototypes/prototype-review-dropdown-menu-separator.tsx +1 -0
- package/src/components/prototypes/prototype-review-panel-menu-item.tsx +1 -0
- package/src/components/prototypes/prototype-review-panel-menu-separator.tsx +1 -0
- package/src/components/prototypes/prototype-review-panel-select.tsx +4 -0
- package/src/components/prototypes/prototype-review-sidebar.tsx +167 -0
- package/src/components/prototypes/prototype-share-link-restore.tsx +75 -0
- package/src/components/prototypes/prototype-share-mode.tsx +206 -0
- package/src/components/prototypes/prototype-spec-panel-content.tsx +538 -0
- package/src/components/prototypes/prototype-state-canvas-overlay.module.scss +336 -0
- package/src/components/prototypes/prototype-state-canvas-overlay.tsx +1023 -0
- package/src/components/prototypes/prototype-state-canvas.tsx +38 -0
- package/src/components/prototypes/prototype-state-screenshot-preview.tsx +47 -0
- package/src/components/prototypes/prototype-target.tsx +120 -0
- package/src/components/prototypes/prototype-tweak-highlight.tsx +132 -0
- package/src/components/prototypes/prototype-tweaks.tsx +48 -0
- package/src/components/prototypes/prototype-variant-explorer.tsx +347 -0
- package/src/components/prototypes/prototype-variant-rationale-panel.tsx +49 -0
- package/src/components/prototypes/prototype-variant-tabs.tsx +207 -0
- package/src/components/prototypes/prototype-vercel-preview-modal.tsx +120 -0
- package/src/components/prototypes/state-map-annotation-tooltip.module.scss +89 -0
- package/src/components/prototypes/state-map-annotation-tooltip.tsx +137 -0
- package/src/components/prototypes/state-map-wireframe-highlight.module.scss +25 -0
- package/src/components/prototypes/state-map-wireframe-highlight.tsx +82 -0
- package/src/components/shell/prototype-gallery-shell.tsx +79 -0
- package/src/components/shell/prototype-screenshot-capture.tsx +45 -0
- package/src/components/shell/prototype-shell.module.scss +194 -0
- package/src/components/shell/prototype-shell.tsx +160 -0
- package/src/components/shell/prototype-state-screenshot-capture.tsx +68 -0
- package/src/components/ui/button.tsx +58 -0
- package/src/components/ui/dialog.module.scss +81 -0
- package/src/components/ui/dialog.tsx +127 -0
- package/src/components/ui/dropdown-menu.tsx +200 -0
- package/src/components/ui/input.tsx +22 -0
- package/src/components/ui/label.tsx +26 -0
- package/src/components/ui/option-select.tsx +81 -0
- package/src/components/ui/scroll-area.tsx +48 -0
- package/src/components/ui/separator.tsx +31 -0
- package/src/components/ui/slider.tsx +28 -0
- package/src/components/ui/switch.tsx +29 -0
- package/src/components/ui/tabs.tsx +55 -0
- package/src/components/ui/toggle-group.tsx +80 -0
- package/src/components/ui/tooltip.tsx +32 -0
- package/src/config/create-prototype-gallery-page.tsx +65 -0
- package/src/config/create-prototype-host-app.tsx +121 -0
- package/src/config/create-prototype-page.tsx +41 -0
- package/src/config/create-prototype-site-layout.tsx +28 -0
- package/src/config/define-prototype-config.ts +7 -0
- package/src/config/prototype-icon.tsx +25 -0
- package/src/config/prototype-site-layout-client.tsx +35 -0
- package/src/config/with-prototype.ts +20 -0
- package/src/index.ts +303 -0
- package/src/lib/pr-split/build-pr-agent-prompt.ts +68 -0
- package/src/lib/pr-split/build-pr-split-prototype-url.ts +12 -0
- package/src/lib/pr-split/pr-split-highlight.ts +6 -0
- package/src/lib/pr-split/pr-split-types.ts +58 -0
- package/src/lib/pr-split/resolve-source-preview-url.ts +45 -0
- package/src/lib/pr-split/use-pr-vercel-previews.ts +69 -0
- package/src/lib/prototype-comments/core/annotation-channel.ts +41 -0
- package/src/lib/prototype-comments/core/annotation-status.ts +60 -0
- package/src/lib/prototype-comments/core/annotation-target.ts +567 -0
- package/src/lib/prototype-comments/core/capture-theme.ts +41 -0
- package/src/lib/prototype-comments/core/capture.ts +11 -0
- package/src/lib/prototype-comments/core/comment-capture-blocked.ts +47 -0
- package/src/lib/prototype-comments/core/comment-threads.ts +52 -0
- package/src/lib/prototype-comments/core/element-identification.ts +615 -0
- package/src/lib/prototype-comments/core/export.ts +35 -0
- package/src/lib/prototype-comments/core/freeze-animations.ts +266 -0
- package/src/lib/prototype-comments/core/identify-element.ts +76 -0
- package/src/lib/prototype-comments/core/normalize-viewport.ts +35 -0
- package/src/lib/prototype-comments/core/react-detection.ts +704 -0
- package/src/lib/prototype-comments/core/restore.ts +7 -0
- package/src/lib/prototype-comments/core/screenshot.ts +428 -0
- package/src/lib/prototype-comments/core/source-location.ts +906 -0
- package/src/lib/prototype-comments/core/storage.ts +80 -0
- package/src/lib/prototype-comments/core/types.ts +79 -0
- package/src/lib/prototype-comments/core/validation.ts +17 -0
- package/src/lib/prototype-comments/hooks/useLayoutShift.ts +61 -0
- package/src/lib/prototype-comments/index.ts +58 -0
- package/src/lib/prototype-comments/react/CommentCaptureToolbar.tsx +1398 -0
- package/src/lib/prototype-comments/react/CommentProvider.tsx +298 -0
- package/src/lib/prototype-comments/scss.d.ts +10 -0
- package/src/lib/prototype-comments/ui/CommentAnnotationOverlay.tsx +253 -0
- package/src/lib/prototype-comments/ui/CommentDetailPage.tsx +56 -0
- package/src/lib/prototype-comments/ui/CommentHeaderCount.tsx +28 -0
- package/src/lib/prototype-comments/ui/CommentThread.tsx +331 -0
- package/src/lib/prototype-comments/ui/CommentsGrid.tsx +780 -0
- package/src/lib/prototype-comments/ui/CommentsListPage.tsx +25 -0
- package/src/lib/prototype-comments/ui/CommentsSidebar.tsx +77 -0
- package/src/lib/prototype-comments/ui/annotation-marker/index.tsx +200 -0
- package/src/lib/prototype-comments/ui/annotation-marker/styles.module.scss +194 -0
- package/src/lib/prototype-comments/ui/annotation-popup/index.tsx +335 -0
- package/src/lib/prototype-comments/ui/annotation-popup/styles.module.scss +469 -0
- package/src/lib/prototype-comments/ui/capture-styles.module.scss +2225 -0
- package/src/lib/prototype-comments/ui/comment-highlight.ts +48 -0
- package/src/lib/prototype-comments/ui/comment-thread.module.scss +203 -0
- package/src/lib/prototype-comments/ui/comments-grid-card.module.scss +253 -0
- package/src/lib/prototype-comments/ui/comments-sidebar.module.scss +123 -0
- package/src/lib/prototype-comments/ui/icon-transitions.module.scss +51 -0
- package/src/lib/prototype-comments/ui/icons.tsx +1086 -0
- package/src/lib/prototype-comments/ui/is-comment-detail-path.ts +7 -0
- package/src/lib/prototypes/capture-prototype-viewport.ts +32 -0
- package/src/lib/prototypes/changelog-meta-context.tsx +162 -0
- package/src/lib/prototypes/changelog-meta-storage.ts +62 -0
- package/src/lib/prototypes/changelog-meta.ts +95 -0
- package/src/lib/prototypes/create-prototype-registry.ts +74 -0
- package/src/lib/prototypes/create-state-screenshot-thumbnail.ts +46 -0
- package/src/lib/prototypes/design-exploration-default-storage.ts +68 -0
- package/src/lib/prototypes/design-exploration-default.ts +51 -0
- package/src/lib/prototypes/design-exploration-types.ts +203 -0
- package/src/lib/prototypes/prototype-comment-registry.tsx +145 -0
- package/src/lib/prototypes/prototype-comment-review-bridge.tsx +40 -0
- package/src/lib/prototypes/prototype-comment-review-state.ts +57 -0
- package/src/lib/prototypes/prototype-component-registry.ts +40 -0
- package/src/lib/prototypes/prototype-config-types.ts +34 -0
- package/src/lib/prototypes/prototype-preview-state-registry.ts +443 -0
- package/src/lib/prototypes/prototype-preview-state-types.ts +89 -0
- package/src/lib/prototypes/prototype-review-context.tsx +905 -0
- package/src/lib/prototypes/prototype-review-url.ts +134 -0
- package/src/lib/prototypes/prototype-share-link.ts +175 -0
- package/src/lib/prototypes/prototype-state-canvas-constants.ts +118 -0
- package/src/lib/prototypes/prototype-state-canvas-types.ts +159 -0
- package/src/lib/prototypes/prototype-state-screenshot.ts +39 -0
- package/src/lib/prototypes/prototype-tweak-registry.ts +96 -0
- package/src/lib/prototypes/prototype-tweak-types.ts +31 -0
- package/src/lib/prototypes/reference-docs.ts +137 -0
- package/src/lib/prototypes/screenshot-manifest.ts +33 -0
- package/src/lib/prototypes/screenshot-src.ts +7 -0
- package/src/lib/prototypes/share-command.ts +8 -0
- package/src/lib/prototypes/state-map-annotation.ts +70 -0
- package/src/lib/prototypes/use-design-exploration-default.ts +114 -0
- package/src/lib/prototypes/use-persisted-local-state.ts +140 -0
- package/src/lib/prototypes/use-prototype-comments.ts +63 -0
- package/src/lib/prototypes/use-prototype-mobile-viewport-frame.ts +46 -0
- package/src/lib/prototypes/use-prototype-state-screenshot-src.ts +71 -0
- package/src/lib/prototypes/use-prototype-tool-theme.tsx +115 -0
- package/src/lib/prototypes/use-prototype-viewport-frame.ts +34 -0
- package/src/lib/prototypes/use-register-prototype-reference-docs.ts +16 -0
- package/src/lib/prototypes/use-snap-corner-position.ts +417 -0
- package/src/lib/prototypes/use-toolbar-hover-panel.ts +98 -0
- package/src/lib/prototypes/variant-set-lucide-icon.tsx +55 -0
- package/src/lib/tool-portal.ts +33 -0
- package/src/lib/use-copy-to-clipboard.ts +81 -0
- package/src/lib/utils.ts +6 -0
- package/src/lib/vercel-preview/parse-vercel-github-comment.ts +81 -0
- package/src/server/create-host-api-route.ts +100 -0
- package/src/server/create-prototype-api-routes.ts +428 -0
- package/src/server/gallery/create-gallery-api.ts +56 -0
- package/src/server/gallery/folders-route.ts +156 -0
- package/src/server/gallery/gallery-env.ts +39 -0
- package/src/server/gallery/gallery-route.ts +150 -0
- package/src/server/gallery/gallery-types.ts +15 -0
- package/src/server/gallery/image-route.ts +59 -0
- package/src/server/gallery/item-route.ts +92 -0
- package/src/server/pr-vercel-preview-route.ts +162 -0
- package/src/server/redis/client.ts +55 -0
- package/src/server/redis/prototype-changelog-meta.ts +31 -0
- package/src/server/redis/prototype-comments.ts +92 -0
- package/src/server/redis/prototype-design-exploration-default.ts +32 -0
- package/src/server.ts +51 -0
- package/src/styles/globals.css +624 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { isValidAnnotation } from "./validation";
|
|
2
|
+
|
|
3
|
+
export interface CommentStorageAdapter<T extends { id: string }> {
|
|
4
|
+
load(): T[] | Promise<T[]>;
|
|
5
|
+
upsert(annotation: T): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class CommentStorageError extends Error {
|
|
9
|
+
constructor(message: string) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "CommentStorageError";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function createRemoteStorageAdapter<T extends { id: string }>(
|
|
16
|
+
slug: string,
|
|
17
|
+
validate: (value: unknown) => boolean = isValidAnnotation,
|
|
18
|
+
onError?: (message: string) => void,
|
|
19
|
+
): CommentStorageAdapter<T> {
|
|
20
|
+
const listUrl = `/api/prototypes/${encodeURIComponent(slug)}/comments`;
|
|
21
|
+
|
|
22
|
+
async function requestUpsert(annotation: T): Promise<void> {
|
|
23
|
+
const response = await fetch(
|
|
24
|
+
`${listUrl}/${encodeURIComponent(annotation.id)}`,
|
|
25
|
+
{
|
|
26
|
+
method: "PUT",
|
|
27
|
+
headers: { "Content-Type": "application/json" },
|
|
28
|
+
body: JSON.stringify(annotation),
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
if (response.status === 503) {
|
|
33
|
+
throw new CommentStorageError(
|
|
34
|
+
"Comment storage is not configured. Set Upstash Redis env vars.",
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!response.ok) {
|
|
39
|
+
const body = (await response.json().catch(() => null)) as {
|
|
40
|
+
error?: string;
|
|
41
|
+
} | null;
|
|
42
|
+
throw new CommentStorageError(body?.error ?? "Failed to save comment.");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
async load(): Promise<T[]> {
|
|
48
|
+
const response = await fetch(listUrl);
|
|
49
|
+
|
|
50
|
+
if (response.status === 503) {
|
|
51
|
+
throw new CommentStorageError(
|
|
52
|
+
"Comment storage is not configured. Set Upstash Redis env vars.",
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
const body = (await response.json().catch(() => null)) as {
|
|
58
|
+
error?: string;
|
|
59
|
+
} | null;
|
|
60
|
+
throw new CommentStorageError(body?.error ?? "Failed to load comments.");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const parsed: unknown = await response.json();
|
|
64
|
+
if (!Array.isArray(parsed)) return [];
|
|
65
|
+
return (parsed as unknown[]).filter(validate) as T[];
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
async upsert(annotation: T): Promise<void> {
|
|
69
|
+
try {
|
|
70
|
+
await requestUpsert(annotation);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error(
|
|
73
|
+
"[prototype-comments] Failed to save comment:",
|
|
74
|
+
error instanceof Error ? error.message : error,
|
|
75
|
+
);
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export type AnnotationBoundingBox = {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type CaptureViewport = {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
scrollY: number;
|
|
12
|
+
/** Scroll offset of the prototype content container (not window) */
|
|
13
|
+
scrollTop?: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type CommentAnnotationFields = {
|
|
17
|
+
id: string;
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
comment: string;
|
|
21
|
+
element: string;
|
|
22
|
+
elementPath: string;
|
|
23
|
+
timestamp: number;
|
|
24
|
+
selectedText?: string;
|
|
25
|
+
boundingBox?: AnnotationBoundingBox;
|
|
26
|
+
/** Element bounds in viewport coordinates at screenshot capture time */
|
|
27
|
+
viewportBoundingBox?: AnnotationBoundingBox;
|
|
28
|
+
/** Viewport dimensions when the screenshot was taken */
|
|
29
|
+
captureViewport?: CaptureViewport;
|
|
30
|
+
positionAnchor?: "viewport" | "element";
|
|
31
|
+
/** Full id from data-prototype-target, e.g. my-slug.filter-bar.status */
|
|
32
|
+
targetId?: string;
|
|
33
|
+
nearbyText?: string;
|
|
34
|
+
cssClasses?: string;
|
|
35
|
+
isMultiSelect?: boolean;
|
|
36
|
+
isFixed?: boolean;
|
|
37
|
+
fullPath?: string;
|
|
38
|
+
accessibility?: string;
|
|
39
|
+
computedStyles?: string;
|
|
40
|
+
nearbyElements?: string;
|
|
41
|
+
reactComponents?: string;
|
|
42
|
+
sourceFile?: string;
|
|
43
|
+
sessionId?: string;
|
|
44
|
+
url?: string;
|
|
45
|
+
status?: "pending" | "acknowledged" | "resolved" | "dismissed";
|
|
46
|
+
/** When set, this annotation is a reply on the root comment with this id. */
|
|
47
|
+
parentId?: string;
|
|
48
|
+
/** Soft-delete flag — deleted comments stay in storage but are hidden in UI. */
|
|
49
|
+
deleted?: boolean;
|
|
50
|
+
/** Review comments vs change log notes. Defaults to `"comment"`. */
|
|
51
|
+
channel?: "comment" | "changelog";
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/** The stored interaction state: prototype live state + package-added metadata */
|
|
55
|
+
export type CommentInteractionState<TState> = TState & {
|
|
56
|
+
capturedAt: string;
|
|
57
|
+
route: string;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type CommentAnnotation<TState> = CommentAnnotationFields & {
|
|
61
|
+
interactionState: CommentInteractionState<TState>;
|
|
62
|
+
screenshot?: string;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export type CommentStore<TState> = {
|
|
66
|
+
slug: string;
|
|
67
|
+
annotations: CommentAnnotation<TState>[];
|
|
68
|
+
storageReady: boolean;
|
|
69
|
+
storageError: string | null;
|
|
70
|
+
addAnnotation: (
|
|
71
|
+
fields: Omit<CommentAnnotation<TState>, "interactionState">,
|
|
72
|
+
) => CommentAnnotation<TState>;
|
|
73
|
+
addReply: (parentId: string, comment: string) => CommentAnnotation<TState>;
|
|
74
|
+
updateAnnotation: (id: string, comment: string) => void;
|
|
75
|
+
resolveAnnotation: (id: string) => void;
|
|
76
|
+
deleteAnnotation: (id: string) => void;
|
|
77
|
+
clearAllAnnotations: () => void;
|
|
78
|
+
restoreComment: (id: string) => CommentAnnotation<TState> | undefined;
|
|
79
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function isValidAnnotation(value: unknown): boolean {
|
|
2
|
+
if (!value || typeof value !== "object") return false;
|
|
3
|
+
const a = value as Record<string, unknown>;
|
|
4
|
+
return (
|
|
5
|
+
typeof a.id === "string" &&
|
|
6
|
+
typeof a.comment === "string" &&
|
|
7
|
+
typeof a.timestamp === "number" &&
|
|
8
|
+
a.interactionState != null &&
|
|
9
|
+
typeof (a.interactionState as Record<string, unknown>).capturedAt ===
|
|
10
|
+
"string" &&
|
|
11
|
+
(a.deleted === undefined || typeof a.deleted === "boolean") &&
|
|
12
|
+
(a.parentId === undefined || typeof a.parentId === "string") &&
|
|
13
|
+
(a.channel === undefined ||
|
|
14
|
+
a.channel === "comment" ||
|
|
15
|
+
a.channel === "changelog")
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Increments a counter whenever page layout shifts in ways that don't fire
|
|
5
|
+
* window resize — e.g. comments sidebar open/close animating body margin.
|
|
6
|
+
*/
|
|
7
|
+
export function useLayoutShift(): number {
|
|
8
|
+
const [layoutVersion, setLayoutVersion] = useState(0);
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const bump = () => setLayoutVersion((v) => v + 1);
|
|
12
|
+
|
|
13
|
+
const resizeObserver = new ResizeObserver(bump);
|
|
14
|
+
resizeObserver.observe(document.body);
|
|
15
|
+
|
|
16
|
+
const mutationObserver = new MutationObserver((mutations) => {
|
|
17
|
+
for (const mutation of mutations) {
|
|
18
|
+
if (
|
|
19
|
+
mutation.type === "attributes" &&
|
|
20
|
+
mutation.attributeName === "data-comments-sidebar-open"
|
|
21
|
+
) {
|
|
22
|
+
bump();
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
mutationObserver.observe(document.documentElement, {
|
|
28
|
+
attributes: true,
|
|
29
|
+
attributeFilter: ["data-comments-sidebar-open", "data-comments-sidebar-resizing", "style"],
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const handleTransitionEnd = (event: TransitionEvent) => {
|
|
33
|
+
const target = event.target;
|
|
34
|
+
if (!(target instanceof HTMLElement)) return;
|
|
35
|
+
|
|
36
|
+
if (
|
|
37
|
+
target === document.body &&
|
|
38
|
+
event.propertyName === "margin-right"
|
|
39
|
+
) {
|
|
40
|
+
bump();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (
|
|
45
|
+
target.id === "prototype-comments-sidebar-root" &&
|
|
46
|
+
event.propertyName === "width"
|
|
47
|
+
) {
|
|
48
|
+
bump();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
document.body.addEventListener("transitionend", handleTransitionEnd);
|
|
52
|
+
|
|
53
|
+
return () => {
|
|
54
|
+
resizeObserver.disconnect();
|
|
55
|
+
mutationObserver.disconnect();
|
|
56
|
+
document.body.removeEventListener("transitionend", handleTransitionEnd);
|
|
57
|
+
};
|
|
58
|
+
}, []);
|
|
59
|
+
|
|
60
|
+
return layoutVersion;
|
|
61
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Core utilities (no React)
|
|
2
|
+
export { captureInteractionState } from "./core/capture";
|
|
3
|
+
export { commentToLiveState } from "./core/restore";
|
|
4
|
+
export { createRemoteStorageAdapter, CommentStorageError } from "./core/storage";
|
|
5
|
+
export type { CommentStorageAdapter } from "./core/storage";
|
|
6
|
+
export { isValidAnnotation } from "./core/validation";
|
|
7
|
+
export {
|
|
8
|
+
getRepliesForParent,
|
|
9
|
+
getRootAnnotations,
|
|
10
|
+
isRootAnnotation,
|
|
11
|
+
resolveThreadRootId,
|
|
12
|
+
} from "./core/comment-threads";
|
|
13
|
+
export { normalizeAnnotationViewport } from "./core/normalize-viewport";
|
|
14
|
+
export { formatAnnotationWithState, formatAllAnnotations } from "./core/export";
|
|
15
|
+
export { captureViewportScreenshot } from "./core/screenshot";
|
|
16
|
+
export {
|
|
17
|
+
closestCrossingShadow,
|
|
18
|
+
identifyElement,
|
|
19
|
+
parseComputedStylesString,
|
|
20
|
+
} from "./core/element-identification";
|
|
21
|
+
export {
|
|
22
|
+
resolveAnnotationTargetElement,
|
|
23
|
+
resolveAnnotationTargetById,
|
|
24
|
+
getPrototypeScrollContainer,
|
|
25
|
+
getAnnotationMarkerPosition,
|
|
26
|
+
getAnnotationOutlineBox,
|
|
27
|
+
getMarkerViewportPosition,
|
|
28
|
+
PROTOTYPE_TARGET_ATTR,
|
|
29
|
+
type AnnotationTargetOptions,
|
|
30
|
+
} from "./core/annotation-target";
|
|
31
|
+
|
|
32
|
+
// Types
|
|
33
|
+
export type {
|
|
34
|
+
AnnotationBoundingBox,
|
|
35
|
+
CaptureViewport,
|
|
36
|
+
CommentAnnotationFields,
|
|
37
|
+
CommentInteractionState,
|
|
38
|
+
CommentAnnotation,
|
|
39
|
+
CommentStore,
|
|
40
|
+
} from "./core/types";
|
|
41
|
+
|
|
42
|
+
// React
|
|
43
|
+
export {
|
|
44
|
+
CommentProvider,
|
|
45
|
+
useCommentStore,
|
|
46
|
+
useCommentStoreOptional,
|
|
47
|
+
} from "./react/CommentProvider";
|
|
48
|
+
export { CommentCaptureToolbar } from "./react/CommentCaptureToolbar";
|
|
49
|
+
export type { CommentCaptureToolbarProps } from "./react/CommentCaptureToolbar";
|
|
50
|
+
|
|
51
|
+
// UI
|
|
52
|
+
export { getViewportBoundingBox, getCaptureAspectRatio } from "./ui/comment-highlight";
|
|
53
|
+
export { isCanvasDetailPath, isCanvasPath } from "./ui/is-comment-detail-path";
|
|
54
|
+
export { CommentsGrid } from "./ui/CommentsGrid";
|
|
55
|
+
export { CommentsListPage } from "./ui/CommentsListPage";
|
|
56
|
+
export { CommentDetailPage } from "./ui/CommentDetailPage";
|
|
57
|
+
export { CommentsSidebar } from "./ui/CommentsSidebar";
|
|
58
|
+
export { CommentAnnotationOverlay } from "./ui/CommentAnnotationOverlay";
|