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.
Files changed (209) hide show
  1. package/AGENTS.md +350 -0
  2. package/README.md +279 -0
  3. package/components.json +18 -0
  4. package/package.json +73 -0
  5. package/scripts/download-mobbin-reference-images.mjs +112 -0
  6. package/scripts/lib/host-config.example.sh +48 -0
  7. package/scripts/lib/host-config.sh +25 -0
  8. package/scripts/lib/resolve-host-root.mjs +18 -0
  9. package/scripts/lib/source-path.sh +49 -0
  10. package/scripts/link-source-db.sh +128 -0
  11. package/scripts/link-source.sh +40 -0
  12. package/scripts/publish-package.sh +147 -0
  13. package/scripts/share-prototype.sh +279 -0
  14. package/scripts/sync-from-source.sh +74 -0
  15. package/scripts/verify-prototype-component-ids.mjs +151 -0
  16. package/scripts/verify-prototype-preview-states.mjs +135 -0
  17. package/src/app.ts +4 -0
  18. package/src/components/platform-ui/code-block.tsx +21 -0
  19. package/src/components/platform-ui/controls-panel-options.tsx +71 -0
  20. package/src/components/platform-ui/controls-panel-select.tsx +438 -0
  21. package/src/components/platform-ui/empty-state.tsx +15 -0
  22. package/src/components/platform-ui/icon-button.tsx +18 -0
  23. package/src/components/platform-ui/panel-select.tsx +123 -0
  24. package/src/components/platform-ui/panel.tsx +97 -0
  25. package/src/components/platform-ui/review-dropdown-menu.tsx +35 -0
  26. package/src/components/platform-ui/sidebar.tsx +293 -0
  27. package/src/components/platform-ui/toolbar-icon-button.tsx +34 -0
  28. package/src/components/platform-ui/toolbar.tsx +37 -0
  29. package/src/components/prototype-gallery-client.tsx +57 -0
  30. package/src/components/prototype-provider.tsx +20 -0
  31. package/src/components/prototypes/mini-pill-label.tsx +37 -0
  32. package/src/components/prototypes/prototype-change-log-panel.tsx +207 -0
  33. package/src/components/prototypes/prototype-comment-provider.tsx +61 -0
  34. package/src/components/prototypes/prototype-comment-toolbar.tsx +65 -0
  35. package/src/components/prototypes/prototype-control.tsx +31 -0
  36. package/src/components/prototypes/prototype-controls.tsx +553 -0
  37. package/src/components/prototypes/prototype-create-exploration-modal.tsx +117 -0
  38. package/src/components/prototypes/prototype-create-state-modal.tsx +117 -0
  39. package/src/components/prototypes/prototype-default-state-map-page.tsx +66 -0
  40. package/src/components/prototypes/prototype-design-brief-modal.tsx +128 -0
  41. package/src/components/prototypes/prototype-design-brief-panel.tsx +525 -0
  42. package/src/components/prototypes/prototype-design-context-panel.tsx +65 -0
  43. package/src/components/prototypes/prototype-floating-pill.module.scss +1341 -0
  44. package/src/components/prototypes/prototype-mobbin-gallery.tsx +330 -0
  45. package/src/components/prototypes/prototype-reference-docs.tsx +222 -0
  46. package/src/components/prototypes/prototype-review-chrome.module.scss +630 -0
  47. package/src/components/prototypes/prototype-review-chrome.tsx +1241 -0
  48. package/src/components/prototypes/prototype-review-dropdown-menu-item.tsx +1 -0
  49. package/src/components/prototypes/prototype-review-dropdown-menu-separator.tsx +1 -0
  50. package/src/components/prototypes/prototype-review-panel-menu-item.tsx +1 -0
  51. package/src/components/prototypes/prototype-review-panel-menu-separator.tsx +1 -0
  52. package/src/components/prototypes/prototype-review-panel-select.tsx +4 -0
  53. package/src/components/prototypes/prototype-review-sidebar.tsx +167 -0
  54. package/src/components/prototypes/prototype-share-link-restore.tsx +75 -0
  55. package/src/components/prototypes/prototype-share-mode.tsx +206 -0
  56. package/src/components/prototypes/prototype-spec-panel-content.tsx +538 -0
  57. package/src/components/prototypes/prototype-state-canvas-overlay.module.scss +336 -0
  58. package/src/components/prototypes/prototype-state-canvas-overlay.tsx +1023 -0
  59. package/src/components/prototypes/prototype-state-canvas.tsx +38 -0
  60. package/src/components/prototypes/prototype-state-screenshot-preview.tsx +47 -0
  61. package/src/components/prototypes/prototype-target.tsx +120 -0
  62. package/src/components/prototypes/prototype-tweak-highlight.tsx +132 -0
  63. package/src/components/prototypes/prototype-tweaks.tsx +48 -0
  64. package/src/components/prototypes/prototype-variant-explorer.tsx +347 -0
  65. package/src/components/prototypes/prototype-variant-rationale-panel.tsx +49 -0
  66. package/src/components/prototypes/prototype-variant-tabs.tsx +207 -0
  67. package/src/components/prototypes/prototype-vercel-preview-modal.tsx +120 -0
  68. package/src/components/prototypes/state-map-annotation-tooltip.module.scss +89 -0
  69. package/src/components/prototypes/state-map-annotation-tooltip.tsx +137 -0
  70. package/src/components/prototypes/state-map-wireframe-highlight.module.scss +25 -0
  71. package/src/components/prototypes/state-map-wireframe-highlight.tsx +82 -0
  72. package/src/components/shell/prototype-gallery-shell.tsx +79 -0
  73. package/src/components/shell/prototype-screenshot-capture.tsx +45 -0
  74. package/src/components/shell/prototype-shell.module.scss +194 -0
  75. package/src/components/shell/prototype-shell.tsx +160 -0
  76. package/src/components/shell/prototype-state-screenshot-capture.tsx +68 -0
  77. package/src/components/ui/button.tsx +58 -0
  78. package/src/components/ui/dialog.module.scss +81 -0
  79. package/src/components/ui/dialog.tsx +127 -0
  80. package/src/components/ui/dropdown-menu.tsx +200 -0
  81. package/src/components/ui/input.tsx +22 -0
  82. package/src/components/ui/label.tsx +26 -0
  83. package/src/components/ui/option-select.tsx +81 -0
  84. package/src/components/ui/scroll-area.tsx +48 -0
  85. package/src/components/ui/separator.tsx +31 -0
  86. package/src/components/ui/slider.tsx +28 -0
  87. package/src/components/ui/switch.tsx +29 -0
  88. package/src/components/ui/tabs.tsx +55 -0
  89. package/src/components/ui/toggle-group.tsx +80 -0
  90. package/src/components/ui/tooltip.tsx +32 -0
  91. package/src/config/create-prototype-gallery-page.tsx +65 -0
  92. package/src/config/create-prototype-host-app.tsx +121 -0
  93. package/src/config/create-prototype-page.tsx +41 -0
  94. package/src/config/create-prototype-site-layout.tsx +28 -0
  95. package/src/config/define-prototype-config.ts +7 -0
  96. package/src/config/prototype-icon.tsx +25 -0
  97. package/src/config/prototype-site-layout-client.tsx +35 -0
  98. package/src/config/with-prototype.ts +20 -0
  99. package/src/index.ts +303 -0
  100. package/src/lib/pr-split/build-pr-agent-prompt.ts +68 -0
  101. package/src/lib/pr-split/build-pr-split-prototype-url.ts +12 -0
  102. package/src/lib/pr-split/pr-split-highlight.ts +6 -0
  103. package/src/lib/pr-split/pr-split-types.ts +58 -0
  104. package/src/lib/pr-split/resolve-source-preview-url.ts +45 -0
  105. package/src/lib/pr-split/use-pr-vercel-previews.ts +69 -0
  106. package/src/lib/prototype-comments/core/annotation-channel.ts +41 -0
  107. package/src/lib/prototype-comments/core/annotation-status.ts +60 -0
  108. package/src/lib/prototype-comments/core/annotation-target.ts +567 -0
  109. package/src/lib/prototype-comments/core/capture-theme.ts +41 -0
  110. package/src/lib/prototype-comments/core/capture.ts +11 -0
  111. package/src/lib/prototype-comments/core/comment-capture-blocked.ts +47 -0
  112. package/src/lib/prototype-comments/core/comment-threads.ts +52 -0
  113. package/src/lib/prototype-comments/core/element-identification.ts +615 -0
  114. package/src/lib/prototype-comments/core/export.ts +35 -0
  115. package/src/lib/prototype-comments/core/freeze-animations.ts +266 -0
  116. package/src/lib/prototype-comments/core/identify-element.ts +76 -0
  117. package/src/lib/prototype-comments/core/normalize-viewport.ts +35 -0
  118. package/src/lib/prototype-comments/core/react-detection.ts +704 -0
  119. package/src/lib/prototype-comments/core/restore.ts +7 -0
  120. package/src/lib/prototype-comments/core/screenshot.ts +428 -0
  121. package/src/lib/prototype-comments/core/source-location.ts +906 -0
  122. package/src/lib/prototype-comments/core/storage.ts +80 -0
  123. package/src/lib/prototype-comments/core/types.ts +79 -0
  124. package/src/lib/prototype-comments/core/validation.ts +17 -0
  125. package/src/lib/prototype-comments/hooks/useLayoutShift.ts +61 -0
  126. package/src/lib/prototype-comments/index.ts +58 -0
  127. package/src/lib/prototype-comments/react/CommentCaptureToolbar.tsx +1398 -0
  128. package/src/lib/prototype-comments/react/CommentProvider.tsx +298 -0
  129. package/src/lib/prototype-comments/scss.d.ts +10 -0
  130. package/src/lib/prototype-comments/ui/CommentAnnotationOverlay.tsx +253 -0
  131. package/src/lib/prototype-comments/ui/CommentDetailPage.tsx +56 -0
  132. package/src/lib/prototype-comments/ui/CommentHeaderCount.tsx +28 -0
  133. package/src/lib/prototype-comments/ui/CommentThread.tsx +331 -0
  134. package/src/lib/prototype-comments/ui/CommentsGrid.tsx +780 -0
  135. package/src/lib/prototype-comments/ui/CommentsListPage.tsx +25 -0
  136. package/src/lib/prototype-comments/ui/CommentsSidebar.tsx +77 -0
  137. package/src/lib/prototype-comments/ui/annotation-marker/index.tsx +200 -0
  138. package/src/lib/prototype-comments/ui/annotation-marker/styles.module.scss +194 -0
  139. package/src/lib/prototype-comments/ui/annotation-popup/index.tsx +335 -0
  140. package/src/lib/prototype-comments/ui/annotation-popup/styles.module.scss +469 -0
  141. package/src/lib/prototype-comments/ui/capture-styles.module.scss +2225 -0
  142. package/src/lib/prototype-comments/ui/comment-highlight.ts +48 -0
  143. package/src/lib/prototype-comments/ui/comment-thread.module.scss +203 -0
  144. package/src/lib/prototype-comments/ui/comments-grid-card.module.scss +253 -0
  145. package/src/lib/prototype-comments/ui/comments-sidebar.module.scss +123 -0
  146. package/src/lib/prototype-comments/ui/icon-transitions.module.scss +51 -0
  147. package/src/lib/prototype-comments/ui/icons.tsx +1086 -0
  148. package/src/lib/prototype-comments/ui/is-comment-detail-path.ts +7 -0
  149. package/src/lib/prototypes/capture-prototype-viewport.ts +32 -0
  150. package/src/lib/prototypes/changelog-meta-context.tsx +162 -0
  151. package/src/lib/prototypes/changelog-meta-storage.ts +62 -0
  152. package/src/lib/prototypes/changelog-meta.ts +95 -0
  153. package/src/lib/prototypes/create-prototype-registry.ts +74 -0
  154. package/src/lib/prototypes/create-state-screenshot-thumbnail.ts +46 -0
  155. package/src/lib/prototypes/design-exploration-default-storage.ts +68 -0
  156. package/src/lib/prototypes/design-exploration-default.ts +51 -0
  157. package/src/lib/prototypes/design-exploration-types.ts +203 -0
  158. package/src/lib/prototypes/prototype-comment-registry.tsx +145 -0
  159. package/src/lib/prototypes/prototype-comment-review-bridge.tsx +40 -0
  160. package/src/lib/prototypes/prototype-comment-review-state.ts +57 -0
  161. package/src/lib/prototypes/prototype-component-registry.ts +40 -0
  162. package/src/lib/prototypes/prototype-config-types.ts +34 -0
  163. package/src/lib/prototypes/prototype-preview-state-registry.ts +443 -0
  164. package/src/lib/prototypes/prototype-preview-state-types.ts +89 -0
  165. package/src/lib/prototypes/prototype-review-context.tsx +905 -0
  166. package/src/lib/prototypes/prototype-review-url.ts +134 -0
  167. package/src/lib/prototypes/prototype-share-link.ts +175 -0
  168. package/src/lib/prototypes/prototype-state-canvas-constants.ts +118 -0
  169. package/src/lib/prototypes/prototype-state-canvas-types.ts +159 -0
  170. package/src/lib/prototypes/prototype-state-screenshot.ts +39 -0
  171. package/src/lib/prototypes/prototype-tweak-registry.ts +96 -0
  172. package/src/lib/prototypes/prototype-tweak-types.ts +31 -0
  173. package/src/lib/prototypes/reference-docs.ts +137 -0
  174. package/src/lib/prototypes/screenshot-manifest.ts +33 -0
  175. package/src/lib/prototypes/screenshot-src.ts +7 -0
  176. package/src/lib/prototypes/share-command.ts +8 -0
  177. package/src/lib/prototypes/state-map-annotation.ts +70 -0
  178. package/src/lib/prototypes/use-design-exploration-default.ts +114 -0
  179. package/src/lib/prototypes/use-persisted-local-state.ts +140 -0
  180. package/src/lib/prototypes/use-prototype-comments.ts +63 -0
  181. package/src/lib/prototypes/use-prototype-mobile-viewport-frame.ts +46 -0
  182. package/src/lib/prototypes/use-prototype-state-screenshot-src.ts +71 -0
  183. package/src/lib/prototypes/use-prototype-tool-theme.tsx +115 -0
  184. package/src/lib/prototypes/use-prototype-viewport-frame.ts +34 -0
  185. package/src/lib/prototypes/use-register-prototype-reference-docs.ts +16 -0
  186. package/src/lib/prototypes/use-snap-corner-position.ts +417 -0
  187. package/src/lib/prototypes/use-toolbar-hover-panel.ts +98 -0
  188. package/src/lib/prototypes/variant-set-lucide-icon.tsx +55 -0
  189. package/src/lib/tool-portal.ts +33 -0
  190. package/src/lib/use-copy-to-clipboard.ts +81 -0
  191. package/src/lib/utils.ts +6 -0
  192. package/src/lib/vercel-preview/parse-vercel-github-comment.ts +81 -0
  193. package/src/server/create-host-api-route.ts +100 -0
  194. package/src/server/create-prototype-api-routes.ts +428 -0
  195. package/src/server/gallery/create-gallery-api.ts +56 -0
  196. package/src/server/gallery/folders-route.ts +156 -0
  197. package/src/server/gallery/gallery-env.ts +39 -0
  198. package/src/server/gallery/gallery-route.ts +150 -0
  199. package/src/server/gallery/gallery-types.ts +15 -0
  200. package/src/server/gallery/image-route.ts +59 -0
  201. package/src/server/gallery/item-route.ts +92 -0
  202. package/src/server/pr-vercel-preview-route.ts +162 -0
  203. package/src/server/redis/client.ts +55 -0
  204. package/src/server/redis/prototype-changelog-meta.ts +31 -0
  205. package/src/server/redis/prototype-comments.ts +92 -0
  206. package/src/server/redis/prototype-design-exploration-default.ts +32 -0
  207. package/src/server.ts +51 -0
  208. package/src/styles/globals.css +624 -0
  209. package/tsconfig.json +19 -0
@@ -0,0 +1,194 @@
1
+ .previewStage {
2
+ position: relative;
3
+ display: flex;
4
+ flex: 1 1 0;
5
+ min-width: 0;
6
+ min-height: 0;
7
+ flex-direction: column;
8
+ overflow: visible;
9
+ background: var(--prototype-ground);
10
+ }
11
+
12
+ .previewStageStateMap {
13
+ background: var(--tool-chrome-bg);
14
+
15
+ .viewportFrame {
16
+ background: var(--tool-chrome-bg);
17
+ border-color: transparent;
18
+ }
19
+
20
+ .viewport:not(.viewportMobile) {
21
+ background: var(--tool-chrome-bg);
22
+ }
23
+
24
+ &.previewStageMobile {
25
+ background: var(--tool-chrome-bg);
26
+ }
27
+ }
28
+
29
+ .previewStageMobile {
30
+ background: var(--prototype-ground);
31
+ }
32
+
33
+ .previewStageSidebarOpen {
34
+ border-right: 1px solid var(--border-faint);
35
+ }
36
+
37
+ .previewStageSidebarOpen .viewportFrame {
38
+ border-right: none;
39
+ border-top: none;
40
+ }
41
+
42
+ .previewStageBody {
43
+ position: relative;
44
+ z-index: 1;
45
+ display: flex;
46
+ flex: 1 1 0;
47
+ min-height: 0;
48
+ min-width: 0;
49
+ align-items: stretch;
50
+ justify-content: center;
51
+ overflow: visible;
52
+ padding: 0;
53
+ }
54
+
55
+ .previewStageMobile .previewStageBody {
56
+ align-items: center;
57
+ justify-content: center;
58
+ padding: 24px;
59
+ }
60
+
61
+ .viewportFrame {
62
+ display: flex;
63
+ flex: 1 1 0;
64
+ width: 100%;
65
+ min-width: 0;
66
+ min-height: 0;
67
+ align-self: stretch;
68
+ flex-direction: column;
69
+ background: var(--bg-main);
70
+ border: 1px solid var(--border-faint);
71
+ }
72
+
73
+ .viewportFrameMobile {
74
+ flex: 0 0 auto;
75
+ width: auto;
76
+ justify-content: center;
77
+ background: transparent;
78
+ border: none;
79
+ box-shadow: none;
80
+ }
81
+
82
+ .viewport {
83
+ position: relative;
84
+ display: flex;
85
+ width: 100%;
86
+ align-self: stretch;
87
+ min-width: 0;
88
+ min-height: 0;
89
+ flex: 1 1 0;
90
+ flex-direction: column;
91
+ overflow: hidden;
92
+ // Contain position:fixed descendants (e.g. source app sidebar) inside the frame.
93
+ transform: translateZ(0);
94
+
95
+ // Source app shell uses h-svh — re-anchor to this preview frame (above review footer).
96
+ :global([data-slot="sidebar-wrapper"]),
97
+ :global([data-slot="sidebar-container"]) {
98
+ height: 100% !important;
99
+ max-height: 100%;
100
+ }
101
+
102
+ :global([data-slot="sidebar-container"]) {
103
+ top: 0;
104
+ bottom: 0;
105
+ }
106
+
107
+ :global([data-slot="sidebar-inset"]) {
108
+ min-height: 0;
109
+ }
110
+
111
+ &:not(.viewportMobile) {
112
+ position: relative;
113
+ z-index: 1;
114
+ background: transparent;
115
+ border: none;
116
+ border-radius: 0;
117
+ }
118
+ }
119
+
120
+ // Prototype pages must fill the device frame — unlike h-svh, which tracks the browser.
121
+ .viewportContent {
122
+ display: flex;
123
+ flex: 1 1 0;
124
+ flex-direction: column;
125
+ min-height: 0;
126
+ min-width: 0;
127
+ width: 100%;
128
+ height: 100%;
129
+ }
130
+
131
+ .viewportPage {
132
+ display: flex;
133
+ flex: 1 1 0;
134
+ flex-direction: column;
135
+ min-height: 0;
136
+ min-width: 0;
137
+ width: 100%;
138
+ height: 100%;
139
+ }
140
+
141
+ // Prototype page root (e.g. PrototypeComponent id="page") — source app shells use h-full.
142
+ .viewportPage > * {
143
+ display: flex;
144
+ flex: 1 1 0;
145
+ flex-direction: column;
146
+ min-height: 0;
147
+ min-width: 0;
148
+ width: 100%;
149
+ height: 100%;
150
+ }
151
+
152
+ .viewportMobile {
153
+ flex: 0 0 auto;
154
+ width: var(--prototype-mobile-viewport-width, 390px);
155
+ max-width: 100%;
156
+ height: min(var(--prototype-mobile-viewport-height, 844px), 100%);
157
+ margin-inline: auto;
158
+ border-radius: 12px;
159
+ box-shadow:
160
+ 0 8px 32px color-mix(in srgb, var(--color-gray-900) 12%, transparent);
161
+ container-type: inline-size;
162
+ container-name: prototype-viewport;
163
+
164
+ // Source app shell uses h-svh / fixed — re-anchor to this device frame.
165
+ :global([data-slot="sidebar-wrapper"]),
166
+ :global([data-slot="sidebar-container"]) {
167
+ height: 100% !important;
168
+ max-height: 100%;
169
+ }
170
+
171
+ :global([data-slot="sidebar-container"]) {
172
+ top: 0;
173
+ bottom: 0;
174
+ }
175
+ }
176
+
177
+ .reviewFooter {
178
+ position: relative;
179
+ z-index: 0;
180
+ flex: 0 0 auto;
181
+ width: 100%;
182
+ border-top: none;
183
+ background: var(--bg-ground);
184
+ }
185
+
186
+ .commentsSidebarRoot {
187
+ background: var(--bg-ground);
188
+ }
189
+
190
+ .commentsSidebarRootClosed {
191
+ width: 0;
192
+ min-width: 0;
193
+ overflow: hidden;
194
+ }
@@ -0,0 +1,160 @@
1
+ "use client";
2
+
3
+ import type { PrototypeComponentRegistry } from "@prototype/lib/prototypes/prototype-component-registry";
4
+
5
+ import { PrototypeCommentRoot } from "@prototype/components/prototypes/prototype-comment-provider";
6
+ import { PrototypeCommentToolbar } from "@prototype/components/prototypes/prototype-comment-toolbar";
7
+ import { PrototypeCommentReviewBridge } from "@prototype/lib/prototypes/prototype-comment-review-bridge";
8
+ import {
9
+ PROTOTYPE_MOBILE_VIEWPORT_HEIGHT_PX,
10
+ PROTOTYPE_MOBILE_VIEWPORT_WIDTH_PX,
11
+ PrototypeReviewProvider,
12
+ usePrototypeReview,
13
+ } from "@prototype/lib/prototypes/prototype-review-context";
14
+ import {
15
+ PROTOTYPE_CHROME_ROOT_ID,
16
+ PROTOTYPE_COMMENTS_SIDEBAR_ROOT_ID,
17
+ PROTOTYPE_PREVIEW_STAGE_ID,
18
+ PROTOTYPE_VIEWPORT_ID,
19
+ } from "@prototype/lib/tool-portal";
20
+ import { cn } from "@prototype/lib/utils";
21
+
22
+ import { PrototypeProvider } from "@prototype/components/prototype-provider";
23
+
24
+ import { PrototypeScreenshotCapture } from "./prototype-screenshot-capture";
25
+ import styles from "./prototype-shell.module.scss";
26
+ import { usePathname } from "next/navigation";
27
+
28
+ type PrototypeShellProps = {
29
+ slug: string;
30
+ componentRegistry?: PrototypeComponentRegistry;
31
+ children: React.ReactNode;
32
+ };
33
+
34
+ function PrototypeCommentsSidebarHost() {
35
+ const review = usePrototypeReview();
36
+ const isMobileViewport = review.viewportLayout === "mobile";
37
+ const hideWhenClosed = isMobileViewport && !review.open;
38
+
39
+ return (
40
+ <div
41
+ id={PROTOTYPE_COMMENTS_SIDEBAR_ROOT_ID}
42
+ className={cn(
43
+ styles.commentsSidebarRoot,
44
+ "flex h-full min-h-0 shrink-0 flex-col overflow-hidden",
45
+ hideWhenClosed && styles.commentsSidebarRootClosed,
46
+ )}
47
+ />
48
+ );
49
+ }
50
+
51
+ function useOnStateMapPage(): boolean {
52
+ const pathname = usePathname();
53
+ const review = usePrototypeReview();
54
+ const stateMapPath = review.stateCanvasPagePath;
55
+
56
+ if (stateMapPath != null) {
57
+ return pathname.startsWith(stateMapPath);
58
+ }
59
+
60
+ return /\/prototypes\/[^/]+\/states\/?$/.test(pathname);
61
+ }
62
+
63
+ function PrototypePreviewArea({
64
+ slug,
65
+ children,
66
+ }: {
67
+ slug: string;
68
+ children: React.ReactNode;
69
+ }) {
70
+ const review = usePrototypeReview();
71
+ const isMobileViewport = review.viewportLayout === "mobile";
72
+ const onStateMapPage = useOnStateMapPage();
73
+
74
+ return (
75
+ <div
76
+ id={PROTOTYPE_PREVIEW_STAGE_ID}
77
+ className={cn(
78
+ styles.previewStage,
79
+ onStateMapPage && styles.previewStageStateMap,
80
+ isMobileViewport && styles.previewStageMobile,
81
+ review.open && styles.previewStageSidebarOpen,
82
+ )}
83
+ >
84
+ <div className={styles.previewStageBody}>
85
+ <div
86
+ className={cn(
87
+ styles.viewportFrame,
88
+ isMobileViewport && styles.viewportFrameMobile,
89
+ )}
90
+ >
91
+ <div
92
+ id={PROTOTYPE_VIEWPORT_ID}
93
+ {...(onStateMapPage ? {} : { "data-prototype-screenshot": true })}
94
+ data-prototype-viewport-layout={review.viewportLayout}
95
+ className={cn(
96
+ styles.viewport,
97
+ isMobileViewport && styles.viewportMobile,
98
+ )}
99
+ style={
100
+ isMobileViewport
101
+ ? {
102
+ ["--prototype-mobile-viewport-width" as string]: `${PROTOTYPE_MOBILE_VIEWPORT_WIDTH_PX}px`,
103
+ ["--prototype-mobile-viewport-height" as string]: `${PROTOTYPE_MOBILE_VIEWPORT_HEIGHT_PX}px`,
104
+ }
105
+ : undefined
106
+ }
107
+ >
108
+ <div className={styles.viewportContent}>
109
+ <div className={styles.viewportPage}>{children}</div>
110
+ </div>
111
+ {!onStateMapPage ? <PrototypeScreenshotCapture slug={slug} /> : null}
112
+ </div>
113
+ </div>
114
+ </div>
115
+ {!onStateMapPage ? (
116
+ <div
117
+ id={PROTOTYPE_CHROME_ROOT_ID}
118
+ className={styles.reviewFooter}
119
+ data-prototype-review-footer
120
+ />
121
+ ) : null}
122
+ </div>
123
+ );
124
+ }
125
+
126
+ function PrototypeShellLayout({ children }: { children: React.ReactNode }) {
127
+ const onStateMapPage = useOnStateMapPage();
128
+
129
+ return (
130
+ <PrototypeProvider
131
+ className={cn(
132
+ "flex h-svh w-full flex-col overflow-hidden",
133
+ onStateMapPage ? "bg-[var(--tool-chrome-bg)]" : "bg-[var(--bg-ground)]",
134
+ )}
135
+ >
136
+ {children}
137
+ </PrototypeProvider>
138
+ );
139
+ }
140
+
141
+ export function PrototypeShell({
142
+ slug,
143
+ componentRegistry,
144
+ children,
145
+ }: PrototypeShellProps) {
146
+ return (
147
+ <PrototypeCommentRoot slug={slug} componentRegistry={componentRegistry}>
148
+ <PrototypeReviewProvider slug={slug}>
149
+ <PrototypeCommentReviewBridge />
150
+ <PrototypeShellLayout>
151
+ <div className="flex min-h-0 flex-1 overflow-hidden">
152
+ <PrototypePreviewArea slug={slug}>{children}</PrototypePreviewArea>
153
+ <PrototypeCommentsSidebarHost />
154
+ </div>
155
+ <PrototypeCommentToolbar />
156
+ </PrototypeShellLayout>
157
+ </PrototypeReviewProvider>
158
+ </PrototypeCommentRoot>
159
+ );
160
+ }
@@ -0,0 +1,68 @@
1
+ "use client";
2
+
3
+ import { useEffect } from "react";
4
+
5
+ import { capturePrototypeViewportPng } from "@prototype/lib/prototypes/capture-prototype-viewport";
6
+ import { createStateScreenshotThumbnail } from "@prototype/lib/prototypes/create-state-screenshot-thumbnail";
7
+ import { getStateScreenshotThumbSize } from "@prototype/lib/prototypes/prototype-state-canvas-constants";
8
+ import { dispatchPrototypeStateScreenshotCaptured } from "@prototype/lib/prototypes/prototype-state-screenshot";
9
+
10
+ const CAPTURE_DELAY_MS = 700;
11
+
12
+ type PrototypeStateScreenshotCaptureProps = {
13
+ slug: string;
14
+ stateId: string | null;
15
+ enabled?: boolean;
16
+ };
17
+
18
+ export function PrototypeStateScreenshotCapture({
19
+ slug,
20
+ stateId,
21
+ enabled = true,
22
+ }: PrototypeStateScreenshotCaptureProps) {
23
+ useEffect(() => {
24
+ if (!enabled || !stateId || process.env.NODE_ENV !== "development") return;
25
+
26
+ let cancelled = false;
27
+
28
+ const capture = async () => {
29
+ const dataUrl = await capturePrototypeViewportPng(CAPTURE_DELAY_MS);
30
+ if (cancelled || !dataUrl) return;
31
+
32
+ const { width, height } = getStateScreenshotThumbSize();
33
+ const thumbnail =
34
+ (await createStateScreenshotThumbnail(dataUrl, width, height)) ?? dataUrl;
35
+
36
+ try {
37
+ const response = await fetch(`/api/prototypes/${slug}/screenshot`, {
38
+ method: "POST",
39
+ headers: { "Content-Type": "application/json" },
40
+ body: JSON.stringify({ image: thumbnail, stateId }),
41
+ });
42
+
43
+ if (!response.ok) {
44
+ throw new Error("Failed to save state screenshot");
45
+ }
46
+
47
+ const payload = (await response.json()) as { version?: number };
48
+ if (cancelled || payload.version == null) return;
49
+
50
+ dispatchPrototypeStateScreenshotCaptured({
51
+ slug,
52
+ stateId,
53
+ version: payload.version,
54
+ });
55
+ } catch (error) {
56
+ console.warn("[prototype-state-screenshot]", error);
57
+ }
58
+ };
59
+
60
+ void capture();
61
+
62
+ return () => {
63
+ cancelled = true;
64
+ };
65
+ }, [enabled, slug, stateId]);
66
+
67
+ return null;
68
+ }
@@ -0,0 +1,58 @@
1
+ "use client";
2
+
3
+ import { Slot } from "@radix-ui/react-slot";
4
+ import { cva, type VariantProps } from "class-variance-authority";
5
+ import * as React from "react";
6
+
7
+ import { cn } from "@prototype/lib/utils";
8
+
9
+ const buttonVariants = cva(
10
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
11
+ {
12
+ variants: {
13
+ variant: {
14
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
15
+ destructive:
16
+ "bg-destructive text-destructive-foreground hover:bg-destructive/90",
17
+ outline:
18
+ "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
19
+ secondary:
20
+ "bg-secondary text-secondary-foreground hover:bg-secondary/80",
21
+ ghost: "hover:bg-accent hover:text-accent-foreground",
22
+ link: "text-primary underline-offset-4 hover:underline",
23
+ },
24
+ size: {
25
+ default: "h-9 px-4 py-2",
26
+ sm: "h-8 rounded-md px-3 text-xs",
27
+ lg: "h-10 rounded-md px-8",
28
+ icon: "h-9 w-9",
29
+ },
30
+ },
31
+ defaultVariants: {
32
+ variant: "default",
33
+ size: "default",
34
+ },
35
+ },
36
+ );
37
+
38
+ export interface ButtonProps
39
+ extends React.ButtonHTMLAttributes<HTMLButtonElement>,
40
+ VariantProps<typeof buttonVariants> {
41
+ asChild?: boolean;
42
+ }
43
+
44
+ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
45
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
46
+ const Comp = asChild ? Slot : "button";
47
+ return (
48
+ <Comp
49
+ className={cn(buttonVariants({ variant, size, className }))}
50
+ ref={ref}
51
+ {...props}
52
+ />
53
+ );
54
+ },
55
+ );
56
+ Button.displayName = "Button";
57
+
58
+ export { Button, buttonVariants };
@@ -0,0 +1,81 @@
1
+ $dialog-ease-out: cubic-bezier(0.215, 0.61, 0.355, 1);
2
+
3
+ .overlay {
4
+ &[data-state="open"] {
5
+ animation: dialogOverlayIn 200ms ease-out both;
6
+ }
7
+
8
+ &[data-state="closed"] {
9
+ animation: dialogOverlayOut 150ms ease both;
10
+ }
11
+
12
+ @media (prefers-reduced-motion: reduce) {
13
+ &[data-state="open"],
14
+ &[data-state="closed"] {
15
+ animation: none;
16
+ }
17
+ }
18
+ }
19
+
20
+ .content {
21
+ transform: translate(-50%, -50%);
22
+
23
+ &[data-state="open"] {
24
+ animation: dialogContentIn 220ms $dialog-ease-out both;
25
+ }
26
+
27
+ &[data-state="closed"] {
28
+ animation: dialogContentOut 160ms ease both;
29
+ }
30
+
31
+ @media (prefers-reduced-motion: reduce) {
32
+ &[data-state="open"],
33
+ &[data-state="closed"] {
34
+ animation: none;
35
+ }
36
+ }
37
+ }
38
+
39
+ @keyframes dialogOverlayIn {
40
+ from {
41
+ opacity: 0;
42
+ }
43
+
44
+ to {
45
+ opacity: 1;
46
+ }
47
+ }
48
+
49
+ @keyframes dialogOverlayOut {
50
+ from {
51
+ opacity: 1;
52
+ }
53
+
54
+ to {
55
+ opacity: 0;
56
+ }
57
+ }
58
+
59
+ @keyframes dialogContentIn {
60
+ from {
61
+ opacity: 0;
62
+ transform: translate(-50%, calc(-50% + 6px)) scale(0.97);
63
+ }
64
+
65
+ to {
66
+ opacity: 1;
67
+ transform: translate(-50%, -50%) scale(1);
68
+ }
69
+ }
70
+
71
+ @keyframes dialogContentOut {
72
+ from {
73
+ opacity: 1;
74
+ transform: translate(-50%, -50%) scale(1);
75
+ }
76
+
77
+ to {
78
+ opacity: 0;
79
+ transform: translate(-50%, calc(-50% + 4px)) scale(0.97);
80
+ }
81
+ }
@@ -0,0 +1,127 @@
1
+ "use client";
2
+
3
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
4
+ import { X } from "lucide-react";
5
+ import * as React from "react";
6
+
7
+ import { getPrototypePortalContainer } from "@prototype/lib/tool-portal";
8
+ import { cn } from "@prototype/lib/utils";
9
+
10
+ import styles from "./dialog.module.scss";
11
+
12
+ const Dialog = DialogPrimitive.Root;
13
+ const DialogTrigger = DialogPrimitive.Trigger;
14
+ const DialogClose = DialogPrimitive.Close;
15
+ const DialogPortal = DialogPrimitive.Portal;
16
+
17
+ const DialogOverlay = React.forwardRef<
18
+ React.ComponentRef<typeof DialogPrimitive.Overlay>,
19
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
20
+ >(({ className, ...props }, ref) => (
21
+ <DialogPrimitive.Overlay
22
+ ref={ref}
23
+ className={cn(
24
+ styles.overlay,
25
+ "fixed inset-0 z-50 bg-black/50",
26
+ className,
27
+ )}
28
+ {...props}
29
+ />
30
+ ));
31
+ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
32
+
33
+ const DialogContent = React.forwardRef<
34
+ React.ComponentRef<typeof DialogPrimitive.Content>,
35
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
36
+ showCloseButton?: boolean;
37
+ }
38
+ >(({ className, children, showCloseButton = true, ...props }, ref) => (
39
+ <DialogPortal container={getPrototypePortalContainer()}>
40
+ <DialogOverlay />
41
+ <DialogPrimitive.Content
42
+ ref={ref}
43
+ className={cn(
44
+ styles.content,
45
+ "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg gap-4 border bg-background p-6 shadow-lg sm:rounded-lg",
46
+ className,
47
+ )}
48
+ {...props}
49
+ >
50
+ {children}
51
+ {showCloseButton ? (
52
+ <DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none">
53
+ <X className="size-4" />
54
+ <span className="sr-only">Close</span>
55
+ </DialogPrimitive.Close>
56
+ ) : null}
57
+ </DialogPrimitive.Content>
58
+ </DialogPortal>
59
+ ));
60
+ DialogContent.displayName = DialogPrimitive.Content.displayName;
61
+
62
+ function DialogHeader({
63
+ className,
64
+ ...props
65
+ }: React.HTMLAttributes<HTMLDivElement>) {
66
+ return (
67
+ <div
68
+ className={cn(
69
+ "flex flex-col space-y-1.5 text-center sm:text-left",
70
+ className,
71
+ )}
72
+ {...props}
73
+ />
74
+ );
75
+ }
76
+
77
+ function DialogFooter({
78
+ className,
79
+ ...props
80
+ }: React.HTMLAttributes<HTMLDivElement>) {
81
+ return (
82
+ <div
83
+ className={cn(
84
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
85
+ className,
86
+ )}
87
+ {...props}
88
+ />
89
+ );
90
+ }
91
+
92
+ const DialogTitle = React.forwardRef<
93
+ React.ComponentRef<typeof DialogPrimitive.Title>,
94
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
95
+ >(({ className, ...props }, ref) => (
96
+ <DialogPrimitive.Title
97
+ ref={ref}
98
+ className={cn("text-lg font-semibold leading-none tracking-tight", className)}
99
+ {...props}
100
+ />
101
+ ));
102
+ DialogTitle.displayName = DialogPrimitive.Title.displayName;
103
+
104
+ const DialogDescription = React.forwardRef<
105
+ React.ComponentRef<typeof DialogPrimitive.Description>,
106
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
107
+ >(({ className, ...props }, ref) => (
108
+ <DialogPrimitive.Description
109
+ ref={ref}
110
+ className={cn("text-sm text-muted-foreground", className)}
111
+ {...props}
112
+ />
113
+ ));
114
+ DialogDescription.displayName = DialogPrimitive.Description.displayName;
115
+
116
+ export {
117
+ Dialog,
118
+ DialogPortal,
119
+ DialogOverlay,
120
+ DialogClose,
121
+ DialogTrigger,
122
+ DialogContent,
123
+ DialogHeader,
124
+ DialogFooter,
125
+ DialogTitle,
126
+ DialogDescription,
127
+ };