foss-design 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/README.md +6 -3
  2. package/dist/cli.js +1700 -217
  3. package/dist/viewer/assets/index-ChcZNlVM.css +2 -0
  4. package/dist/viewer/assets/index-CzXF5TnZ.js +157 -0
  5. package/dist/viewer/index.html +2 -2
  6. package/dist/viewer-lib/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
  7. package/dist/viewer-lib/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
  8. package/dist/viewer-lib/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
  9. package/dist/viewer-lib/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
  10. package/dist/viewer-lib/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
  11. package/dist/viewer-lib/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
  12. package/dist/viewer-lib/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
  13. package/dist/viewer-lib/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
  14. package/dist/viewer-lib/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  15. package/dist/viewer-lib/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  16. package/dist/viewer-lib/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  17. package/dist/viewer-lib/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  18. package/dist/viewer-lib/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
  19. package/dist/viewer-lib/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
  20. package/dist/viewer-lib/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
  21. package/dist/viewer-lib/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
  22. package/dist/viewer-lib/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
  23. package/dist/viewer-lib/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
  24. package/dist/viewer-lib/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
  25. package/dist/viewer-lib/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
  26. package/dist/viewer-lib/assets/ibm-plex-sans-cyrillic-400-normal-BTotfTJu.woff +0 -0
  27. package/dist/viewer-lib/assets/ibm-plex-sans-cyrillic-400-normal-DZqxrq2p.woff2 +0 -0
  28. package/dist/viewer-lib/assets/ibm-plex-sans-cyrillic-500-normal-ByOcLdNv.woff +0 -0
  29. package/dist/viewer-lib/assets/ibm-plex-sans-cyrillic-500-normal-CocWQlwt.woff2 +0 -0
  30. package/dist/viewer-lib/assets/ibm-plex-sans-cyrillic-600-normal-71GNu3SW.woff2 +0 -0
  31. package/dist/viewer-lib/assets/ibm-plex-sans-cyrillic-600-normal-BGq0mW3O.woff +0 -0
  32. package/dist/viewer-lib/assets/ibm-plex-sans-cyrillic-ext-400-normal-Dsrv2Tcn.woff +0 -0
  33. package/dist/viewer-lib/assets/ibm-plex-sans-cyrillic-ext-400-normal-g30qAdWV.woff2 +0 -0
  34. package/dist/viewer-lib/assets/ibm-plex-sans-cyrillic-ext-500-normal-Cs5J6C77.woff2 +0 -0
  35. package/dist/viewer-lib/assets/ibm-plex-sans-cyrillic-ext-500-normal-DB5PtV2g.woff +0 -0
  36. package/dist/viewer-lib/assets/ibm-plex-sans-cyrillic-ext-600-normal-Bz0x94Yp.woff +0 -0
  37. package/dist/viewer-lib/assets/ibm-plex-sans-cyrillic-ext-600-normal-DUMzJB7m.woff2 +0 -0
  38. package/dist/viewer-lib/assets/ibm-plex-sans-greek-400-normal-D9ESIMu3.woff +0 -0
  39. package/dist/viewer-lib/assets/ibm-plex-sans-greek-400-normal-_efipK4i.woff2 +0 -0
  40. package/dist/viewer-lib/assets/ibm-plex-sans-greek-500-normal-CuWXN6rf.woff +0 -0
  41. package/dist/viewer-lib/assets/ibm-plex-sans-greek-500-normal-JMMifIXV.woff2 +0 -0
  42. package/dist/viewer-lib/assets/ibm-plex-sans-greek-600-normal-D-CqTdkO.woff +0 -0
  43. package/dist/viewer-lib/assets/ibm-plex-sans-greek-600-normal-DzTrcv_p.woff2 +0 -0
  44. package/dist/viewer-lib/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
  45. package/dist/viewer-lib/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
  46. package/dist/viewer-lib/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
  47. package/dist/viewer-lib/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
  48. package/dist/viewer-lib/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
  49. package/dist/viewer-lib/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
  50. package/dist/viewer-lib/assets/ibm-plex-sans-latin-ext-400-normal-C5H60-Va.woff2 +0 -0
  51. package/dist/viewer-lib/assets/ibm-plex-sans-latin-ext-400-normal-RBey6euL.woff +0 -0
  52. package/dist/viewer-lib/assets/ibm-plex-sans-latin-ext-500-normal-D0aIdm-b.woff +0 -0
  53. package/dist/viewer-lib/assets/ibm-plex-sans-latin-ext-500-normal-DakdToA3.woff2 +0 -0
  54. package/dist/viewer-lib/assets/ibm-plex-sans-latin-ext-600-normal-DIrixKbi.woff +0 -0
  55. package/dist/viewer-lib/assets/ibm-plex-sans-latin-ext-600-normal-DOrvGEcy.woff2 +0 -0
  56. package/dist/viewer-lib/assets/ibm-plex-sans-vietnamese-400-normal-DG4YqDda.woff2 +0 -0
  57. package/dist/viewer-lib/assets/ibm-plex-sans-vietnamese-400-normal-fK1oJ5dG.woff +0 -0
  58. package/dist/viewer-lib/assets/ibm-plex-sans-vietnamese-500-normal-BEb3_waV.woff +0 -0
  59. package/dist/viewer-lib/assets/ibm-plex-sans-vietnamese-500-normal-e4dixQRQ.woff2 +0 -0
  60. package/dist/viewer-lib/assets/ibm-plex-sans-vietnamese-600-normal-DgdngZtN.woff +0 -0
  61. package/dist/viewer-lib/assets/ibm-plex-sans-vietnamese-600-normal-DpPYBSTl.woff2 +0 -0
  62. package/dist/viewer-lib/index.d.ts +1 -0
  63. package/dist/viewer-lib/index.js +17581 -0
  64. package/dist/viewer-lib/styles.css +3090 -0
  65. package/dist/viewer-lib/types/src/shared/devices.d.ts +46 -0
  66. package/dist/viewer-lib/types/src/shared/types.d.ts +355 -0
  67. package/dist/viewer-lib/types/viewer/src/app.d.ts +20 -0
  68. package/dist/viewer-lib/types/viewer/src/components/auto-frame.d.ts +13 -0
  69. package/dist/viewer-lib/types/viewer/src/components/code-view.d.ts +6 -0
  70. package/dist/viewer-lib/types/viewer/src/components/command-palette.d.ts +2 -0
  71. package/dist/viewer-lib/types/viewer/src/components/inspector.d.ts +29 -0
  72. package/dist/viewer-lib/types/viewer/src/components/issues.d.ts +10 -0
  73. package/dist/viewer-lib/types/viewer/src/components/markdown.d.ts +8 -0
  74. package/dist/viewer-lib/types/viewer/src/components/search-button.d.ts +6 -0
  75. package/dist/viewer-lib/types/viewer/src/components/slide-panel.d.ts +11 -0
  76. package/dist/viewer-lib/types/viewer/src/components/theme-menu.d.ts +1 -0
  77. package/dist/viewer-lib/types/viewer/src/components/topbar.d.ts +8 -0
  78. package/dist/viewer-lib/types/viewer/src/components/wordmark.d.ts +7 -0
  79. package/dist/viewer-lib/types/viewer/src/lib/api.d.ts +14 -0
  80. package/dist/viewer-lib/types/viewer/src/lib/cn.d.ts +1 -0
  81. package/dist/viewer-lib/types/viewer/src/lib/copy.d.ts +1 -0
  82. package/dist/viewer-lib/types/viewer/src/lib/focus.d.ts +2 -0
  83. package/dist/viewer-lib/types/viewer/src/lib/format.d.ts +3 -0
  84. package/dist/viewer-lib/types/viewer/src/lib/frames.d.ts +25 -0
  85. package/dist/viewer-lib/types/viewer/src/lib/platform.d.ts +3 -0
  86. package/dist/viewer-lib/types/viewer/src/lib/source.d.ts +43 -0
  87. package/dist/viewer-lib/types/viewer/src/lib/store.d.ts +10 -0
  88. package/dist/viewer-lib/types/viewer/src/lib/theme.d.ts +6 -0
  89. package/dist/viewer-lib/types/viewer/src/lib/viewer.d.ts +44 -0
  90. package/dist/viewer-lib/types/viewer/src/library.d.ts +25 -0
  91. package/dist/viewer-lib/types/viewer/src/pages/canvas/camera.d.ts +43 -0
  92. package/dist/viewer-lib/types/viewer/src/pages/canvas/canvas-bar.d.ts +29 -0
  93. package/dist/viewer-lib/types/viewer/src/pages/canvas/canvas-page.d.ts +4 -0
  94. package/dist/viewer-lib/types/viewer/src/pages/canvas/items.d.ts +47 -0
  95. package/dist/viewer-lib/types/viewer/src/pages/canvas/layout.d.ts +30 -0
  96. package/dist/viewer-lib/types/viewer/src/pages/canvas/overlay.d.ts +19 -0
  97. package/dist/viewer-lib/types/viewer/src/pages/canvas/play-page.d.ts +4 -0
  98. package/dist/viewer-lib/types/viewer/src/pages/canvas/sidebar.d.ts +10 -0
  99. package/dist/viewer-lib/types/viewer/src/pages/canvas/view-state.d.ts +30 -0
  100. package/dist/viewer-lib/types/viewer/src/pages/canvas/viewport.d.ts +37 -0
  101. package/dist/viewer-lib/types/viewer/src/pages/home.d.ts +1 -0
  102. package/dist/viewer-lib/types/viewer/src/pages/not-found.d.ts +4 -0
  103. package/dist/viewer-lib/types/viewer/src/pages/system/assets.d.ts +4 -0
  104. package/dist/viewer-lib/types/viewer/src/pages/system/colors.d.ts +4 -0
  105. package/dist/viewer-lib/types/viewer/src/pages/system/component-page.d.ts +5 -0
  106. package/dist/viewer-lib/types/viewer/src/pages/system/guideline.d.ts +5 -0
  107. package/dist/viewer-lib/types/viewer/src/pages/system/motion.d.ts +7 -0
  108. package/dist/viewer-lib/types/viewer/src/pages/system/nav.d.ts +5 -0
  109. package/dist/viewer-lib/types/viewer/src/pages/system/other-tokens.d.ts +4 -0
  110. package/dist/viewer-lib/types/viewer/src/pages/system/overview.d.ts +4 -0
  111. package/dist/viewer-lib/types/viewer/src/pages/system/shape.d.ts +4 -0
  112. package/dist/viewer-lib/types/viewer/src/pages/system/shared.d.ts +34 -0
  113. package/dist/viewer-lib/types/viewer/src/pages/system/system-routes.d.ts +2 -0
  114. package/dist/viewer-lib/types/viewer/src/pages/system/typography.d.ts +4 -0
  115. package/dist/viewer-lib/types/viewer/src/ui/avatar.d.ts +14 -0
  116. package/dist/viewer-lib/types/viewer/src/ui/badge.d.ts +11 -0
  117. package/dist/viewer-lib/types/viewer/src/ui/button.d.ts +37 -0
  118. package/dist/viewer-lib/types/viewer/src/ui/choice.d.ts +19 -0
  119. package/dist/viewer-lib/types/viewer/src/ui/dialog.d.ts +18 -0
  120. package/dist/viewer-lib/types/viewer/src/ui/icon-paths.d.ts +87 -0
  121. package/dist/viewer-lib/types/viewer/src/ui/icon.d.ts +8 -0
  122. package/dist/viewer-lib/types/viewer/src/ui/menu.d.ts +27 -0
  123. package/dist/viewer-lib/types/viewer/src/ui/meter.d.ts +15 -0
  124. package/dist/viewer-lib/types/viewer/src/ui/page.d.ts +39 -0
  125. package/dist/viewer-lib/types/viewer/src/ui/panel.d.ts +72 -0
  126. package/dist/viewer-lib/types/viewer/src/ui/text-field.d.ts +19 -0
  127. package/dist/viewer-lib/types/viewer/src/ui/text.d.ts +22 -0
  128. package/dist/viewer-lib/types/viewer/src/ui/toast.d.ts +5 -0
  129. package/dist/viewer-lib/types/viewer/src/ui/tooltip.d.ts +13 -0
  130. package/package.json +20 -2
  131. package/dist/viewer/assets/index-DeZ8UVA6.css +0 -2
  132. package/dist/viewer/assets/index-j0vt81cl.js +0 -157
@@ -0,0 +1,46 @@
1
+ /** Frame presets, in CSS pixels. */
2
+ export declare const DEVICES: {
3
+ readonly phone: {
4
+ readonly width: 390;
5
+ readonly height: 844;
6
+ readonly label: 'Phone';
7
+ };
8
+ readonly 'phone-sm': {
9
+ readonly width: 375;
10
+ readonly height: 667;
11
+ readonly label: 'Phone S';
12
+ };
13
+ readonly 'phone-lg': {
14
+ readonly width: 430;
15
+ readonly height: 932;
16
+ readonly label: 'Phone L';
17
+ };
18
+ readonly tablet: {
19
+ readonly width: 834;
20
+ readonly height: 1194;
21
+ readonly label: 'Tablet';
22
+ };
23
+ readonly 'tablet-landscape': {
24
+ readonly width: 1194;
25
+ readonly height: 834;
26
+ readonly label: 'Tablet landscape';
27
+ };
28
+ readonly laptop: {
29
+ readonly width: 1280;
30
+ readonly height: 800;
31
+ readonly label: 'Laptop';
32
+ };
33
+ readonly desktop: {
34
+ readonly width: 1440;
35
+ readonly height: 900;
36
+ readonly label: 'Desktop';
37
+ };
38
+ readonly wide: {
39
+ readonly width: 1920;
40
+ readonly height: 1080;
41
+ readonly label: 'Wide';
42
+ };
43
+ };
44
+ export type DeviceName = keyof typeof DEVICES;
45
+ export declare const DEVICE_NAMES: [DeviceName, ...DeviceName[]];
46
+ export declare const DEFAULT_DEVICE: DeviceName;
@@ -0,0 +1,355 @@
1
+ /** Contracts shared by the server, the static build and the viewer. */
2
+ export type Theme = 'light' | 'dark';
3
+ export interface Issue {
4
+ severity: 'error' | 'warning';
5
+ /** Path relative to the project root. */
6
+ file: string;
7
+ message: string;
8
+ /** Where in the file, such as `pages[0].sections[1].items[2].src`. */
9
+ at?: string;
10
+ }
11
+ export interface ProjectInfo {
12
+ name: string;
13
+ root: string;
14
+ /** True in a static build: no live reload, no snapshots, hash routing. */
15
+ static: boolean;
16
+ version: string;
17
+ system: SystemSummary | null;
18
+ canvases: CanvasSummary[];
19
+ issues: Issue[];
20
+ }
21
+ export interface SystemSummary {
22
+ name: string;
23
+ description?: string;
24
+ tokens: number;
25
+ components: number;
26
+ guidelines: number;
27
+ issues: number;
28
+ }
29
+ export interface CanvasSummary {
30
+ id: string;
31
+ title: string;
32
+ description?: string;
33
+ pages: number;
34
+ screens: number;
35
+ updatedAt: number;
36
+ issues: number;
37
+ /** A snapshot of the first screen, for the canvas card. */
38
+ cover?: string;
39
+ }
40
+ export interface FrameSize {
41
+ width: number;
42
+ /** `auto` grows the frame to the screen's content. */
43
+ height: number | 'auto';
44
+ device?: string;
45
+ }
46
+ interface ItemBase {
47
+ id: string;
48
+ title: string;
49
+ description?: string;
50
+ /** Free-layout position on the page, in canvas pixels. */
51
+ x?: number;
52
+ y?: number;
53
+ }
54
+ export interface ScreenItem extends ItemBase {
55
+ kind: 'screen';
56
+ /** Source path relative to the canvas folder, as written in canvas.json. */
57
+ src: string;
58
+ /** Source path relative to the project root. */
59
+ file: string;
60
+ format: 'module' | 'html';
61
+ /** Frame URL without the theme parameter. */
62
+ url: string;
63
+ frame: FrameSize;
64
+ theme?: Theme;
65
+ missing?: boolean;
66
+ /** Changes when anything that needs a reload changes: props, theme, stylesheet. */
67
+ rev: string;
68
+ snapshots?: Partial<Record<Theme, string>>;
69
+ /** The snapshots shrunk to a few hundred pixels wide, for the zoomed-out canvas. */
70
+ thumbs?: Partial<Record<Theme, string>>;
71
+ /** Last content height the screen reported, for `auto` frames before they load. */
72
+ measuredHeight?: number;
73
+ }
74
+ export interface UrlItem extends ItemBase {
75
+ kind: 'url';
76
+ url: string;
77
+ frame: FrameSize;
78
+ }
79
+ export interface NoteItem extends ItemBase {
80
+ kind: 'note';
81
+ /** Markdown. */
82
+ text: string;
83
+ width: number;
84
+ tone: 'note' | 'plain';
85
+ }
86
+ export interface ImageItem extends ItemBase {
87
+ kind: 'image';
88
+ url: string;
89
+ width?: number;
90
+ missing?: boolean;
91
+ }
92
+ export type CanvasItem = ScreenItem | UrlItem | NoteItem | ImageItem;
93
+ export interface CanvasSection {
94
+ id: string;
95
+ title?: string;
96
+ description?: string;
97
+ /** Wrap the row after this many items. */
98
+ columns?: number;
99
+ items: CanvasItem[];
100
+ }
101
+ export interface CanvasPage {
102
+ id: string;
103
+ title: string;
104
+ description?: string;
105
+ layout: 'sections' | 'free';
106
+ sections: CanvasSection[];
107
+ }
108
+ export interface CanvasDoc {
109
+ id: string;
110
+ title: string;
111
+ description?: string;
112
+ theme?: Theme;
113
+ pages: CanvasPage[];
114
+ issues: Issue[];
115
+ updatedAt: number;
116
+ }
117
+ export type TokenKind = 'color' | 'font' | 'text' | 'weight' | 'leading' | 'tracking' | 'spacing' | 'radius' | 'shadow' | 'blur' | 'ease' | 'animation' | 'duration' | 'breakpoint' | 'other';
118
+ export interface TokenValue {
119
+ /** As written. */
120
+ raw: string;
121
+ /** With `var()` references substituted. */
122
+ value: string;
123
+ }
124
+ export interface Token {
125
+ /** The variable screens use, such as `--ink` or `--color-brand`. */
126
+ name: string;
127
+ kind: TokenKind;
128
+ group: string;
129
+ description?: string;
130
+ light?: TokenValue;
131
+ dark?: TokenValue;
132
+ /** Tailwind theme key, such as `ink` for `--color-ink` (bg-ink, text-ink). */
133
+ utility?: string;
134
+ /** Line height paired with a text size (`--text-sm--line-height`). */
135
+ lineHeight?: string;
136
+ }
137
+ export interface ComponentDoc {
138
+ id: string;
139
+ title: string;
140
+ group: string;
141
+ description?: string;
142
+ status?: string;
143
+ /** Specimen path relative to the project root. */
144
+ specimen: string;
145
+ /** Component source paths relative to the project root. */
146
+ sources: string[];
147
+ url: string;
148
+ }
149
+ export interface GuidelineDoc {
150
+ slug: string;
151
+ title: string;
152
+ order: number;
153
+ markdown: string;
154
+ }
155
+ export interface AssetDoc {
156
+ name: string;
157
+ /** Path relative to the system folder. */
158
+ path: string;
159
+ url: string;
160
+ size: number;
161
+ kind: 'image' | 'font' | 'other';
162
+ }
163
+ export interface SystemDoc {
164
+ name: string;
165
+ description?: string;
166
+ /** Stylesheet URLs (web fonts) the screens load. */
167
+ fonts: string[];
168
+ tokens: Token[];
169
+ components: ComponentDoc[];
170
+ guidelines: GuidelineDoc[];
171
+ assets: AssetDoc[];
172
+ /** Frame URL of the built-in typography specimen. */
173
+ typographyUrl: string | null;
174
+ issues: Issue[];
175
+ }
176
+ /** What the server pushes over /api/events. */
177
+ export type DesignEvent = {
178
+ type: 'project';
179
+ } | {
180
+ type: 'canvas';
181
+ id: string;
182
+ } | {
183
+ type: 'system';
184
+ } | {
185
+ type: 'snapshot';
186
+ canvas: string;
187
+ id: string;
188
+ theme: Theme;
189
+ url: string;
190
+ height?: number;
191
+ };
192
+ /** Top, right, bottom, left. */
193
+ export type Box = [top: number, right: number, bottom: number, left: number];
194
+ /** An element in an inspected frame; `ref` names it in messages back to the frame. */
195
+ export interface Crumb {
196
+ ref: number;
197
+ label: string;
198
+ }
199
+ export interface ColorValue {
200
+ /** Readable: hex when the color is sRGB. */
201
+ value: string;
202
+ /** As computed, for painting a swatch. */
203
+ css: string;
204
+ token?: string;
205
+ }
206
+ /** What the inspector reports about the element picked in a frame. */
207
+ export interface ElementInfo {
208
+ ref: number;
209
+ tag: string;
210
+ label: string;
211
+ text?: string;
212
+ classes: string[];
213
+ attributes: [string, string][];
214
+ component?: {
215
+ owners: string[];
216
+ file?: string;
217
+ };
218
+ rect: {
219
+ x: number;
220
+ y: number;
221
+ w: number;
222
+ h: number;
223
+ };
224
+ margin: Box;
225
+ border: Box;
226
+ padding: Box;
227
+ layout: [string, string][];
228
+ typography?: {
229
+ family: string;
230
+ familyToken?: string;
231
+ size: string;
232
+ sizeToken?: string;
233
+ weight: string;
234
+ lineHeight: string;
235
+ letterSpacing: string;
236
+ color: ColorValue;
237
+ align: string;
238
+ transform?: string;
239
+ };
240
+ appearance: {
241
+ background?: ColorValue;
242
+ backgroundImage?: string;
243
+ border?: {
244
+ width: string;
245
+ style: string;
246
+ color: ColorValue;
247
+ };
248
+ radius?: {
249
+ value: string;
250
+ token?: string;
251
+ };
252
+ shadow?: {
253
+ value: string;
254
+ token?: string;
255
+ };
256
+ opacity?: string;
257
+ };
258
+ path: Crumb[];
259
+ children: Crumb[];
260
+ /** The CSS worth copying, as a block. */
261
+ css: string;
262
+ }
263
+ /**
264
+ * Messages between the viewer and the runtime inside each frame. Frames may
265
+ * sit on another origin than the viewer, so everything goes through postMessage.
266
+ */
267
+ export type RuntimeMessage = {
268
+ source: 'design-runtime';
269
+ key: string;
270
+ type: 'ready';
271
+ } | {
272
+ source: 'design-runtime';
273
+ key: string;
274
+ type: 'size';
275
+ width: number;
276
+ height: number;
277
+ } | {
278
+ source: 'design-runtime';
279
+ key: string;
280
+ type: 'error';
281
+ message: string;
282
+ } | {
283
+ source: 'design-runtime';
284
+ key: string;
285
+ type: 'go';
286
+ target: string;
287
+ } | {
288
+ source: 'design-runtime';
289
+ key: string;
290
+ type: 'wheel';
291
+ deltaX: number;
292
+ deltaY: number;
293
+ x: number;
294
+ y: number;
295
+ /** Pinch or ctrl/⌘-wheel: zoom the canvas; otherwise pan it. */
296
+ zoom: boolean;
297
+ } | {
298
+ source: 'design-runtime';
299
+ key: string;
300
+ type: 'keydown';
301
+ code: string;
302
+ }
303
+ /** ⌘/Ctrl pressed or released in the frame, or a key pressed while one is down. */
304
+ | {
305
+ source: 'design-runtime';
306
+ key: string;
307
+ type: 'key';
308
+ name: string;
309
+ down: boolean;
310
+ } | {
311
+ source: 'design-runtime';
312
+ key: string;
313
+ type: 'blur';
314
+ } | {
315
+ source: 'design-runtime';
316
+ key: string;
317
+ type: 'updated';
318
+ }
319
+ /** The picked element changed, or its styles did; null when nothing is picked. */
320
+ | {
321
+ source: 'design-runtime';
322
+ key: string;
323
+ type: 'inspect';
324
+ info: ElementInfo | null;
325
+ }
326
+ /** Escape while inspecting with nothing picked. */
327
+ | {
328
+ source: 'design-runtime';
329
+ key: string;
330
+ type: 'inspect-escape';
331
+ };
332
+ export type ViewerMessage = {
333
+ source: 'design-viewer';
334
+ type: 'theme';
335
+ theme: Theme;
336
+ }
337
+ /** The frame is on the canvas: pan and zoom with the wheel go to the viewer. */
338
+ | {
339
+ source: 'design-viewer';
340
+ type: 'canvas';
341
+ }
342
+ /** Inspect mode on or off; `tokens` let the frame name the tokens behind computed styles. */
343
+ | {
344
+ source: 'design-viewer';
345
+ type: 'inspect';
346
+ on: boolean;
347
+ tokens?: Token[];
348
+ }
349
+ /** Pick an element by the `ref` a previous report gave it, or clear the pick without reporting. */
350
+ | {
351
+ source: 'design-viewer';
352
+ type: 'inspect-select';
353
+ ref: number | null;
354
+ };
355
+ export {};
@@ -0,0 +1,20 @@
1
+ import { type QueryClient } from '@tanstack/react-query';
2
+ import type { ViewerSource } from './lib/source';
3
+ import { type ViewerScope, type ViewerSlots } from './lib/viewer';
4
+ export interface DesignViewerProps {
5
+ /** Where the project comes from: `localSource`, `staticSource` or the embedding app's own. Keep it stable. */
6
+ source: ViewerSource;
7
+ /**
8
+ * Path the viewer's routes live under, such as `/p/<projectId>`; it adds to the base of the
9
+ * wouter router around the viewer, whose location hook it also uses.
10
+ */
11
+ base?: string;
12
+ /** The `sandbox` attribute for every frame; none when unset. */
13
+ frameSandbox?: string;
14
+ slots?: ViewerSlots;
15
+ scope?: ViewerScope;
16
+ /** Shared with the embedding app; the viewer makes its own when unset. */
17
+ queryClient?: QueryClient;
18
+ }
19
+ /** The whole viewer: home, canvases, screens and the design system of one project. */
20
+ export declare function DesignViewer({ source, base, frameSandbox, slots, scope, queryClient }: DesignViewerProps): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import type { Theme } from '../../../src/shared/types';
2
+ /**
3
+ * A frame that grows to its content: system specimens and the typography page.
4
+ * The theme is sent to the running frame; changing it does not reload it.
5
+ */
6
+ export declare function AutoFrame({ src, theme, title, minHeight, width, className, }: {
7
+ src: string;
8
+ theme: Theme;
9
+ title: string;
10
+ minHeight?: number;
11
+ width?: number;
12
+ className?: string;
13
+ }): import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ /** Source with line numbers and syntax colors; the header carries the path and a copy button. */
2
+ export declare function CodeView({ code, path, className }: {
3
+ code: string;
4
+ path?: string;
5
+ className?: string;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ /** ⌘K: jump to canvases, pages, screens and system pages. */
2
+ export declare function CommandPalette(): import("react").JSX.Element;
@@ -0,0 +1,29 @@
1
+ import type { ElementInfo } from '../../../src/shared/types';
2
+ /**
3
+ * Inspect frames: while `enabled`, every frame in `frames` highlights on hover
4
+ * and picks on click. The inspecting runs inside each frame (see the runtime's
5
+ * inspect.ts); this side only switches it and shows what the frames report.
6
+ * The pick outlives `enabled` (so a quick ⌘-hold leaves the panel open) until
7
+ * it is cleared.
8
+ */
9
+ export declare function useInspection(frames: HTMLIFrameElement[], enabled: boolean, options: {
10
+ onEscape(): void;
11
+ }): {
12
+ info: ElementInfo | null;
13
+ frame: HTMLIFrameElement | null;
14
+ /** Pick another element in the same frame by its ref, or clear the pick. */
15
+ select(ref: number | null): void;
16
+ };
17
+ /**
18
+ * True while ⌘ or Ctrl is held on its own, in the viewer or inside any of
19
+ * `frames`. A modifier used for a shortcut (⌘K, ⌘C) does not count.
20
+ */
21
+ export declare function useModifierHold(frames: HTMLIFrameElement[]): boolean;
22
+ /** The right sidebar: what the selected element is and how it is styled. */
23
+ export declare function InspectorPanel({ info, onSelect, onClose, active, }: {
24
+ info: ElementInfo | null;
25
+ onSelect(ref: number): void;
26
+ onClose(): void;
27
+ /** Whether a frame is being inspected right now. */
28
+ active: boolean;
29
+ }): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import type { Issue } from '../../../src/shared/types';
2
+ export declare function IssueList({ issues, className }: {
3
+ issues: Issue[];
4
+ className?: string;
5
+ }): import("react").JSX.Element;
6
+ /** Problems found in the project's files, as a panel. */
7
+ export declare function IssuesPanel({ issues, title }: {
8
+ issues: Issue[];
9
+ title?: string;
10
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,8 @@
1
+ /** http, https, mailto or relative. Browsers drop whitespace and control characters inside a scheme, so do we. */
2
+ export declare function isSafeHref(href: string): boolean;
3
+ export declare function renderMarkdown(text: string): string;
4
+ /** Markdown from the project's own files (guidelines, notes, descriptions). */
5
+ export declare function Markdown({ text, className }: {
6
+ text: string;
7
+ className?: string;
8
+ }): import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ export declare function openPalette(): void;
2
+ /** Opens ⌘K. As tall as the buttons next to it; drops the label on narrow screens. */
3
+ export declare function SearchButton({ width, label }: {
4
+ width?: number;
5
+ label?: string;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import type { ReactNode } from 'react';
2
+ /**
3
+ * A side panel that slides open and shut. The wrapper animates its width while
4
+ * the content keeps its own, so nothing inside reflows mid-animation.
5
+ */
6
+ export declare function SlidePanel({ open, side, width, children, }: {
7
+ open: boolean;
8
+ side: 'left' | 'right';
9
+ width: number;
10
+ children: ReactNode;
11
+ }): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function ThemeMenu(): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { type ReactNode } from 'react';
2
+ /** A 52px bar across the top; pages that fill the screen compose their own content into it. */
3
+ export declare function Bar({ children, className }: {
4
+ children: ReactNode;
5
+ className?: string;
6
+ }): import("react").JSX.Element;
7
+ /** The app's top bar: project, sections, search and appearance. */
8
+ export declare function AppTopBar(): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ export declare function Mark({ size }: {
2
+ size?: number;
3
+ }): import("react").JSX.Element;
4
+ export declare function Wordmark({ name, version }: {
5
+ name?: string;
6
+ version?: string;
7
+ }): import("react").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { QueryClient } from '@tanstack/react-query';
2
+ import { type ViewerKeys } from './viewer';
3
+ export { ApiError } from './source';
4
+ /** A live source refetches on every change it announces; the others load once. */
5
+ export declare function createQueryClient(live: boolean): QueryClient;
6
+ /** Nothing in single-canvas mode needs the project. */
7
+ export declare function useProject(): import("@tanstack/react-query").UseQueryResult<import("../../../src/shared/types").ProjectInfo, Error>;
8
+ export declare function useCanvas(id: string, enabled?: boolean): import("@tanstack/react-query").UseQueryResult<import("../../../src/shared/types").CanvasDoc, Error>;
9
+ /** Null when the project has no design system. */
10
+ export declare function useSystem(enabled?: boolean): import("@tanstack/react-query").UseQueryResult<import("../../../src/shared/types").SystemDoc | null, Error>;
11
+ /** A file of the design system. */
12
+ export declare function useSource(path: string | null, unit?: string): import("@tanstack/react-query").UseQueryResult<string, Error>;
13
+ /** Keep queries fresh from the preview server's event stream. */
14
+ export declare function connectEvents(queryClient: QueryClient, keys: ViewerKeys): () => void | undefined;
@@ -0,0 +1 @@
1
+ export declare function cn(...parts: Array<string | false | null | undefined>): string;
@@ -0,0 +1 @@
1
+ export declare function copyText(text: string, label?: string): Promise<void>;
@@ -0,0 +1,2 @@
1
+ export declare function requestFocus(canvas: string, item: string): void;
2
+ export declare function takeFocus(canvas: string): string | null;
@@ -0,0 +1,3 @@
1
+ export declare function relativeTime(ms: number): string;
2
+ export declare function bytes(size: number): string;
3
+ export declare function plural(count: number, one: string, many?: string): string;
@@ -0,0 +1,25 @@
1
+ import type { RuntimeMessage, Theme, ViewerMessage } from '../../../src/shared/types';
2
+ type Handler = (message: RuntimeMessage) => void;
3
+ export declare function listenToFrame(frame: HTMLIFrameElement, handler: Handler): () => void;
4
+ type Outgoing = ViewerMessage extends infer M ? M extends {
5
+ source: 'design-viewer';
6
+ } ? Omit<M, 'source'> : never : never;
7
+ export declare function sendToFrame(frame: HTMLIFrameElement | null, message: Outgoing): void;
8
+ /** Tell a frame it sits on the canvas, so it hands the wheel to the viewer. */
9
+ export declare function claimWheel(frame: HTMLIFrameElement | null): void;
10
+ export declare function sendTheme(frame: HTMLIFrameElement | null, theme: Theme): void;
11
+ /** Load the frame again; works whatever origin it is on. */
12
+ export declare function reloadFrame(frame: HTMLIFrameElement | null): void;
13
+ /**
14
+ * Where the dev server's frames load from. Browsers give each site its own
15
+ * process, so frames served from the viewer's twin host (localhost ↔ 127.0.0.1,
16
+ * both reach the same server) run their scripts and animations off the viewer's
17
+ * thread: a canvas full of live screens still pans smoothly. Any other host,
18
+ * and static builds, keep frames on the viewer's origin.
19
+ */
20
+ export declare const FRAME_ORIGIN: string;
21
+ /** A frame URL with the theme it should open in. */
22
+ export declare function frameSrc(url: string, theme: Theme, extra?: Record<string, string>): string;
23
+ /** Absolute URL for opening a frame in a new tab. */
24
+ export declare function absoluteUrl(url: string): string;
25
+ export {};
@@ -0,0 +1,3 @@
1
+ export declare const IS_MAC: boolean;
2
+ /** The shortcut modifier as the user's keyboard labels it. */
3
+ export declare const MOD_KEY: string;
@@ -0,0 +1,43 @@
1
+ import type { CanvasDoc, ProjectInfo, SystemDoc } from '../../../src/shared/types';
2
+ declare global {
3
+ interface Window {
4
+ __DESIGN_STATIC__?: boolean;
5
+ __DESIGN_CANVAS_READY__?: boolean;
6
+ }
7
+ }
8
+ /** A site made by `design build`: JSON files instead of the API, hash routing, no live updates. */
9
+ export declare const STATIC_SITE: boolean;
10
+ /**
11
+ * Where the viewer gets a project from. Docs keep the URLs they were built
12
+ * with; relative ones (`_s/…`, `_f/…`, `_snap/…`) resolve against the `base`
13
+ * their unit comes with, so frames and images can live on another host.
14
+ */
15
+ export interface ViewerSource {
16
+ /** Keep queries fresh from the preview server's `/api/events` stream. */
17
+ live: boolean;
18
+ project(): Promise<ProjectInfo>;
19
+ canvas(id: string): Promise<{
20
+ doc: CanvasDoc;
21
+ base: string;
22
+ }>;
23
+ /** Null when the project has no design system. */
24
+ system(): Promise<{
25
+ doc: SystemDoc;
26
+ base: string;
27
+ } | null>;
28
+ /** The text of a project file; `unit` is `system` or `canvas/<id>`. */
29
+ source(path: string, unit: string): Promise<string>;
30
+ }
31
+ export declare class ApiError extends Error {
32
+ readonly status: number;
33
+ constructor(status: number, message: string);
34
+ }
35
+ export declare const localSource: ViewerSource;
36
+ /** The JSON files of a `design build` site, relative to its root. */
37
+ export declare const staticSource: ViewerSource;
38
+ /** `url` against a unit's base; an empty base leaves it as the doc has it. */
39
+ export declare function resolveUrl(url: string, base: string): string;
40
+ /** A canvas with its frame, snapshot and image URLs resolved against its unit's base. */
41
+ export declare function resolveCanvas(doc: CanvasDoc, base: string): CanvasDoc;
42
+ /** A design system with its specimen and asset URLs resolved against the system unit's base. */
43
+ export declare function resolveSystem(doc: SystemDoc, base: string): SystemDoc;
@@ -0,0 +1,10 @@
1
+ /** A tiny observable value for state shared outside React's tree. */
2
+ export declare class Store<T> {
3
+ private value;
4
+ private listeners;
5
+ constructor(value: T);
6
+ get: () => T;
7
+ set: (next: T | ((prev: T) => T)) => void;
8
+ subscribe: (listener: () => void) => () => void;
9
+ }
10
+ export declare function useStore<T, S = T>(store: Store<T>, select?: (value: T) => S): S;
@@ -0,0 +1,6 @@
1
+ export type ThemePref = 'system' | 'light' | 'dark';
2
+ export type Theme = 'light' | 'dark';
3
+ export declare function setThemePref(value: ThemePref): void;
4
+ export declare function useThemePref(): ThemePref;
5
+ /** The theme the app shows: the saved choice, or the system's. */
6
+ export declare function useTheme(): Theme;