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,65 @@
1
+ import "server-only";
2
+
3
+ import { PrototypeGalleryClient } from "@prototype/components/prototype-gallery-client";
4
+ import { PrototypeGalleryHeader } from "@prototype/components/shell/prototype-gallery-shell";
5
+ import { createPrototypeRegistry } from "@prototype/lib/prototypes/create-prototype-registry";
6
+ import type { PrototypeConfig } from "@prototype/lib/prototypes/prototype-config-types";
7
+
8
+ import { readScreenshotManifest } from "../lib/prototypes/screenshot-manifest";
9
+
10
+ type PrototypeGalleryPageOptions = {
11
+ title?: string;
12
+ description?: string;
13
+ eyebrow?: string;
14
+ };
15
+
16
+ export function createPrototypeGalleryPage(
17
+ config: PrototypeConfig,
18
+ options: PrototypeGalleryPageOptions = {},
19
+ ) {
20
+ const registry = createPrototypeRegistry(config);
21
+ const {
22
+ title = "Prototypes",
23
+ description = "UI experiments and concept explorations. Select a prototype to open it.",
24
+ eyebrow,
25
+ } = options;
26
+
27
+ async function PrototypeGallery() {
28
+ const prototypes = registry.getAllPrototypes();
29
+ const screenshotVersions =
30
+ process.env.NODE_ENV === "development"
31
+ ? await readScreenshotManifest()
32
+ : {};
33
+
34
+ if (prototypes.length === 0) {
35
+ return (
36
+ <p className="text-muted-foreground py-12 text-sm">
37
+ No prototypes yet. Add one in{" "}
38
+ <code className="text-foreground">prototype.config.ts</code>.
39
+ </p>
40
+ );
41
+ }
42
+
43
+ return (
44
+ <PrototypeGalleryClient
45
+ prototypes={prototypes}
46
+ screenshotVersions={screenshotVersions}
47
+ />
48
+ );
49
+ }
50
+
51
+ function HomePage() {
52
+ return (
53
+ <div className="px-10 lg:px-16">
54
+ <PrototypeGalleryHeader
55
+ eyebrow={eyebrow}
56
+ title={title}
57
+ description={description}
58
+ />
59
+ <PrototypeGallery />
60
+ </div>
61
+ );
62
+ }
63
+
64
+ return HomePage;
65
+ }
@@ -0,0 +1,121 @@
1
+ import "server-only";
2
+
3
+ import { notFound } from "next/navigation";
4
+ import { Suspense } from "react";
5
+
6
+ import { PrototypeShell } from "@prototype/components/shell/prototype-shell";
7
+ import { PrototypeDefaultStateMapPage } from "@prototype/components/prototypes/prototype-default-state-map-page";
8
+ import { createPrototypeRegistry } from "@prototype/lib/prototypes/create-prototype-registry";
9
+ import type {
10
+ PrototypeConfig,
11
+ PrototypeExtraRoute,
12
+ } from "@prototype/lib/prototypes/prototype-config-types";
13
+
14
+ import { createPrototypePage } from "./create-prototype-page";
15
+
16
+ function matchExtraRoute(
17
+ path: string[],
18
+ pattern: string[],
19
+ params: Record<string, string>,
20
+ ): boolean {
21
+ if (path.length !== pattern.length) return false;
22
+
23
+ for (let index = 0; index < pattern.length; index += 1) {
24
+ const segment = pattern[index]!;
25
+ const value = path[index]!;
26
+
27
+ if (segment.startsWith("[") && segment.endsWith("]")) {
28
+ params[segment.slice(1, -1)] = value;
29
+ continue;
30
+ }
31
+
32
+ if (segment !== value) return false;
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ function findExtraRoute(
39
+ path: string[],
40
+ routes: PrototypeExtraRoute[] | undefined,
41
+ ): { route: PrototypeExtraRoute; params: Record<string, string> } | null {
42
+ for (const route of routes ?? []) {
43
+ const params: Record<string, string> = {};
44
+ if (matchExtraRoute(path, route.segments, params)) {
45
+ return { route, params };
46
+ }
47
+ }
48
+ return null;
49
+ }
50
+
51
+ export function createPrototypeCatchAllPage(config: PrototypeConfig) {
52
+ const registry = createPrototypeRegistry(config);
53
+ const prototypePage = createPrototypePage(config);
54
+
55
+ function generateStaticParams() {
56
+ const prototypePaths = prototypePage.generateStaticParams().map(({ slug }) => ({
57
+ path: ["prototypes", slug],
58
+ }));
59
+ const stateMapPaths = registry.getAllPrototypes().map(({ slug }) => ({
60
+ path: ["prototypes", slug, "states"],
61
+ }));
62
+
63
+ return [...prototypePaths, ...stateMapPaths];
64
+ }
65
+
66
+ async function CatchAllPage({
67
+ params,
68
+ }: {
69
+ params: Promise<{ path?: string[] }>;
70
+ }) {
71
+ const { path = [] } = await params;
72
+
73
+ if (path.length === 2 && path[0] === "prototypes") {
74
+ const slug = path[1]!;
75
+ return prototypePage.default({ params: Promise.resolve({ slug }) });
76
+ }
77
+
78
+ const extra = findExtraRoute(path, config.extraRoutes);
79
+ if (extra) {
80
+ const { route, params: routeParams } = extra;
81
+ const Component = route.component;
82
+
83
+ if (route.shellSlug && route.componentRegistry) {
84
+ return (
85
+ <Suspense fallback={null}>
86
+ <PrototypeShell
87
+ slug={route.shellSlug}
88
+ componentRegistry={route.componentRegistry}
89
+ >
90
+ <Component {...routeParams} />
91
+ </PrototypeShell>
92
+ </Suspense>
93
+ );
94
+ }
95
+
96
+ return <Component {...routeParams} />;
97
+ }
98
+
99
+ if (path.length === 3 && path[0] === "prototypes" && path[2] === "states") {
100
+ const slug = path[1]!;
101
+ const prototype = registry.getPrototype(slug);
102
+ const componentRegistry = registry.getPrototypeComponentRegistryForSlug(slug);
103
+
104
+ if (!prototype) {
105
+ notFound();
106
+ }
107
+
108
+ return (
109
+ <Suspense fallback={null}>
110
+ <PrototypeShell slug={slug} componentRegistry={componentRegistry}>
111
+ <PrototypeDefaultStateMapPage slug={slug} />
112
+ </PrototypeShell>
113
+ </Suspense>
114
+ );
115
+ }
116
+
117
+ notFound();
118
+ }
119
+
120
+ return { default: CatchAllPage, generateStaticParams };
121
+ }
@@ -0,0 +1,41 @@
1
+ import { notFound } from "next/navigation";
2
+ import { Suspense } from "react";
3
+
4
+ import { PrototypeShell } from "@prototype/components/shell/prototype-shell";
5
+ import { createPrototypeRegistry } from "@prototype/lib/prototypes/create-prototype-registry";
6
+ import type { PrototypeConfig } from "@prototype/lib/prototypes/prototype-config-types";
7
+
8
+ type PrototypePageProps = {
9
+ params: Promise<{ slug: string }>;
10
+ };
11
+
12
+ export function createPrototypePage(config: PrototypeConfig) {
13
+ const registry = createPrototypeRegistry(config);
14
+
15
+ function generateStaticParams() {
16
+ return registry.getAllPrototypes().map((prototype) => ({
17
+ slug: prototype.slug,
18
+ }));
19
+ }
20
+
21
+ async function PrototypePage({ params }: PrototypePageProps) {
22
+ const { slug } = await params;
23
+ const prototype = registry.getPrototype(slug);
24
+ const Component = registry.getPrototypeComponent(slug);
25
+ const componentRegistry = registry.getPrototypeComponentRegistryForSlug(slug);
26
+
27
+ if (!prototype || !Component) {
28
+ notFound();
29
+ }
30
+
31
+ return (
32
+ <Suspense fallback={null}>
33
+ <PrototypeShell slug={slug} componentRegistry={componentRegistry}>
34
+ <Component />
35
+ </PrototypeShell>
36
+ </Suspense>
37
+ );
38
+ }
39
+
40
+ return { default: PrototypePage, generateStaticParams };
41
+ }
@@ -0,0 +1,28 @@
1
+ import type { ComponentType, ReactNode } from "react";
2
+
3
+ import { PrototypeGalleryShell } from "@prototype/components/shell/prototype-gallery-shell";
4
+
5
+ import { PrototypeSiteLayoutClient } from "./prototype-site-layout-client";
6
+
7
+ type PrototypeSiteLayoutOptions = {
8
+ toaster?: ReactNode;
9
+ };
10
+
11
+ export function createPrototypeSiteLayout(
12
+ options: PrototypeSiteLayoutOptions = {},
13
+ ) {
14
+ return function PrototypeSiteLayout({
15
+ children,
16
+ }: Readonly<{
17
+ children: ReactNode;
18
+ }>) {
19
+ return (
20
+ <PrototypeSiteLayoutClient
21
+ galleryShell={PrototypeGalleryShell as ComponentType<{ children: ReactNode }>}
22
+ toaster={options.toaster}
23
+ >
24
+ {children}
25
+ </PrototypeSiteLayoutClient>
26
+ );
27
+ };
28
+ }
@@ -0,0 +1,7 @@
1
+ import type { PrototypeConfig } from "@prototype/lib/prototypes/prototype-config-types";
2
+ import { setPrototypeConfig } from "@prototype/lib/prototypes/create-prototype-registry";
3
+
4
+ export function definePrototypeConfig(config: PrototypeConfig): PrototypeConfig {
5
+ setPrototypeConfig(config);
6
+ return config;
7
+ }
@@ -0,0 +1,25 @@
1
+ import { ImageResponse } from "next/og";
2
+
3
+ export const size = { width: 32, height: 32 };
4
+ export const contentType = "image/png";
5
+
6
+ export default function PrototypeIcon() {
7
+ return new ImageResponse(
8
+ (
9
+ <div
10
+ style={{
11
+ fontSize: 28,
12
+ width: "100%",
13
+ height: "100%",
14
+ display: "flex",
15
+ alignItems: "center",
16
+ justifyContent: "center",
17
+ lineHeight: 1,
18
+ }}
19
+ >
20
+ 🎨
21
+ </div>
22
+ ),
23
+ { ...size },
24
+ );
25
+ }
@@ -0,0 +1,35 @@
1
+ "use client";
2
+
3
+ import { usePathname } from "next/navigation";
4
+ import type { ComponentType, ReactNode } from "react";
5
+
6
+ type PrototypeSiteLayoutClientProps = {
7
+ children: ReactNode;
8
+ galleryShell: ComponentType<{ children: ReactNode }>;
9
+ toaster: ReactNode;
10
+ };
11
+
12
+ export function PrototypeSiteLayoutClient({
13
+ children,
14
+ galleryShell: GalleryShell,
15
+ toaster,
16
+ }: PrototypeSiteLayoutClientProps) {
17
+ const pathname = usePathname();
18
+ const isGalleryHome = pathname === "/";
19
+
20
+ if (isGalleryHome) {
21
+ return (
22
+ <>
23
+ <GalleryShell>{children}</GalleryShell>
24
+ {toaster}
25
+ </>
26
+ );
27
+ }
28
+
29
+ return (
30
+ <div className="bg-[var(--bg-ground)] flex h-svh overflow-hidden">
31
+ {children}
32
+ {toaster}
33
+ </div>
34
+ );
35
+ }
@@ -0,0 +1,20 @@
1
+ import type { NextConfig } from "next";
2
+
3
+ export type WithPrototypeOptions = {
4
+ configPath?: string;
5
+ nextConfig?: NextConfig;
6
+ };
7
+
8
+ export function withPrototype(
9
+ options: WithPrototypeOptions = {},
10
+ ): NextConfig {
11
+ const { nextConfig = {} } = options;
12
+
13
+ return {
14
+ ...nextConfig,
15
+ transpilePackages: [
16
+ ...(nextConfig.transpilePackages ?? []),
17
+ "proto-plugin",
18
+ ],
19
+ };
20
+ }
package/src/index.ts ADDED
@@ -0,0 +1,303 @@
1
+ export { definePrototypeConfig } from "./config/define-prototype-config";
2
+ export { createPrototypePage } from "./config/create-prototype-page";
3
+ export { createPrototypeSiteLayout } from "./config/create-prototype-site-layout";
4
+ export { withPrototype } from "./config/with-prototype";
5
+
6
+ export {
7
+ createPrototypeRegistry,
8
+ getAllPrototypes,
9
+ getPrototype,
10
+ getPrototypeComponent,
11
+ getPrototypeComponentRegistryForSlug,
12
+ setPrototypeConfig,
13
+ } from "./lib/prototypes/create-prototype-registry";
14
+
15
+ export type {
16
+ PrototypeConfig,
17
+ PrototypeDefinition,
18
+ PrototypeExtraRoute,
19
+ PrototypeMetadata,
20
+ } from "./lib/prototypes/prototype-config-types";
21
+
22
+ export {
23
+ PrototypeComponent,
24
+ PrototypeTarget,
25
+ PrototypeTargetIdProvider,
26
+ usePrototypeSlug,
27
+ buildPrototypeTargetId,
28
+ } from "./components/prototypes/prototype-target";
29
+
30
+ export {
31
+ PrototypeControl,
32
+ PrototypeControlGroup,
33
+ } from "./components/prototypes/prototype-control";
34
+
35
+ export { PrototypeShell } from "./components/shell/prototype-shell";
36
+
37
+ export { PrototypeProvider } from "./components/prototype-provider";
38
+
39
+ export { PrototypeVariantExplorer } from "./components/prototypes/prototype-variant-explorer";
40
+
41
+ export { PrototypeVercelPreviewModal } from "./components/prototypes/prototype-vercel-preview-modal";
42
+ export type { PrototypeVercelPreviewModalProps } from "./components/prototypes/prototype-vercel-preview-modal";
43
+
44
+ export { PrototypeTweaks } from "./components/prototypes/prototype-tweaks";
45
+ export type { PrototypeTweakConfig } from "./components/prototypes/prototype-tweaks";
46
+
47
+ export { usePrototypeComments } from "./lib/prototypes/use-prototype-comments";
48
+
49
+ export {
50
+ usePersistPrototypeLiveState,
51
+ readPersistedPrototypeLiveState,
52
+ } from "./lib/prototypes/use-persisted-local-state";
53
+
54
+ export type { DesignExplorationConfig } from "./lib/prototypes/design-exploration-types";
55
+
56
+ export {
57
+ buildCreateDesignExplorationCopyText,
58
+ buildCreateDesignExplorationPrompt,
59
+ buildResetBriefDefaultsPrompt,
60
+ getAdjacentDesignExplorationVariant,
61
+ } from "./lib/prototypes/design-exploration-types";
62
+
63
+ export {
64
+ buildCreatePreviewStateCopyText,
65
+ buildCreatePreviewStatePrompt,
66
+ } from "./lib/prototypes/prototype-preview-state-types";
67
+ export type { PrototypePreviewState } from "./lib/prototypes/prototype-preview-state-types";
68
+
69
+ export {
70
+ buildAddReferenceDocCopyText,
71
+ buildAddReferenceDocPrompt,
72
+ defaultReferenceDocsConfigPath,
73
+ isValidReferenceDoc,
74
+ isValidReferenceDocInput,
75
+ normalizeReferenceDocLink,
76
+ } from "./lib/prototypes/reference-docs";
77
+ export type { PrototypeReferenceDoc } from "./lib/prototypes/reference-docs";
78
+ export { useRegisterPrototypeReferenceDocs } from "./lib/prototypes/use-register-prototype-reference-docs";
79
+ export {
80
+ buildPreviewStateCanvasEdges,
81
+ buildPreviewStateCanvasLayout,
82
+ buildPreviewStateCanvasNodes,
83
+ buildPreviewStatePickerOptions,
84
+ definePreviewStateRegistry,
85
+ flattenPreviewStateLabels,
86
+ getPreviewStateNodeHeight,
87
+ normalizePreviewStateCanvasRowStates,
88
+ } from "./lib/prototypes/prototype-preview-state-registry";
89
+ export type {
90
+ DefinedPreviewStateRegistry,
91
+ PreviewStateCanvasLayout,
92
+ PreviewStateCanvasRowPlacement,
93
+ PreviewStateCanvasRowStatePlacement,
94
+ PrototypePreviewStateCanvasLayoutSpec,
95
+ PrototypePreviewStateDefinition,
96
+ PrototypePreviewStateEdge,
97
+ PrototypePreviewStateRegistry,
98
+ PrototypePreviewStateVariant,
99
+ ResolvedPrototypePreviewStateDefinition,
100
+ } from "./lib/prototypes/prototype-preview-state-registry";
101
+ export {
102
+ getStateCanvasNodeHeight,
103
+ PROTOTYPE_STATE_CANVAS_PADDING,
104
+ PROTOTYPE_STATE_NODE_COLUMN_GAP,
105
+ PROTOTYPE_STATE_NODE_ROW_GAP,
106
+ PROTOTYPE_STATE_SECTION_TO_NODES,
107
+ stateCanvasColumnX,
108
+ } from "./lib/prototypes/prototype-state-canvas-constants";
109
+
110
+ export { PrototypeGalleryClient } from "./components/prototype-gallery-client";
111
+
112
+ export {
113
+ PrototypeGalleryShell,
114
+ PrototypeGalleryHeader,
115
+ PrototypeGalleryPage,
116
+ } from "./components/shell/prototype-gallery-shell";
117
+
118
+ export { screenshotSrc } from "./lib/prototypes/screenshot-src";
119
+
120
+ export {
121
+ definePrototypeComponentRegistry,
122
+ type PrototypeComponentRegistry,
123
+ } from "./lib/prototypes/prototype-component-registry";
124
+
125
+ export { PrototypeControls } from "./components/prototypes/prototype-controls";
126
+
127
+ export {
128
+ PrototypeStateCanvasRegistrar,
129
+ PrototypeStateCanvasView,
130
+ buildStateMapHref,
131
+ getDefaultPrototypeStateMapPath,
132
+ parseStateMapReturnTo,
133
+ PROTOTYPE_STATE_MAP_RETURN_TO_PARAM,
134
+ type PrototypeStateCanvasConfig,
135
+ type PrototypeStateCanvasEdge,
136
+ type PrototypeStateCanvasNode,
137
+ type PrototypeStateCanvasNodeCallout,
138
+ type PrototypeStateCanvasSection,
139
+ type PrototypeStateMapAnnotationEntry,
140
+ buildStateMapAnnotationEntries,
141
+ stateMapHasAnnotations,
142
+ } from "./components/prototypes/prototype-state-canvas";
143
+
144
+ export { PrototypeStateScreenshotCapture } from "./components/shell/prototype-state-screenshot-capture";
145
+
146
+ export { PrototypeStateScreenshotPreview } from "./components/prototypes/prototype-state-screenshot-preview";
147
+
148
+ export {
149
+ sanitizeStateIdForFilename,
150
+ stateScreenshotManifestKey,
151
+ stateScreenshotPublicPath,
152
+ stateScreenshotSrc,
153
+ } from "./lib/prototypes/prototype-state-screenshot";
154
+
155
+ export {
156
+ StateMapHighlightProvider,
157
+ StateMapHighlightRegion,
158
+ StateMapPreviewHighlightOverlay,
159
+ useStateMapHighlight,
160
+ } from "./components/prototypes/state-map-wireframe-highlight";
161
+
162
+ export {
163
+ parseStateMapAnnotation,
164
+ resolveBulletHighlightId,
165
+ stateMapAnnotationHasInteractiveBullets,
166
+ } from "./lib/prototypes/state-map-annotation";
167
+ export type {
168
+ ParsedStateMapAnnotation,
169
+ ParsedStateMapBullet,
170
+ } from "./lib/prototypes/state-map-annotation";
171
+
172
+ export type { StateMapHighlightRect } from "./lib/prototypes/prototype-state-canvas-types";
173
+
174
+ export { PrototypeReviewDropdownMenuItem } from "./components/prototypes/prototype-review-dropdown-menu-item";
175
+
176
+ export { PrototypeReviewDropdownMenuSeparator } from "./components/prototypes/prototype-review-dropdown-menu-separator";
177
+
178
+ export { PrototypeReviewPanelSelect } from "./components/prototypes/prototype-review-panel-select";
179
+
180
+ export {
181
+ ControlsPanelOption,
182
+ ControlsPanelOptionGroup,
183
+ ControlsPanelOptionSeparator,
184
+ } from "./components/platform-ui/controls-panel-options";
185
+
186
+ export {
187
+ ControlsPanelSelect,
188
+ } from "./components/platform-ui/controls-panel-select";
189
+ export type {
190
+ ControlsPanelSelectEntry,
191
+ ControlsPanelSelectOption,
192
+ ControlsPanelSelectSeparator,
193
+ ControlsPanelSelectSubmenu,
194
+ ControlsPanelSelectSubmenuOption,
195
+ } from "./components/platform-ui/controls-panel-select";
196
+
197
+ export { PrototypeReviewPanelMenuItem } from "./components/prototypes/prototype-review-panel-menu-item";
198
+
199
+ export { PrototypeReviewPanelMenuSeparator } from "./components/prototypes/prototype-review-panel-menu-separator";
200
+
201
+ export {
202
+ usePrototypeReview,
203
+ usePrototypeReviewOptional,
204
+ } from "./lib/prototypes/prototype-review-context";
205
+ export type {
206
+ PrototypeReviewSidebarPanel,
207
+ PrototypeVariantSet,
208
+ PrototypeViewportLayout,
209
+ } from "./lib/prototypes/prototype-review-context";
210
+
211
+ export {
212
+ PROTOTYPE_MOBILE_VIEWPORT_HEIGHT_PX,
213
+ PROTOTYPE_MOBILE_VIEWPORT_WIDTH_PX,
214
+ } from "./lib/prototypes/prototype-review-context";
215
+ export {
216
+ VariantSetLucideIcon,
217
+ resolveVariantSetLucideIcon,
218
+ } from "./lib/prototypes/variant-set-lucide-icon";
219
+ export { usePrototypeViewportFrame } from "./lib/prototypes/use-prototype-viewport-frame";
220
+ export { usePrototypeMobileViewportFrame } from "./lib/prototypes/use-prototype-mobile-viewport-frame";
221
+
222
+ export {
223
+ PROTOTYPE_CHROME_ROOT_ID,
224
+ PROTOTYPE_COMMENTS_SIDEBAR_ROOT_ID,
225
+ PROTOTYPE_PREVIEW_STAGE_ID,
226
+ PROTOTYPE_ROOT_ID,
227
+ PROTOTYPE_SCREENSHOT_ATTR,
228
+ PROTOTYPE_VIEWPORT_ID,
229
+ getPrototypeChromeRoot,
230
+ getPrototypePreviewStage,
231
+ getPrototypeScreenshotRoot,
232
+ } from "./lib/tool-portal";
233
+
234
+ export {
235
+ prototypeChangelogMetaRedisKey,
236
+ isValidChangelogMeta,
237
+ parseChangelogMeta,
238
+ normalizeChangelogMetaPayload,
239
+ EMPTY_CHANGELOG_META,
240
+ } from "./lib/prototypes/changelog-meta";
241
+ export type { PrototypeChangelogMeta } from "./lib/prototypes/changelog-meta";
242
+ export { createChangelogMetaStorageAdapter } from "./lib/prototypes/changelog-meta-storage";
243
+ export {
244
+ ChangelogMetaProvider,
245
+ useChangelogMeta,
246
+ useChangelogMetaOptional,
247
+ } from "./lib/prototypes/changelog-meta-context";
248
+
249
+ export {
250
+ prototypeDesignExplorationDefaultRedisKey,
251
+ parseDesignExplorationDefault,
252
+ isValidDesignExplorationDefaultRecord,
253
+ } from "./lib/prototypes/design-exploration-default";
254
+ export type { DesignExplorationDefaultRecord } from "./lib/prototypes/design-exploration-default";
255
+ export { createDesignExplorationDefaultStorageAdapter } from "./lib/prototypes/design-exploration-default-storage";
256
+ export { useDesignExplorationDefault } from "./lib/prototypes/use-design-exploration-default";
257
+
258
+ export {
259
+ filterAnnotationsByChannel,
260
+ getChangelogRootAnnotations,
261
+ getCommentRootAnnotations,
262
+ isChangelogAnnotation,
263
+ } from "./lib/prototype-comments/core/annotation-channel";
264
+ export type { AnnotationChannel } from "./lib/prototype-comments/core/annotation-channel";
265
+
266
+ export { isValidAnnotation } from "./lib/prototype-comments/core/validation";
267
+ export {
268
+ isAnnotationDeleted,
269
+ isVisibleAnnotation,
270
+ } from "./lib/prototype-comments/core/annotation-status";
271
+ export type { CommentAnnotationFields } from "./lib/prototype-comments/core/types";
272
+
273
+ export { PrototypeSpecPanelContent } from "./components/prototypes/prototype-spec-panel-content";
274
+ export type { PrototypeSpecPanelContentProps } from "./components/prototypes/prototype-spec-panel-content";
275
+
276
+ export {
277
+ PR_TARGET_HIGHLIGHT_BORDER,
278
+ PR_TARGET_HIGHLIGHT_FILL,
279
+ } from "./lib/pr-split/pr-split-highlight";
280
+
281
+ export { buildPrSplitPrototypeUrl } from "./lib/pr-split/build-pr-split-prototype-url";
282
+ export { buildPrAgentPrompt } from "./lib/pr-split/build-pr-agent-prompt";
283
+
284
+ export type {
285
+ PrSplitEntry,
286
+ PrSplitEntrySize,
287
+ PrSplitConfig,
288
+ PrSplitAgentPromptConfig,
289
+ PrSplitUrlConfig,
290
+ } from "./lib/pr-split/pr-split-types";
291
+
292
+ export { resolveSourcePreviewUrl } from "./lib/pr-split/resolve-source-preview-url";
293
+ export { usePrVercelPreviews } from "./lib/pr-split/use-pr-vercel-previews";
294
+
295
+ export {
296
+ buildVercelPreviewPageUrl,
297
+ parseGithubPrUrl,
298
+ parseVercelGithubCommentBody,
299
+ } from "./lib/vercel-preview/parse-vercel-github-comment";
300
+ export type {
301
+ VercelPreviewFromPr,
302
+ VercelPreviewProject,
303
+ } from "./lib/vercel-preview/parse-vercel-github-comment";