@dexhq/canvas 0.13.0 → 0.14.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 (159) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +16 -15
  3. package/app/canvas/frame-node.tsx +34 -17
  4. package/app/canvas/tool-cursors.ts +16 -16
  5. package/app/i18n/locales/en/messages.po +26 -4
  6. package/app/i18n/locales/en/messages.ts +1 -1
  7. package/app/i18n/locales/pseudo/messages.po +26 -4
  8. package/app/i18n/locales/pseudo/messages.ts +1 -1
  9. package/app/icons/{sets/lucide.tsx → glyphs.tsx} +3 -5
  10. package/app/icons/index.tsx +3 -3
  11. package/app/icons/types.ts +3 -10
  12. package/app/index.html +3 -3
  13. package/app/pages/canvas-settings.tsx +35 -0
  14. package/app/shell/about.tsx +5 -4
  15. package/app/shell/feedback-details.ts +0 -3
  16. package/app/shell/instructions-editor.tsx +1 -1
  17. package/app/shell/presence-style.ts +59 -0
  18. package/app/shell/presence.tsx +6 -3
  19. package/app/shell/settings-sections.ts +12 -0
  20. package/app/shell/sidebar.tsx +1 -1
  21. package/app/studio-ui.d.ts +0 -9
  22. package/app/ui/prompt-editor.tsx +1 -1
  23. package/dist/cli/commands/create.d.mts +26 -14
  24. package/dist/cli/commands/create.mjs +13 -7
  25. package/dist/cli/commands/dev.mjs +2 -3
  26. package/dist/cli/commands/init.d.mts +11 -6
  27. package/dist/cli/help.d.mts +1 -1
  28. package/dist/cli/help.mjs +3 -3
  29. package/dist/cli/main.d.mts +22 -12
  30. package/dist/config/index.d.mts +6 -5
  31. package/dist/config/project-files.d.mts +0 -3
  32. package/dist/config/project-files.mjs +0 -3
  33. package/dist/config/schema.d.mts +0 -5
  34. package/dist/config/schema.mjs +0 -5
  35. package/dist/content/content.mjs +0 -3
  36. package/dist/content/snapshot-client.mjs +1 -1
  37. package/dist/paste/paste.mjs +1 -1
  38. package/dist/server/brief.mjs +3 -3
  39. package/dist/server/channel.d.mts +6 -0
  40. package/dist/server/channel.mjs +16 -1
  41. package/dist/server/claimed-presence.d.mts +17 -0
  42. package/dist/server/claimed-presence.mjs +50 -0
  43. package/dist/server/dev-server.mjs +9 -0
  44. package/dist/server/file-errors.d.mts +7 -2
  45. package/dist/server/file-errors.mjs +31 -8
  46. package/dist/server/requests.mjs +1 -1
  47. package/dist/server/studio-for.mjs +1 -1
  48. package/dist/server/vite.mjs +26 -29
  49. package/dist/server/web-app.mjs +3 -3
  50. package/dist/setup/apply.mjs +8 -14
  51. package/dist/setup/create.mjs +51 -19
  52. package/dist/setup/desktop-app.mjs +1 -1
  53. package/dist/setup/detect.d.mts +14 -5
  54. package/dist/setup/detect.mjs +56 -8
  55. package/dist/setup/doctor.mjs +1 -3
  56. package/dist/setup/existing-setup.d.mts +1 -3
  57. package/dist/setup/existing-setup.mjs +10 -11
  58. package/dist/setup/own-app.d.mts +1 -2
  59. package/dist/setup/own-app.mjs +4 -5
  60. package/dist/setup/plan.d.mts +8 -6
  61. package/dist/setup/plan.mjs +64 -48
  62. package/dist/setup/project.d.mts +0 -16
  63. package/dist/setup/project.mjs +8 -52
  64. package/dist/setup/prompts.d.mts +5 -5
  65. package/dist/setup/prompts.mjs +28 -61
  66. package/dist/setup/questions.d.mts +12 -4
  67. package/dist/setup/questions.mjs +10 -25
  68. package/dist/setup/starters.mjs +19 -8
  69. package/dist/setup/workspace-setup.d.mts +1 -2
  70. package/dist/setup/workspace-setup.mjs +4 -6
  71. package/dist/setup/write.d.mts +15 -5
  72. package/dist/setup/write.mjs +35 -9
  73. package/dist/shared/server-page.mjs +6 -0
  74. package/extension/dist/feedback.js +1 -1
  75. package/extension/dist/manifest.json +1 -1
  76. package/package.json +2 -19
  77. package/src/cli/commands/create.ts +17 -9
  78. package/src/cli/commands/dev.ts +0 -3
  79. package/src/cli/help.ts +3 -3
  80. package/src/config/index.ts +6 -5
  81. package/src/config/project-files.ts +0 -5
  82. package/src/config/schema.ts +0 -1
  83. package/src/content/content.ts +0 -3
  84. package/src/content/snapshot-client.ts +1 -1
  85. package/src/server/brief.ts +8 -3
  86. package/src/server/channel.ts +27 -0
  87. package/src/server/claimed-presence.ts +77 -0
  88. package/src/server/dev-server.ts +13 -0
  89. package/src/server/file-errors.ts +47 -13
  90. package/src/server/studio-for.ts +1 -1
  91. package/src/server/vite.ts +37 -40
  92. package/src/server/web-app.ts +3 -3
  93. package/src/setup/apply.ts +10 -16
  94. package/src/setup/create.ts +52 -20
  95. package/src/setup/desktop-app.ts +1 -1
  96. package/src/setup/detect.ts +56 -10
  97. package/src/setup/doctor.ts +4 -4
  98. package/src/setup/existing-setup.ts +10 -12
  99. package/src/setup/own-app.ts +2 -5
  100. package/src/setup/plan.ts +93 -84
  101. package/src/setup/project.ts +16 -110
  102. package/src/setup/prompts.ts +44 -127
  103. package/src/setup/questions.ts +27 -29
  104. package/src/setup/starters.ts +27 -9
  105. package/src/setup/workspace-setup.ts +8 -18
  106. package/src/setup/write.ts +52 -9
  107. package/src/shared/server-page.ts +9 -0
  108. package/templates/methods/review.md +2 -2
  109. package/templates/rules/canvas-frames.md +104 -0
  110. package/templates/rules/canvas.md +8 -142
  111. package/templates/rules/prototypes.md +1 -1
  112. package/templates/rules/snapshots.md +52 -0
  113. package/templates/starters/standalone/README.md +7 -7
  114. package/templates/starters/standalone/components.json +1 -1
  115. package/templates/starters/standalone/package.json +1 -2
  116. package/templates/starters/turborepo/README.md +6 -6
  117. package/templates/starters/turborepo/apps/web/components.json +1 -1
  118. package/templates/starters/turborepo/apps/web/package.json +1 -2
  119. package/templates/starters/turborepo/apps/web/src/app.tsx +4 -5
  120. package/templates/starters/turborepo/packages/ui/components.json +1 -1
  121. package/templates/starters/turborepo/packages/ui/package.json +1 -2
  122. package/templates/starters/vite/README.md +7 -6
  123. package/templates/starters/vite/components.json +1 -1
  124. package/templates/starters/vite/package.json +1 -2
  125. package/templates/starters/vite/src/app.tsx +3 -4
  126. package/templates/starters/vite/src/components/ui/accordion.tsx +71 -0
  127. package/templates/starters/vite/src/components/ui/attachment.tsx +1 -1
  128. package/templates/starters/vite/src/components/ui/badge.tsx +2 -2
  129. package/templates/starters/vite/src/components/ui/button.tsx +17 -12
  130. package/templates/starters/vite/src/components/ui/card.tsx +1 -1
  131. package/templates/starters/vite/src/components/ui/checkbox.tsx +28 -0
  132. package/templates/starters/vite/src/components/ui/dialog.tsx +5 -5
  133. package/templates/starters/vite/src/components/ui/dropdown-menu.tsx +17 -14
  134. package/templates/starters/vite/src/components/ui/field.tsx +3 -1
  135. package/templates/starters/vite/src/components/ui/input-group.tsx +5 -3
  136. package/templates/starters/vite/src/components/ui/input.tsx +1 -1
  137. package/templates/starters/vite/src/components/ui/label.tsx +2 -0
  138. package/templates/starters/vite/src/components/ui/native-select.tsx +3 -4
  139. package/templates/starters/vite/src/components/ui/popover.tsx +1 -1
  140. package/templates/starters/vite/src/components/ui/separator.tsx +2 -0
  141. package/templates/starters/vite/src/components/ui/spinner.tsx +3 -7
  142. package/templates/starters/vite/src/components/ui/switch.tsx +1 -1
  143. package/templates/starters/vite/src/components/ui/textarea.tsx +1 -1
  144. package/templates/starters/vite/src/components/ui/toggle.tsx +4 -2
  145. package/templates/starters/vite/src/index.css +533 -111
  146. package/app/icons/sets/hugeicons.tsx +0 -259
  147. package/app/icons/sets/phosphor.tsx +0 -251
  148. package/dist/server/icon-set.d.mts +0 -15
  149. package/dist/server/icon-set.mjs +0 -31
  150. package/dist/shared/icon-sets.d.mts +0 -9
  151. package/dist/shared/icon-sets.mjs +0 -21
  152. package/src/server/icon-set.ts +0 -56
  153. package/src/shared/icon-sets.ts +0 -23
  154. /package/app/public/{sudio-192.png → dex-192.png} +0 -0
  155. /package/app/public/{sudio-512.png → dex-512.png} +0 -0
  156. /package/app/public/{apple-touch-icon.png → dex-apple-touch-icon.png} +0 -0
  157. /package/app/public/{favicon-32.png → dex-icon-32.png} +0 -0
  158. /package/app/public/{favicon.svg → dex-icon.svg} +0 -0
  159. /package/app/public/{sudio-maskable-512.png → dex-maskable-512.png} +0 -0
@@ -9,7 +9,6 @@ import type { Alias } from "vite";
9
9
  import { highestMajor, isDirectory, isFile, posix } from "../paths.ts";
10
10
  import { isRecord } from "../shared/checks.ts";
11
11
  import type { StylingApproach } from "../shared/design-system.ts";
12
- import { INTERFACE_ICONS, type InterfaceIcons } from "../shared/icon-sets.ts";
13
12
 
14
13
  type Json = Record<string, unknown>;
15
14
 
@@ -543,8 +542,6 @@ export interface ComponentsJson {
543
542
  file: string;
544
543
  /** The folder its `ui` alias points at. */
545
544
  folder: string;
546
- /** The icon set it draws with (`iconLibrary`), when the interface has it. */
547
- icons: InterfaceIcons | undefined;
548
545
  /** How code at the root imports the folder's files: "@/components/ui". */
549
546
  import: string;
550
547
  }
@@ -583,7 +580,6 @@ export function readComponentsJson(
583
580
  const folder =
584
581
  resolveAlias(alias, dir) ?? exported ?? join(dir, "components", "ui");
585
582
  const css = stringAt(objectAt(config, "tailwind"), "css");
586
- const iconLibrary = stringAt(config, "iconLibrary");
587
583
  return {
588
584
  file,
589
585
  folder,
@@ -594,7 +590,6 @@ export function readComponentsJson(
594
590
  ? alias
595
591
  : (importBaseFor(folder, root) ?? alias),
596
592
  css: css ? join(dir, css) : undefined,
597
- icons: INTERFACE_ICONS.find((set) => set === iconLibrary),
598
593
  baseUi: String(config.style ?? "").startsWith("base-"),
599
594
  };
600
595
  }
@@ -100,7 +100,6 @@ const ui = z.looseObject({
100
100
  accent: z.string().optional(),
101
101
  chromeTheme: z.partialRecord(z.enum(CHROME_VARIABLES), z.string()).optional(),
102
102
  components: text.optional(),
103
- icons: z.enum(["phosphor", "lucide", "hugeicons"]).optional(),
104
103
  locale: z.string().optional(),
105
104
  primitives: z.union([text, z.literal(true)]).optional(),
106
105
  subtitle: z.string().optional(),
@@ -532,7 +532,6 @@ const CHROME_IMPORTS = [
532
532
  "react",
533
533
  // The config's ui settings and the project's own interface components.
534
534
  "virtual:studio-ui",
535
- "virtual:studio-icons",
536
535
  "react-dom",
537
536
  "wouter",
538
537
  "next-themes",
@@ -551,8 +550,6 @@ const CHROME_IMPORTS = [
551
550
  // (canvas/activity-bar.tsx, canvas/activity.tsx).
552
551
  "motion/react",
553
552
  "tw-animate-css",
554
- "@hugeicons/",
555
- "@phosphor-icons/",
556
553
  "@lingui/",
557
554
  "@fontsource-variable/inter",
558
555
  "@studio/",
@@ -41,7 +41,7 @@ function unreachable(url: string, error: unknown): SnapshotError {
41
41
  ?.cause;
42
42
  if (cause?.code && NOT_LISTENING.has(cause.code)) {
43
43
  return new SnapshotError(
44
- `Dex is not running at ${url}. Start it with \`npx dex dev\` (or the project's own script, such as \`npm run studio\`), then try again.`
44
+ `Dex is not running at ${url}. Start it with \`npx dex dev\` (or the project's own script, such as \`npm run dex\`), then try again.`
45
45
  );
46
46
  }
47
47
  const why = cause?.message ?? (error as Error)?.message ?? String(error);
@@ -53,7 +53,7 @@ import { flowSpecs } from "../content/flow-specs.ts";
53
53
  import { checkPrototype } from "../content/prototype-checks.ts";
54
54
  import { prototypePaths } from "../content/prototypes.ts";
55
55
  import { readText } from "../content/read-text.ts";
56
- import { shownFrom } from "../paths.ts";
56
+ import { shownFrom, TEMPLATES_DIR } from "../paths.ts";
57
57
  import { designSystemGuide } from "../setup/design-system-guide.ts";
58
58
  import {
59
59
  ALWAYS_ON,
@@ -352,12 +352,17 @@ async function guidesSection(
352
352
  const when = always
353
353
  ? "Whatever the work: read it first"
354
354
  : frontMatterValue(yaml, WHEN_RE);
355
- return `\`${show(guide.file)}\`${guide.own ? " (the team's own)" : ""}${when ? `: ${words(when)}` : ""}`;
355
+ const name = guide.own
356
+ ? `\`${show(guide.file)}\` (the team's own)`
357
+ : `\`${guide.path}\``;
358
+ return `${name}${when ? `: ${words(when)}` : ""}`;
356
359
  })
357
360
  );
361
+ // The package's folder is named once, not on every entry: the brief is
362
+ // in every session, and the prefix was a tenth of it.
358
363
  return [
359
364
  "## Dex's rules and methods",
360
- `Read one when the work is what it says.\n\n${listed(
365
+ `Read one when the work is what it says. Dex's are in \`${show(TEMPLATES_DIR)}/\`; the team's own are where they say.\n\n${listed(
361
366
  entries.filter(Boolean),
362
367
  (more) => `and ${more} in those folders`,
363
368
  MAX_GUIDES
@@ -386,6 +386,33 @@ export async function connectedAgents(
386
386
  return agents;
387
387
  }
388
388
 
389
+ /**
390
+ * The agent sessions running on this machine now, by their heartbeats: not a
391
+ * teammate's, whose claims come from the workspace. Reads only; clearing old
392
+ * heartbeats is connectedAgents's.
393
+ */
394
+ export async function localSessions(
395
+ root: string,
396
+ now = Date.now()
397
+ ): Promise<Set<string>> {
398
+ const dir = studioState(root).agents;
399
+ const sessions = new Set<string>();
400
+ const names = await readdir(dir).catch(() => []);
401
+ for (const name of names.filter(isHeartbeat)) {
402
+ try {
403
+ const beat: Heartbeat = JSON.parse(
404
+ await readFile(join(dir, name), "utf8")
405
+ );
406
+ if (beat.session && now - beat.at < LISTENING_MS) {
407
+ sessions.add(beat.session);
408
+ }
409
+ } catch {
410
+ // A heartbeat mid-write: it will be whole next time.
411
+ }
412
+ }
413
+ return sessions;
414
+ }
415
+
389
416
  /** A heartbeat file's process, as it is named: "62653.json". */
390
417
  const pidOf = (name: string): { pid?: number } => {
391
418
  const digits = PID_FILE_RE.exec(name)?.[1];
@@ -0,0 +1,77 @@
1
+ // An agent at work on a comment shows on the canvas once it edits the view or
2
+ // doc the comment is on, whichever agent it is. Claude Code marks its own
3
+ // edits through its hook (`dex hook`), but Codex, Cursor and the rest have no
4
+ // hook, so the dev server, which sees every file in a prototype change, marks
5
+ // the session on this machine holding a claimed thread there. The mark is the
6
+ // thread's own target, so closing the thread clears it (agent-session.ts);
7
+ // otherwise it expires as a hook's does.
8
+
9
+ import { relative } from "node:path";
10
+ import type { ThreadModule } from "../content/thread-module.ts";
11
+ import { targetForPath } from "../shared/live-presence.ts";
12
+ import { claimOf } from "../shared/threads-core.ts";
13
+ import { presenceTargetOf } from "./agent-session.ts";
14
+ import type { PresenceMark } from "./presence.ts";
15
+
16
+ /** How often one claim's session is marked again while it edits. */
17
+ const REMARK_MS = 10_000;
18
+
19
+ /**
20
+ * Mark the agent sessions with a claimed thread on the view or doc `file`
21
+ * belongs to as working on it. `file` is absolute; `content` is the studio's
22
+ * content folder. `sessions` are the agent sessions running on this machine:
23
+ * a teammate's claim, synced from the workspace, is never marked here.
24
+ */
25
+ export function claimedPresence({
26
+ content,
27
+ mark,
28
+ sessions,
29
+ threads,
30
+ now = Date.now,
31
+ }: {
32
+ content: string;
33
+ mark: (entry: PresenceMark) => Promise<void>;
34
+ sessions: () => Promise<Set<string>>;
35
+ threads: Pick<ThreadModule, "list">;
36
+ now?: () => number;
37
+ }) {
38
+ const marked = new Map<string, number>();
39
+ return async (file: string): Promise<void> => {
40
+ const edited = targetForPath(relative(content, file).replaceAll("\\", "/"));
41
+ if (!edited || edited.target === "prototype") {
42
+ return;
43
+ }
44
+ const claimed = await threads.list({
45
+ prototype: edited.slug,
46
+ status: "acknowledged",
47
+ });
48
+ const time = now();
49
+ const marks: PresenceMark[] = [];
50
+ let local: Set<string> | undefined;
51
+ for (const thread of claimed) {
52
+ const claim = claimOf(thread);
53
+ const session = claim?.session;
54
+ if (
55
+ !(claim && session) ||
56
+ presenceTargetOf(thread)?.target !== edited.target
57
+ ) {
58
+ continue;
59
+ }
60
+ // Each claim's first edit marks at once, even just after another
61
+ // claim on the same view was resolved and its mark cleared.
62
+ const key = [session, thread.id, edited.slug, edited.target].join(
63
+ "\u0001"
64
+ );
65
+ if (time - (marked.get(key) ?? Number.NEGATIVE_INFINITY) < REMARK_MS) {
66
+ continue;
67
+ }
68
+ local ??= await sessions();
69
+ if (!local.has(session)) {
70
+ continue;
71
+ }
72
+ marked.set(key, time);
73
+ marks.push({ ...edited, agent: claim.by, session });
74
+ }
75
+ await Promise.all(marks.map(mark));
76
+ };
77
+ }
@@ -39,6 +39,8 @@ import {
39
39
  type StudioFileKind,
40
40
  } from "../shared/studio-files.ts";
41
41
  import { WORKSPACE_ICON_FILES } from "../shared/workspace.ts";
42
+ import { localSessions } from "./channel.ts";
43
+ import { claimedPresence } from "./claimed-presence.ts";
42
44
  import { openPresence } from "./presence.ts";
43
45
  import {
44
46
  type DesktopAppHost,
@@ -184,6 +186,15 @@ export function studioDev(project: StudioDevProject): Plugin {
184
186
  );
185
187
  };
186
188
 
189
+ // An agent without a hook shows at work once it edits the view its claimed
190
+ // comment is on.
191
+ const markClaimed = claimedPresence({
192
+ content,
193
+ mark: presence.mark,
194
+ sessions: () => localSessions(content),
195
+ threads,
196
+ });
197
+
187
198
  const sendPresence = async () =>
188
199
  events.send(studioEvent.presence(await presence.list()));
189
200
 
@@ -256,6 +267,8 @@ export function studioDev(project: StudioDevProject): Plugin {
256
267
  for (const event of eventsForFile(relative(content, file))) {
257
268
  events.send(event);
258
269
  }
270
+ // Presence only shows the work; a mark that fails changes nothing.
271
+ markClaimed(file).catch(() => undefined);
259
272
  };
260
273
  for (const event of ["add", "change", "unlink"] as const) {
261
274
  server.watcher.on(event, onFile);
@@ -16,9 +16,13 @@ import {
16
16
  // one file in one frame. Here, before Vite's own error handler, such an
17
17
  // error is answered and logged without that, and the file joins the list
18
18
  // of files that can't be read (src/shared/file-errors.ts), which the frame
19
- // that failed shows. A file leaves the list once it changes, transforms
20
- // again, or goes. Errors elsewhere, in the studio or the design system, or in a JSON
21
- // file, are left to Vite, overlay and all.
19
+ // that failed shows. A file leaves the list once it changes, loads, or goes,
20
+ // and every file leaves it when a file appears, which may be the one an
21
+ // import was waiting for. Not as a page asks for it again, before it loads:
22
+ // each frame tries a file that leaves the list again at once, so one still
23
+ // broken would be asked for, and fail, as fast as the frames can ask. Errors
24
+ // elsewhere, in the studio or the design system, or in a JSON file, are left
25
+ // to Vite, overlay and all.
22
26
 
23
27
  const QUERY_RE = /[?#].*$/;
24
28
  // The files a page loads as code. A JSON file the studio itself starts
@@ -95,15 +99,31 @@ export function describeFileError(
95
99
  };
96
100
  }
97
101
 
98
- /** Keeps a broken file in the content folder from breaking every page on the server. */
99
- export const fileErrors = (content: string): Plugin => {
102
+ /**
103
+ * Keeps a broken file in the content folder from breaking every page on the
104
+ * server. `imports` is the folder outside it that views import from, the
105
+ * components' (vite.ts): Vite watches only the files it loaded, so a file
106
+ * appearing there, such as a component shadcn adds, would go unseen.
107
+ */
108
+ export const fileErrors = (content: string, imports?: string): Plugin => {
100
109
  const errors = new Map<string, FileError>();
101
110
  let server: ViteDevServer | undefined;
102
111
  const list = () => [...errors.values()];
103
112
  const tell = () => server?.ws.send(FILE_ERRORS_EVENT, list());
104
- const forget = (file: string) => {
113
+ const listed = (file: string) => {
105
114
  const path = inContent(content, file.replace(QUERY_RE, ""));
106
- if (path && errors.delete(path)) {
115
+ return path && errors.has(path) ? path : undefined;
116
+ };
117
+ const forget = (file: string) => {
118
+ const path = listed(file);
119
+ if (path) {
120
+ errors.delete(path);
121
+ tell();
122
+ }
123
+ };
124
+ const forgetAll = () => {
125
+ if (errors.size > 0) {
126
+ errors.clear();
107
127
  tell();
108
128
  }
109
129
  };
@@ -119,8 +139,27 @@ export const fileErrors = (content: string): Plugin => {
119
139
  // to it reaches no page: it leaves the list instead, which tells the
120
140
  // frames to try it again. Still broken, it joins it again as they do.
121
141
  devServer.watcher.on("change", forget);
122
- devServer.watcher.on("add", forget);
142
+ devServer.watcher.on("add", forgetAll);
123
143
  devServer.watcher.on("unlink", forget);
144
+ if (imports) {
145
+ devServer.watcher.add(imports);
146
+ }
147
+ // Whatever fixed it, a package installed or a file added where nothing
148
+ // watches, a file on the list that loads leaves it.
149
+ devServer.middlewares.use((request, response, next) => {
150
+ const file =
151
+ errors.size > 0
152
+ ? fileOf({}, request.url, devServer.config.root)
153
+ : undefined;
154
+ if (file && listed(file)) {
155
+ response.once("finish", () => {
156
+ if (response.statusCode < 400) {
157
+ forget(file);
158
+ }
159
+ });
160
+ }
161
+ next();
162
+ });
124
163
  // After Vite's own middleware, so this sees the errors they pass on.
125
164
  return () => {
126
165
  const onError: Connect.ErrorHandleFunction = (
@@ -158,10 +197,5 @@ export const fileErrors = (content: string): Plugin => {
158
197
  devServer.middlewares.use(onError);
159
198
  };
160
199
  },
161
- transform(_code, id) {
162
- if (errors.size > 0) {
163
- forget(id);
164
- }
165
- },
166
200
  };
167
201
  };
@@ -137,7 +137,7 @@ export async function studioFor(
137
137
  }
138
138
 
139
139
  const START =
140
- "Start it with `npx dex dev` (or the project's own script, such as `npm run studio`), then try again.";
140
+ "Start it with `npx dex dev` (or the project's own script, such as `npm run dex`), then try again.";
141
141
 
142
142
  const ports = (tried: number[]): string =>
143
143
  tried.map((port) => `:${port}`).join(", ");
@@ -60,7 +60,6 @@ import type {
60
60
  DesignComponent,
61
61
  StudioDesignSystemGuide,
62
62
  } from "../shared/design-system.ts";
63
- import type { InterfaceIcons } from "../shared/icon-sets.ts";
64
63
  import { ME_META } from "../shared/studio-routes.ts";
65
64
  import {
66
65
  publicThreads,
@@ -76,7 +75,6 @@ import { CloudError } from "./cloud.ts";
76
75
  import { studioDev } from "./dev-server.ts";
77
76
  import { type Feature, features } from "./features.ts";
78
77
  import { fileErrors } from "./file-errors.ts";
79
- import { interfaceIconSet } from "./icon-set.ts";
80
78
  import { type Me, readMe } from "./me.ts";
81
79
  import { lacksNext, next } from "./next.ts";
82
80
  import { projectPublic } from "./project-public.ts";
@@ -279,6 +277,35 @@ const interfaceTakesDesignSystem = (project: StudioProject): boolean =>
279
277
  project.ui?.theme === "design-system" ||
280
278
  Boolean(project.ui?.components || project.ui?.primitives);
281
279
 
280
+ /**
281
+ * Where views import the project's components from: the top folder of the
282
+ * package they are in ("src" for src/components/ui), which holds what views
283
+ * import beside them too, such as a block shadcn adds to src/components.
284
+ * Vite's root is Dex's own, so neither Tailwind nor Vite's watcher finds any
285
+ * of it on their own, as they do in the project: views' Tailwind scans it,
286
+ * and the watcher sees a file appear in it (file-errors.ts). Never the
287
+ * package itself, which for an app is the whole repository, its node_modules
288
+ * and Dex's output with it; a package in node_modules gives its components'
289
+ * folder alone.
290
+ */
291
+ function componentsRoot(project: StudioProject): string | undefined {
292
+ const folder = project.designSystem?.componentSource?.folder;
293
+ if (!folder) {
294
+ return;
295
+ }
296
+ const home = project.designSystem?.componentPackage ?? project.root;
297
+ const path = relative(home, folder);
298
+ if (
299
+ !path ||
300
+ path.startsWith("..") ||
301
+ isAbsolute(path) ||
302
+ folder.split(sep).includes("node_modules")
303
+ ) {
304
+ return folder;
305
+ }
306
+ return join(home, path.split(sep)[0] ?? "");
307
+ }
308
+
282
309
  /**
283
310
  * Two stylesheets per project, one for each page. The frame page's is what
284
311
  * the real product would have: the design system's CSS (it brings Tailwind
@@ -306,7 +333,6 @@ export async function writeEntries(
306
333
  .map((folder) => `@source "${from(folder)}";`)
307
334
  ),
308
335
  ];
309
- const componentFolder = project.designSystem?.componentSource?.folder;
310
336
  const tailwind = tailwindSetup(project.root);
311
337
  // Tailwind 3's config, for Tailwind 4 wherever the design system's theme is
312
338
  // used: the one beside the components views render (Dub's packages/ui, for
@@ -324,7 +350,7 @@ export async function writeEntries(
324
350
  `@import "${from(join(APP_DIR, "frame.css"))}";`,
325
351
  ...config,
326
352
  `@source "${from(prototypesDir(project.content))}";`,
327
- ...sources([componentFolder]),
353
+ ...sources([componentsRoot(project)]),
328
354
  "",
329
355
  ].join("\n");
330
356
  const own = [
@@ -386,22 +412,14 @@ async function sourceFiles(dir: string): Promise<string[]> {
386
412
  return files;
387
413
  }
388
414
 
389
- const ICON_SETS_DIR = join(APP_DIR, "icons", "sets");
390
- const iconSetFile = (set: InterfaceIcons): string =>
391
- join(ICON_SETS_DIR, `${set}.tsx`);
392
-
393
415
  /**
394
- * Every library the studio's own interface imports, with only the icon set
395
- * it draws with: the others may not be installed. Installed from npm, the
416
+ * Every library the studio's own interface imports. Installed from npm, the
396
417
  * interface lives in node_modules, where Vite neither crawls imports nor
397
418
  * converts CommonJS for the browser, so they are listed for it to prepare.
398
419
  */
399
- async function interfaceDependencies(icons: InterfaceIcons): Promise<string[]> {
420
+ async function interfaceDependencies(): Promise<string[]> {
400
421
  const found = new Set<string>();
401
- const files = (await sourceFiles(APP_DIR)).filter(
402
- (file) => dirname(file) !== ICON_SETS_DIR || file === iconSetFile(icons)
403
- );
404
- for (const file of files) {
422
+ for (const file of await sourceFiles(APP_DIR)) {
405
423
  for (const specifier of importsIn(await readFile(file, "utf8"))) {
406
424
  // Macros compile away (studioMacros); bundled, they throw at runtime.
407
425
  if (!MACRO_IMPORT_RE.test(specifier)) {
@@ -468,26 +486,6 @@ const studioMacros = (): Plugin => {
468
486
  };
469
487
  };
470
488
 
471
- const ICONS_MODULE = "virtual:studio-icons";
472
- const RESOLVED_ICONS_MODULE = `\0${ICONS_MODULE}`;
473
-
474
- /**
475
- * `virtual:studio-icons`: the glyphs of the icon set the interface draws
476
- * with (interfaceIconSet). Only that set is bundled.
477
- */
478
- const studioIcons = (project: StudioProject): Plugin => {
479
- const set = interfaceIconSet(project);
480
- return {
481
- name: "studio-icons",
482
- resolveId: (id) =>
483
- id === ICONS_MODULE ? RESOLVED_ICONS_MODULE : undefined,
484
- load: (id) =>
485
- id === RESOLVED_ICONS_MODULE
486
- ? `export { glyphs } from ${JSON.stringify(iconSetFile(set))};\n`
487
- : undefined,
488
- };
489
- };
490
-
491
489
  /**
492
490
  * While serving, what a module made from `build` in dex.config.ts has is
493
491
  * made again once the file changes (Settings → Deployment writes it), so a
@@ -630,9 +628,9 @@ const studioInterface = (project: StudioProject): Plugin => {
630
628
  const build = serving
631
629
  ? await readBuildSettings(project.root)
632
630
  : project.build;
633
- const { title, subtitle, theme, locale, chromeTheme, components, icons } =
631
+ const { title, subtitle, theme, locale, chromeTheme, components } =
634
632
  project.ui ?? {};
635
- const settings = `export const ui = ${JSON.stringify({ title: workspaceName(title), subtitle, theme, locale, chromeTheme, icons, workspaceIcon })};`;
633
+ const settings = `export const ui = ${JSON.stringify({ title: workspaceName(title), subtitle, theme, locale, chromeTheme, workspaceIcon })};`;
636
634
  const slots = components
637
635
  ? `export * as slots from ${JSON.stringify(resolve(project.root, components))};`
638
636
  : "export const slots = {};";
@@ -1114,7 +1112,6 @@ export async function viteConfig(
1114
1112
  reactFromStudio(),
1115
1113
  tailwindcss(),
1116
1114
  studioInterface(project),
1117
- studioIcons(project),
1118
1115
  studioThreads(project),
1119
1116
  studioDesignSystem(project),
1120
1117
  studioComponents(project),
@@ -1125,7 +1122,7 @@ export async function viteConfig(
1125
1122
  ...((await lacksNext(project)) ? [next()] : []),
1126
1123
  studioDev(project),
1127
1124
  // A broken file in the content folder breaks only what loads it.
1128
- fileErrors(project.content),
1125
+ fileErrors(project.content, componentsRoot(project)),
1129
1126
  studioWebApp(project),
1130
1127
  projectPublic(project.root),
1131
1128
  ],
@@ -1164,7 +1161,7 @@ export async function viteConfig(
1164
1161
  },
1165
1162
  },
1166
1163
  optimizeDeps: {
1167
- include: await interfaceDependencies(interfaceIconSet(project)),
1164
+ include: await interfaceDependencies(),
1168
1165
  },
1169
1166
  preview: { port: project.port },
1170
1167
  // The instructions editor is a large chunk on purpose: it loads only
@@ -71,10 +71,10 @@ const webAppManifest = (name: string): WebAppManifest => ({
71
71
  background_color: LIGHT,
72
72
  theme_color: LIGHT,
73
73
  icons: [
74
- { src: "sudio-192.png", sizes: "192x192", type: "image/png" },
75
- { src: "sudio-512.png", sizes: "512x512", type: "image/png" },
74
+ { src: "dex-192.png", sizes: "192x192", type: "image/png" },
75
+ { src: "dex-512.png", sizes: "512x512", type: "image/png" },
76
76
  {
77
- src: "sudio-maskable-512.png",
77
+ src: "dex-maskable-512.png",
78
78
  sizes: "512x512",
79
79
  type: "image/png",
80
80
  purpose: "maskable",
@@ -28,7 +28,6 @@ import { type AgentsSetUp, addAgent, setUpAgents } from "../server/agents.ts";
28
28
  import { nextPackage } from "../server/next.ts";
29
29
  import { STATE_FOLDER } from "../server/state.ts";
30
30
  import type { StylingApproach } from "../shared/design-system.ts";
31
- import { ICON_SET_NAMES } from "../shared/icon-sets.ts";
32
31
  import { jsonLike } from "../shared/json-style.ts";
33
32
  import { STUDIO_FILES } from "../shared/studio-files.ts";
34
33
  import { choicesOnly, type DesignSystemChoices } from "./config-choices.ts";
@@ -75,8 +74,10 @@ import {
75
74
  ignoreFile,
76
75
  missingIgnoreLines,
77
76
  missingScripts,
77
+ pnpmDecidesEsbuild,
78
78
  STUDIO_TYPES,
79
79
  tsconfigJson,
80
+ withEsbuildBuilds,
80
81
  withIgnoreLines,
81
82
  withPointer,
82
83
  } from "./write.ts";
@@ -292,18 +293,9 @@ function afterShadcn(root: string, decisions: SetupDecisions): SetupDecisions {
292
293
  }
293
294
  const choice = componentsChoice(library, root);
294
295
  const value: ComponentsDecision = { kind: "folder", choice };
295
- const icons = choice.icons ?? decisions.icons.value;
296
296
  return {
297
297
  ...decisions,
298
298
  components: { ...decisions.components, value },
299
- icons:
300
- decisions.icons.source === "--icons"
301
- ? decisions.icons
302
- : {
303
- ...decisions.icons,
304
- value: icons,
305
- shown: ICON_SET_NAMES[icons],
306
- },
307
299
  // A stylesheet given or left out with --styles stays as it was.
308
300
  styles:
309
301
  decisions.styles.value || decisions.styles.source === NO_STYLES
@@ -419,7 +411,6 @@ async function writeStep(
419
411
  configSource(written, {
420
412
  studio: posix(relative(packageDir, content)) || ".",
421
413
  primitives: decisions.primitives.value,
422
- icons: decisions.icons.value,
423
414
  next:
424
415
  nextPackage(
425
416
  nextFolders(packageDir, decisions, resolved?.componentPackage)
@@ -439,7 +430,6 @@ async function writeStep(
439
430
  await write(file, STUDIO_TYPES);
440
431
  } else if (step.write === "scripts") {
441
432
  const spec = plan.workspace?.studioSpec;
442
- const icons = plan.workspace ? plan.iconPackages : {};
443
433
  // Its own app's dev is the studio: it gets no script of its own.
444
434
  const own = plan.target.kind === "own-app";
445
435
  await editManifest(file, (manifest) => {
@@ -448,11 +438,10 @@ async function writeStep(
448
438
  manifest.scripts = { ...scripts, ...missingScripts(scripts) };
449
439
  }
450
440
  // In a workspace the package asks for the studio; the root installs.
451
- if (spec || Object.keys(icons).length > 0) {
441
+ if (spec) {
452
442
  manifest.devDependencies = {
453
443
  ...recordAt(manifest, "devDependencies"),
454
- ...(spec ? { [PACKAGE_NAME]: spec } : {}),
455
- ...icons,
444
+ [PACKAGE_NAME]: spec,
456
445
  };
457
446
  }
458
447
  });
@@ -460,7 +449,7 @@ async function writeStep(
460
449
  const script = plan.workspace.studioScript;
461
450
  await editManifest(file, (manifest) => {
462
451
  const scripts = recordAt(manifest, "scripts");
463
- manifest.scripts = { ...scripts, studio: scripts.studio ?? script };
452
+ manifest.scripts = { ...scripts, dex: scripts.dex ?? script };
464
453
  });
465
454
  } else {
466
455
  await editProjectFile(step, file, plan);
@@ -486,6 +475,11 @@ async function editProjectFile(
486
475
  await writeFile(file, withIgnoreLines(text, missing));
487
476
  } else if (step.write === "pointer") {
488
477
  await writeFile(file, withPointer(text, studio));
478
+ } else if (step.write === "pnpm-builds") {
479
+ const edited = withEsbuildBuilds(text);
480
+ if (edited !== undefined && !pnpmDecidesEsbuild(text)) {
481
+ await writeFile(file, edited);
482
+ }
489
483
  }
490
484
  }
491
485