@dexhq/canvas 0.14.0 → 0.15.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 (229) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +5 -3
  3. package/app/canvas/activity.tsx +8 -15
  4. package/app/canvas/anchoring.ts +3 -5
  5. package/app/canvas/canvas-input.ts +151 -14
  6. package/app/canvas/canvas-keys.ts +9 -0
  7. package/app/canvas/canvas-model.ts +5 -42
  8. package/app/canvas/canvas-panels.ts +1 -17
  9. package/app/canvas/canvas-scene.ts +7 -3
  10. package/app/canvas/canvas-ui.ts +2 -1
  11. package/app/canvas/canvas.css +61 -26
  12. package/app/canvas/change-notice.tsx +10 -1
  13. package/app/canvas/comment-layer.tsx +2 -1
  14. package/app/canvas/comments.tsx +204 -82
  15. package/app/canvas/element-picker.ts +200 -27
  16. package/app/canvas/engine/canvas-gestures.ts +72 -17
  17. package/app/canvas/engine/canvas-store.ts +17 -1
  18. package/app/canvas/engine/engine.css +6 -3
  19. package/app/canvas/find-bar.tsx +817 -0
  20. package/app/canvas/find-model.ts +135 -0
  21. package/app/canvas/flow-canvas.tsx +18 -2
  22. package/app/canvas/follow-pin.ts +26 -6
  23. package/app/canvas/frame-node.tsx +9 -9
  24. package/app/canvas/imported-reviews.tsx +12 -22
  25. package/app/canvas/layout.ts +27 -0
  26. package/app/canvas/live-page.ts +142 -19
  27. package/app/canvas/page-find.ts +220 -0
  28. package/app/canvas/page-style.ts +23 -0
  29. package/app/canvas/section-node.tsx +2 -0
  30. package/app/canvas/spec-threads.ts +24 -23
  31. package/app/canvas/thread-focus.tsx +14 -12
  32. package/app/canvas/use-activity.ts +0 -8
  33. package/app/canvas/use-agent-changes.tsx +34 -40
  34. package/app/canvas/use-canvas-clipboard.tsx +11 -14
  35. package/app/canvas/xray.ts +3 -12
  36. package/app/frame.tsx +5 -0
  37. package/app/i18n/locales/en/messages.po +88 -8
  38. package/app/i18n/locales/en/messages.ts +1 -1
  39. package/app/i18n/locales/pseudo/messages.po +88 -8
  40. package/app/i18n/locales/pseudo/messages.ts +1 -1
  41. package/app/icons/glyphs.tsx +4 -0
  42. package/app/main.tsx +3 -0
  43. package/app/pages/canvas.tsx +27 -8
  44. package/app/pages/commands-settings.tsx +16 -2
  45. package/app/shell/feedback-form.tsx +10 -21
  46. package/app/shell/feedback-link.tsx +2 -1
  47. package/app/shell/scaled-frame.tsx +21 -9
  48. package/app/types.ts +21 -205
  49. package/app/ui/file-drop.ts +128 -0
  50. package/app/ui/shadcn/input-group.tsx +2 -2
  51. package/dist/cli/banner.d.mts +4 -2
  52. package/dist/cli/banner.mjs +34 -11
  53. package/dist/cli/commands/app.mjs +19 -11
  54. package/dist/cli/commands/hook.mjs +2 -1
  55. package/dist/config/project-files.d.mts +6 -0
  56. package/dist/config/project-files.mjs +14 -2
  57. package/dist/config/renamed.d.mts +0 -2
  58. package/dist/config/renamed.mjs +1 -3
  59. package/dist/content/capture.d.mts +2 -2
  60. package/dist/content/capture.mjs +2 -2
  61. package/dist/content/content.d.mts +3 -141
  62. package/dist/content/content.mjs +7 -62
  63. package/dist/content/flow-specs.mjs +1 -1
  64. package/dist/content/prototype-summary.d.mts +3 -39
  65. package/dist/content/prototype-summary.mjs +2 -3
  66. package/dist/content/prototypes.mjs +1 -1
  67. package/dist/content/text-replace.d.mts +30 -0
  68. package/dist/content/text-replace.mjs +309 -0
  69. package/dist/content/thread-module.mjs +1 -1
  70. package/dist/content/threads.mjs +1 -1
  71. package/dist/paste/paste.mjs +1 -1
  72. package/dist/paths.d.mts +0 -2
  73. package/dist/paths.mjs +1 -3
  74. package/dist/server/agent-env.d.mts +5 -1
  75. package/dist/server/agent-env.mjs +7 -2
  76. package/dist/server/agent-session.d.mts +14 -1
  77. package/dist/server/agent-session.mjs +84 -19
  78. package/dist/server/build-pictures.mjs +1 -1
  79. package/dist/server/channel.d.mts +13 -24
  80. package/dist/server/channel.mjs +55 -37
  81. package/dist/server/claimed-presence.d.mts +3 -2
  82. package/dist/server/claimed-presence.mjs +15 -7
  83. package/dist/server/close-check.mjs +2 -2
  84. package/dist/server/comments/actions.d.mts +153 -0
  85. package/dist/server/comments/actions.mjs +154 -0
  86. package/dist/server/comments/routes.d.mts +25 -0
  87. package/dist/server/comments/routes.mjs +88 -0
  88. package/dist/server/comments/tools.d.mts +6 -0
  89. package/dist/server/comments/tools.mjs +154 -0
  90. package/dist/server/dev-server.mjs +27 -13
  91. package/dist/server/file-lock.d.mts +2 -2
  92. package/dist/server/file-lock.mjs +130 -36
  93. package/dist/server/mcp.d.mts +0 -2
  94. package/dist/server/mcp.mjs +7 -8
  95. package/dist/server/me.d.mts +1 -1
  96. package/dist/server/open-page.d.mts +22 -0
  97. package/dist/server/open-page.mjs +20 -2
  98. package/dist/server/outcome.d.mts +22 -0
  99. package/dist/server/outcome.mjs +8 -0
  100. package/dist/server/own-copies.mjs +2 -2
  101. package/dist/server/people.d.mts +1 -1
  102. package/dist/server/port.d.mts +12 -0
  103. package/dist/server/port.mjs +66 -14
  104. package/dist/server/presence.d.mts +4 -1
  105. package/dist/server/presence.mjs +2 -2
  106. package/dist/server/requests.d.mts +5 -1
  107. package/dist/server/requests.mjs +33 -48
  108. package/dist/server/studio-for.d.mts +5 -0
  109. package/dist/server/studio-for.mjs +17 -3
  110. package/dist/server/sync-install.d.mts +8 -12
  111. package/dist/server/sync-install.mjs +12 -30
  112. package/dist/server/thread-source.mjs +2 -2
  113. package/dist/server/tools/describe.d.mts +1 -1
  114. package/dist/server/tools/describe.mjs +1 -1
  115. package/dist/server/tools/feedback.d.mts +1 -1
  116. package/dist/server/tools/reading.mjs +13 -4
  117. package/dist/server/tools/show.d.mts +1 -1
  118. package/dist/server/tools/snapshot.d.mts +1 -1
  119. package/dist/server/tools/thread-list.mjs +1 -1
  120. package/dist/server/tools/watch.mjs +5 -3
  121. package/dist/server/vite.mjs +2 -2
  122. package/dist/server/web-app.mjs +4 -7
  123. package/dist/server/work-groups.mjs +1 -1
  124. package/dist/setup/create.d.mts +4 -2
  125. package/dist/setup/create.mjs +67 -17
  126. package/dist/setup/design-system-checks.mjs +3 -12
  127. package/dist/setup/desktop-app-script.mjs +4 -3
  128. package/dist/setup/desktop-app-start.d.mts +8 -2
  129. package/dist/setup/desktop-app-start.mjs +64 -29
  130. package/dist/setup/desktop-app.d.mts +8 -0
  131. package/dist/setup/desktop-app.mjs +19 -3
  132. package/dist/setup/detect.d.mts +0 -2
  133. package/dist/setup/detect.mjs +1 -3
  134. package/dist/setup/doctor.mjs +1 -1
  135. package/dist/setup/migrate/row-titles.mjs +1 -1
  136. package/dist/setup/project.d.mts +6 -1
  137. package/dist/setup/project.mjs +9 -9
  138. package/dist/setup/starters.d.mts +2 -0
  139. package/dist/setup/starters.mjs +7 -1
  140. package/dist/shared/annotations-core.mjs +1 -1
  141. package/dist/shared/canvas-core.mjs +1 -1
  142. package/dist/shared/canvas-file.d.mts +201 -0
  143. package/dist/shared/canvas-file.mjs +1 -0
  144. package/dist/shared/comments/routes.d.mts +53 -0
  145. package/dist/shared/comments/routes.mjs +37 -0
  146. package/dist/shared/feedback.d.mts +8 -0
  147. package/dist/shared/feedback.mjs +10 -2
  148. package/dist/shared/page-review.d.mts +2 -11
  149. package/dist/shared/page-review.mjs +4 -13
  150. package/dist/shared/presence-core.d.mts +11 -0
  151. package/dist/shared/presence-core.mjs +11 -2
  152. package/dist/shared/review-file.d.mts +5 -0
  153. package/dist/shared/review-file.mjs +23 -13
  154. package/dist/shared/server-page.mjs +1 -1
  155. package/dist/shared/signup.d.mts +2 -5
  156. package/dist/shared/signup.mjs +2 -35
  157. package/dist/shared/studio-events.d.mts +0 -6
  158. package/dist/shared/studio-events.mjs +1 -5
  159. package/dist/shared/studio-files.d.mts +12 -0
  160. package/dist/shared/studio-files.mjs +6 -1
  161. package/dist/shared/studio-routes.d.mts +16 -62
  162. package/dist/shared/studio-routes.mjs +1 -69
  163. package/dist/shared/threads-core.d.mts +2 -2
  164. package/dist/shared/threads-core.mjs +1 -1
  165. package/extension/dist/feedback.js +148 -138
  166. package/extension/dist/manifest.json +1 -1
  167. package/extension/dist/picker.js +146 -136
  168. package/package.json +2 -2
  169. package/src/cli/banner.ts +45 -11
  170. package/src/cli/commands/app.ts +23 -8
  171. package/src/cli/commands/hook.ts +4 -1
  172. package/src/config/project-files.ts +21 -6
  173. package/src/config/renamed.ts +0 -3
  174. package/src/content/capture.ts +6 -12
  175. package/src/content/content.ts +7 -241
  176. package/src/content/flow-specs.ts +2 -1
  177. package/src/content/prototype-summary.ts +4 -44
  178. package/src/content/review-pages.ts +2 -1
  179. package/src/content/text-replace.ts +449 -0
  180. package/src/paths.ts +0 -8
  181. package/src/server/agent-env.ts +12 -2
  182. package/src/server/agent-session.ts +124 -34
  183. package/src/server/channel.ts +94 -52
  184. package/src/server/claimed-presence.ts +26 -10
  185. package/src/server/comments/actions.ts +352 -0
  186. package/src/server/comments/routes.ts +176 -0
  187. package/src/server/comments/tools.ts +317 -0
  188. package/src/server/dev-server.ts +36 -15
  189. package/src/server/file-lock.ts +205 -54
  190. package/src/server/mcp.ts +13 -14
  191. package/src/server/me.ts +2 -5
  192. package/src/server/open-page.ts +54 -4
  193. package/src/server/outcome.ts +26 -0
  194. package/src/server/people.ts +2 -1
  195. package/src/server/port.ts +94 -20
  196. package/src/server/presence.ts +11 -3
  197. package/src/server/requests.ts +60 -70
  198. package/src/server/studio-for.ts +26 -2
  199. package/src/server/sync-install.ts +35 -26
  200. package/src/server/thread-place.ts +2 -4
  201. package/src/server/tools/reading.ts +16 -3
  202. package/src/server/tools/watch.ts +7 -7
  203. package/src/server/web-app.ts +11 -9
  204. package/src/setup/create.ts +91 -17
  205. package/src/setup/design-system-checks.ts +7 -15
  206. package/src/setup/desktop-app-script.ts +4 -3
  207. package/src/setup/desktop-app-start.ts +94 -26
  208. package/src/setup/desktop-app.ts +23 -2
  209. package/src/setup/detect.ts +0 -4
  210. package/src/setup/project.ts +9 -8
  211. package/src/setup/starters.ts +8 -1
  212. package/src/shared/canvas-file.ts +205 -0
  213. package/src/shared/comments/routes.ts +79 -0
  214. package/src/shared/feedback.ts +14 -4
  215. package/src/shared/page-review.ts +11 -16
  216. package/src/shared/presence-core.ts +16 -2
  217. package/src/shared/review-file.ts +28 -12
  218. package/src/shared/server-page.ts +2 -1
  219. package/src/shared/signup.ts +4 -28
  220. package/src/shared/studio-events.ts +0 -13
  221. package/src/shared/studio-files.ts +14 -0
  222. package/src/shared/studio-routes.ts +21 -64
  223. package/src/shared/threads-core.ts +2 -2
  224. package/dist/server/tools/close-reply.d.mts +0 -6
  225. package/dist/server/tools/close-reply.mjs +0 -138
  226. package/dist/server/tools/comment.d.mts +0 -6
  227. package/dist/server/tools/comment.mjs +0 -49
  228. package/src/server/tools/close-reply.ts +0 -271
  229. package/src/server/tools/comment.ts +0 -96
@@ -66,10 +66,12 @@ export declare function movedLines(taken: PortTaken | undefined, port: number, l
66
66
  /**
67
67
  * Why `dex dev` did not start: the port is taken, and by what. With
68
68
  * `live`, this project's own Dex is in the way too: it is not in step
69
- * with the cloud workspace, and this one would be.
69
+ * with the cloud workspace, and this one would be. With `ownUrl`, the app
70
+ * says where this project's Dex runs instead.
70
71
  */
71
- export declare function portTakenLines(taken: PortTaken, look: Look, { because, live }?: {
72
+ export declare function portTakenLines(taken: PortTaken, look: Look, { because, live, ownUrl }?: {
72
73
  because?: KeptBecause;
73
74
  live?: boolean;
75
+ ownUrl?: string;
74
76
  }): string[];
75
77
  //#endregion
@@ -1,4 +1,4 @@
1
- import "../server/port.mjs";
1
+ import { OTHER_DEX } from "../server/port.mjs";
2
2
  import { versionsLine } from "../shared/update-core.mjs";
3
3
  import { SYMBOLS, outputMode, paint } from "./ui.mjs";
4
4
  import { stripVTControlCharacters } from "node:util";
@@ -133,28 +133,47 @@ function machineLines(machine, look) {
133
133
  }
134
134
  /** What the supervisor says as it starts the studio again. */
135
135
  const restartingLine = ({ style, terminal }) => terminal ? `${INDENT}${style("dim", "Restarting Dex…")}` : "Restarting Dex…";
136
- /** Who holds the port, as a phrase: "python3 (PID 4321)". */
137
- const holderPhrase = ({ by, pid }, style) => [by && style("bold", by), pid && style("dim", `(PID ${pid})`)].filter(Boolean).join(" ");
136
+ /**
137
+ * Who holds the port, as a phrase: "python3 (PID 4321)", or "another
138
+ * checkout's Dex (PID 57225)" for a Dex that isn't this project's.
139
+ */
140
+ const holderPhrase = ({ by, pid }, style) => [by && style("bold", by === "Dex" ? "another checkout's Dex" : by), pid && style("dim", `(PID ${pid})`)].filter(Boolean).join(" ");
138
141
  /** Why Dex did not move on to a free port, as the refusal says it. */
139
142
  const KEPT_BECAUSE = {
140
- app: () => "Dex keeps to one port, so an installed Dex app still finds it.",
143
+ app: (port) => `The Dex app opens this project on port ${port} only.`,
141
144
  asked: () => "STUDIO_PORT asks for this port, so Dex keeps to it.",
142
145
  full: (port) => `Dex found no free port from ${port} to ${port + 20 - 1}.`
143
146
  };
144
147
  /**
145
148
  * The refusal for a taken port: this project's own Dex, in the way of a
146
149
  * live one (`running` says it is running), or anything else on the port.
150
+ * `ownUrl` is where this project's Dex runs instead, which the app can't
151
+ * open but can be made again from.
147
152
  */
148
- function refusal(taken, running, style, because) {
153
+ function refusal(taken, running, style, { because, ownUrl }) {
149
154
  if (taken.sameProject) return {
150
155
  headline: `${running}, but not live.`,
151
156
  why: `Stop it, then run ${style("bold", "npx dex dev --live")} again.`,
152
157
  ways: []
153
158
  };
154
159
  const who = holderPhrase(taken, style);
160
+ const headline = `Port ${taken.port} is in use${who ? ` by ${who}` : ""}.`;
161
+ const why = KEPT_BECAUSE[because](taken.port);
162
+ if (because === "app" && ownUrl) return {
163
+ headline,
164
+ why,
165
+ lead: "Stop that process, then try again, or open this project's Dex and install the app again from it:",
166
+ ways: [style("cyan", ownUrl)]
167
+ };
168
+ if (because === "app") return {
169
+ headline,
170
+ why,
171
+ lead: "Stop that process, then try again, or move the app to a free port:",
172
+ ways: [`run ${style("bold", "npx dex dev")} in this project, which moves to one, and install the app again from it`]
173
+ };
155
174
  return {
156
- headline: `Port ${taken.port} is in use${who ? ` by ${who}` : ""}.`,
157
- why: KEPT_BECAUSE[because](taken.port),
175
+ headline,
176
+ why,
158
177
  lead: "Stop that process, or give this project its own port:",
159
178
  ways: [`set ${style("bold", "port")} in dex.config`, `or run ${style("bold", `STUDIO_PORT=${taken.port + 1} npx dex dev`)}`]
160
179
  };
@@ -166,15 +185,16 @@ function refusal(taken, running, style, because) {
166
185
  */
167
186
  function movedLines(taken, port, look) {
168
187
  if (!taken) return [];
169
- const who = taken.by === "Dex" ? "another checkout's Dex" : holderPhrase(taken, (_color, text) => text) || "another process";
188
+ const who = taken.by === "Dex" ? OTHER_DEX : holderPhrase(taken, (_color, text) => text) || "another process";
170
189
  return [noteLine("note", `Port ${taken.port} is in use by ${who}, so this Dex is on ${port}.`, look)];
171
190
  }
172
191
  /**
173
192
  * Why `dex dev` did not start: the port is taken, and by what. With
174
193
  * `live`, this project's own Dex is in the way too: it is not in step
175
- * with the cloud workspace, and this one would be.
194
+ * with the cloud workspace, and this one would be. With `ownUrl`, the app
195
+ * says where this project's Dex runs instead.
176
196
  */
177
- function portTakenLines(taken, look, { because = "app", live = false } = {}) {
197
+ function portTakenLines(taken, look, { because = "app", live = false, ownUrl } = {}) {
178
198
  const { style, terminal } = look;
179
199
  const local = style("cyan", `http://localhost:${taken.port}`);
180
200
  const pid = taken.pid ? ` ${style("dim", `(PID ${taken.pid})`)}` : "";
@@ -185,7 +205,10 @@ function portTakenLines(taken, look, { because = "app", live = false } = {}) {
185
205
  `${INDENT}${style("dim", SYMBOLS.note)} Local: ${local}`,
186
206
  ""
187
207
  ] : [`${running}, at ${local}.`];
188
- const { headline, why, lead, ways } = refusal(taken, running, style, because);
208
+ const { headline, why, lead, ways } = refusal(taken, running, style, {
209
+ because,
210
+ ownUrl
211
+ });
189
212
  if (!terminal) return [
190
213
  `${SYMBOLS.fail} ${headline}`,
191
214
  why,
@@ -2,16 +2,12 @@ import { loadProject, print } from "../command.mjs";
2
2
  import { desktopApp, desktopAppUnavailable, installDesktopApp, removeDesktopApp, revealInFinder } from "../../setup/desktop-app.mjs";
3
3
  import { defineCommand } from "citty";
4
4
  //#region src/cli/commands/app.ts
5
- /** The project's app, on a Mac that can make it. */
6
- async function projectApp() {
5
+ /** The project, on a Mac that can make its app. */
6
+ async function macProject() {
7
7
  const unavailable = desktopAppUnavailable();
8
8
  if (unavailable === "platform") throw new Error("Installing outside the browser is macOS-only for now. Install Dex from your browser instead.");
9
9
  if (unavailable === "hosted") throw new Error("A hosted studio can't install an app.");
10
- const { root, port } = await loadProject();
11
- return desktopApp({
12
- root,
13
- port
14
- });
10
+ return await loadProject();
15
11
  }
16
12
  const install = defineCommand({
17
13
  meta: {
@@ -19,9 +15,17 @@ const install = defineCommand({
19
15
  description: "Make ~/Applications/Dex.app: it starts dex dev when it isn't running, and opens the studio in its own window"
20
16
  },
21
17
  async run() {
22
- const path = await installDesktopApp(await projectApp());
18
+ const project = await macProject();
19
+ const { ownPort, studioFor } = await import("../../server/studio-for.mjs");
20
+ const found = await studioFor(project);
21
+ const app = desktopApp({
22
+ root: project.root,
23
+ port: ownPort(found) ?? project.port
24
+ });
25
+ const path = await installDesktopApp(app);
23
26
  await revealInFinder(path).catch(() => void 0);
24
- print(`Installed ${path}.`);
27
+ print(`Installed ${path}, which opens ${app.url}.`);
28
+ if (found.kind === "elsewhere") print(`Port ${found.port} is in use by ${found.holder}, so the app can start this project only once that stops.`);
25
29
  print("Find it in Launchpad, or drag it to your Dock.");
26
30
  }
27
31
  });
@@ -31,7 +35,11 @@ const remove = defineCommand({
31
35
  description: "Remove the app `dex app install` made for this project"
32
36
  },
33
37
  async run() {
34
- const app = await projectApp();
38
+ const { root, port } = await macProject();
39
+ const app = desktopApp({
40
+ root,
41
+ port
42
+ });
35
43
  await removeDesktopApp(app);
36
44
  print(`Removed ${app.name}.`);
37
45
  }
@@ -83,7 +91,7 @@ const start = defineCommand({
83
91
  process.exitCode = STARTED_EXIT;
84
92
  return;
85
93
  }
86
- const lines = started.state === "gone" ? [started.message] : banner.portTakenLines(started.taken, banner.lookOf());
94
+ const lines = started.state === "gone" ? [started.message] : banner.portTakenLines(started.taken, banner.lookOf(), { ownUrl: started.ownUrl });
87
95
  for (const line of lines) print(line);
88
96
  process.exitCode = 1;
89
97
  }
@@ -1,4 +1,5 @@
1
1
  import { contentRoot, print } from "../command.mjs";
2
+ import { workerSession } from "../../shared/presence-core.mjs";
2
3
  import { defineCommand } from "citty";
3
4
  //#region src/cli/commands/hook.ts
4
5
  const STOPPED = /* @__PURE__ */ new Set([
@@ -39,7 +40,7 @@ var hook_default = defineCommand({
39
40
  const [root, { openPresence }] = await Promise.all([contentRoot(args.root), import("../../server/presence.mjs")]);
40
41
  const presence = openPresence(root);
41
42
  const session = event.session_id ?? "claude";
42
- const worker = event.agent_id ? `${session}/${event.agent_id}` : session;
43
+ const worker = event.agent_id ? workerSession(session, event.agent_id) : session;
43
44
  if (event.hook_event_name === "UserPromptSubmit") {
44
45
  const { promptNotices } = await import("../../server/notices.mjs");
45
46
  const context = await promptNotices(root, session, event.cwd);
@@ -32,6 +32,12 @@ export declare const stylingIn: (all: Record<string, string>) => StylingApproach
32
32
  /** The folder the app's framework serves at "/": what root-relative URLs name. */
33
33
  export declare function publicFolder(root: string): string | undefined;
34
34
  export declare function packageFolder(dir: string): string | undefined;
35
+ /**
36
+ * Where package `name` is installed: the first node_modules folder that holds
37
+ * it, looking up from `from` as Node does. Not `require.resolve`, which under
38
+ * Bun, with no node_modules above, finds Bun's global cache instead.
39
+ */
40
+ export declare function installedPackageDir(from: string, name: string): string | undefined;
35
41
  export declare function workspaceDirs(root: string): string[];
36
42
  export interface Manifest extends Json {
37
43
  exports?: unknown;
@@ -198,6 +198,18 @@ function packageFolder(dir) {
198
198
  if (dirname(at) === at) return;
199
199
  }
200
200
  }
201
+ /**
202
+ * Where package `name` is installed: the first node_modules folder that holds
203
+ * it, looking up from `from` as Node does. Not `require.resolve`, which under
204
+ * Bun, with no node_modules above, finds Bun's global cache instead.
205
+ */
206
+ function installedPackageDir(from, name) {
207
+ for (let at = resolve(from);; at = dirname(at)) {
208
+ const dir = join(at, "node_modules", name);
209
+ if (isFile(join(dir, "package.json"))) return dir;
210
+ if (dirname(at) === at) return;
211
+ }
212
+ }
201
213
  const GLOB_STAR_RE = /\/\*$/;
202
214
  const QUOTES_RE = /["']/g;
203
215
  function workspaceDirs(root) {
@@ -408,7 +420,7 @@ function packageDir(name, from) {
408
420
  folders.push(at);
409
421
  if (dirname(at) === at) break;
410
422
  }
411
- return folders.flatMap(workspaceDirs).find((dir) => readJson(join(dir, "package.json"))?.name === name) ?? folders.map((at) => join(at, "node_modules", name)).find((dir) => isFile(join(dir, "package.json")));
423
+ return folders.flatMap(workspaceDirs).find((dir) => readJson(join(dir, "package.json"))?.name === name) ?? installedPackageDir(from, name);
412
424
  }
413
425
  function packageEntry(name, from) {
414
426
  const dir = packageDir(name, from);
@@ -501,4 +513,4 @@ function exportedNames(file) {
501
513
  const COMPONENT_EXPORT_RE = /^[A-Z](?=[\dA-Za-z]*[a-z])[\dA-Za-z]*$/;
502
514
  const exportedComponents = (file) => exportedNames(file).filter((name) => COMPONENT_EXPORT_RE.test(name));
503
515
  //#endregion
504
- export { canImport, compilerOption, componentsJsonError, dependenciesOf, exportedComponents, exportedFolder, exportedNames, filesImport, importBaseFor, packageAt, packageEntry, packageFolder, parseJsonc, projectAliases, projectBaseUrl, projectPaths, publicFolder, readComponentsJson, readJson, resolveAlias, runtimeDependencies, stringRecord, stylingIn, tailwind3Config, tailwindSetup, tsconfigFile, workspaceDirs };
516
+ export { canImport, compilerOption, componentsJsonError, dependenciesOf, exportedComponents, exportedFolder, exportedNames, filesImport, importBaseFor, installedPackageDir, packageAt, packageEntry, packageFolder, parseJsonc, projectAliases, projectBaseUrl, projectPaths, publicFolder, readComponentsJson, readJson, resolveAlias, runtimeDependencies, stringRecord, stylingIn, tailwind3Config, tailwindSetup, tsconfigFile, workspaceDirs };
@@ -1,6 +1,4 @@
1
1
  //#region src/config/renamed.d.ts
2
- /** The product's name before Dex, as old names start with it. */
3
- export declare const OLD_PRODUCT = "sudio";
4
2
  /** Notices said so far, for tests. */
5
3
  export declare const resetRenamedNotices: () => void;
6
4
  /**
@@ -1,6 +1,4 @@
1
1
  //#region src/config/renamed.ts
2
- /** The product's name before Dex, as old names start with it. */
3
- const OLD_PRODUCT = "sudio";
4
2
  const said = /* @__PURE__ */ new Set();
5
3
  /** Notices said so far, for tests. */
6
4
  const resetRenamedNotices = () => said.clear();
@@ -31,4 +29,4 @@ const importsOldPackage = (source) => source.match(OLD_PACKAGE_RE) !== null;
31
29
  /** `source` with its imports of @sudio/core pointed at @dexhq/canvas. */
32
30
  const withNewPackage = (source) => source.replace(OLD_PACKAGE_RE, (_match, quote, path = "") => `${quote}@dexhq/canvas${path}${quote}`);
33
31
  //#endregion
34
- export { OLD_PRODUCT, dexEnv, importsOldPackage, renamedNotice, resetRenamedNotices, withNewPackage };
32
+ export { dexEnv, importsOldPackage, renamedNotice, resetRenamedNotices, withNewPackage };
@@ -1,5 +1,5 @@
1
1
  import { Cell } from "../shared/canvas-core.mjs";
2
- import { Canvas, CanvasFrame } from "./content.mjs";
2
+ import { Canvas, Frame } from "../shared/canvas-file.mjs";
3
3
  import { Capture } from "../shared/snapshot-clipboard.mjs";
4
4
  //#region src/content/capture.d.ts
5
5
  /** The longest side a snapshot's frame may have, in pixels. */
@@ -26,7 +26,7 @@ export interface Placed {
26
26
  /** A snapshot about to be saved, as placing its frame sees it. */
27
27
  export interface Snapshot {
28
28
  capture: Capture;
29
- frame: CanvasFrame;
29
+ frame: Frame;
30
30
  name: string;
31
31
  }
32
32
  /** Where a saved snapshot went: its view, its frame's key. */
@@ -1,7 +1,7 @@
1
- import { isSlug, prototypeFiles, prototypePage, slugify } from "../shared/prototypes-core.mjs";
2
- import { prototypeExists, prototypePaths } from "./prototypes.mjs";
3
1
  import { gridProblems } from "../shared/frame-grids.mjs";
2
+ import { isSlug, prototypeFiles, prototypePage, slugify } from "../shared/prototypes-core.mjs";
4
3
  import { appendRow, insertRowBelow, parseFrameKey, placeFrameInCell, uniqueId } from "../shared/canvas-core.mjs";
4
+ import { prototypeExists, prototypePaths } from "./prototypes.mjs";
5
5
  import { knownFor, ownCell, readCanvas, writeCanvas } from "./content.mjs";
6
6
  import { arrangeRows } from "../shared/paste-arrangement.mjs";
7
7
  import { posix } from "node:path";
@@ -1,145 +1,10 @@
1
- import { CanvasPoint, Cell, Viewport } from "../shared/canvas-core.mjs";
2
- import { Sketch } from "../shared/sketch-core.mjs";
1
+ import { Cell, Viewport } from "../shared/canvas-core.mjs";
3
2
  import { ResolvedDesignSystem } from "../config/design-system.mjs";
4
3
  import { Authored } from "../shared/annotations-core.mjs";
5
- import { FrameGrid, FrameGuide } from "../shared/frame-grids.mjs";
4
+ import { Canvas, ViewFrame } from "../shared/canvas-file.mjs";
6
5
  import { PresenceTarget } from "../shared/presence-core.mjs";
6
+ import { Contributor } from "../shared/studio-files.mjs";
7
7
  //#region src/content/content.d.ts
8
- /** A person who makes prototypes, from contributors.json. */
9
- export interface Contributor {
10
- discipline: string;
11
- /** Git user names that identify this person. */
12
- git: string[];
13
- /** Their GitHub username, for their avatar. */
14
- github?: string;
15
- name: string;
16
- slug: string;
17
- }
18
- interface FrameBase {
19
- /** On a column's first frame: the stacked frame its column starts level with. */
20
- beside?: string;
21
- id: string;
22
- step?: number;
23
- title?: string;
24
- /**
25
- * Which frame this is, for good: kept when it moves or is renamed, new on
26
- * a copy. Picks follow it. Given to the saver's frames that have none when
27
- * they save.
28
- */
29
- uid?: string;
30
- /** Stacked below the frame before it, in its column. */
31
- under?: true;
32
- }
33
- /** A frame that shows one of the prototype's views. */
34
- export interface ViewFrame extends FrameBase {
35
- doc?: undefined;
36
- /** The frame's own grids and guides, shown in place of the canvas's grid. */
37
- grids?: FrameGrid[];
38
- guides?: FrameGuide[];
39
- params?: Record<string, string>;
40
- /** A fixed size in pixels, for a snapshot of one element. */
41
- size?: {
42
- height: number;
43
- width: number;
44
- };
45
- sketch?: undefined;
46
- /**
47
- * Where a snapshot was captured from, and when; and the image it is, when
48
- * it is one, in the prototype's folder: "images/….png".
49
- */
50
- snapshot?: {
51
- captured: string;
52
- image?: string;
53
- url: string;
54
- };
55
- spec?: undefined;
56
- view: string;
57
- viewport?: Viewport;
58
- }
59
- /** A frame that shows one of the prototype's docs. */
60
- export interface DocFrame extends FrameBase {
61
- doc: string;
62
- sketch?: undefined;
63
- spec?: undefined;
64
- view?: undefined;
65
- }
66
- /** A spec, edited in place: its markdown file, from the file's folder. */
67
- export interface SpecFrame extends FrameBase {
68
- doc?: undefined;
69
- size?: {
70
- height: number;
71
- width: number;
72
- };
73
- sketch?: undefined;
74
- spec: string;
75
- view?: undefined;
76
- }
77
- export interface SketchFrame extends FrameBase {
78
- doc?: undefined;
79
- sketch: Sketch;
80
- spec?: undefined;
81
- /** Required, as an older Dex names a frame by its title or view. */
82
- title: string;
83
- view?: undefined;
84
- }
85
- declare const readFromDisk: unique symbol;
86
- /**
87
- * A frame this Dex cannot show: a kind from a newer Dex, or a mistake.
88
- * Only reading a canvas makes one, so Dex never writes a frame that shows
89
- * nothing.
90
- */
91
- export interface UnknownFrame extends FrameBase {
92
- doc?: undefined;
93
- sketch?: undefined;
94
- spec?: undefined;
95
- view?: undefined;
96
- readonly [readFromDisk]: true;
97
- }
98
- export type CanvasFrame = ViewFrame | DocFrame | SpecFrame | SketchFrame | UnknownFrame;
99
- /** A pass through a section; its frames are the steps, left to right. */
100
- export interface CanvasRow {
101
- /**
102
- * In a person's copy of someone else's section: the id of their row this one
103
- * is shown under (people-core.ts).
104
- */
105
- after?: string;
106
- /** Whose it is, when not its section's: set when read, never written. */
107
- author?: string;
108
- /** The id of the section in its author's file that keeps it. */
109
- copy?: string;
110
- frames: CanvasFrame[];
111
- id: string;
112
- title?: string;
113
- }
114
- /** A section on the canvas; with `at`, a frame of its own drawn at that point. */
115
- export interface CanvasSection {
116
- at?: CanvasPoint;
117
- /** Whose it is, from the folder it was read from; never written to a file. */
118
- author?: string;
119
- /** The id of the section it is a copy of, shown right below it. */
120
- copyOf?: string;
121
- /** When it was added, as an ISO date. */
122
- created?: string;
123
- description?: string;
124
- /** Whose section it was copied from, when it is a copy. */
125
- from?: string;
126
- id: string;
127
- /** Where a placed section's area starts; none stacks it with the others. */
128
- position?: CanvasPoint;
129
- rows: CanvasRow[];
130
- title: string;
131
- }
132
- /** canvas.json: sections stacked top to bottom. */
133
- export interface Canvas {
134
- /**
135
- * Set once the person's frames have uids (with uids on): from then on, a
136
- * frame of theirs with none is new. Read, a canvas lists whose files have
137
- * it in `uidsGiven`.
138
- */
139
- frameUids?: true;
140
- sections: CanvasSection[];
141
- uidsGiven?: string[];
142
- }
143
8
  /** The views and docs that exist in a prototype, which frames may show. */
144
9
  export interface Known {
145
10
  docs: string[];
@@ -206,7 +71,6 @@ export interface CommandValues {
206
71
  wait?: string;
207
72
  }
208
73
  export declare const STATUSES: string[];
209
- export declare const DISCIPLINES: string[];
210
74
  export declare function contributorProblems(contributors: unknown): string[];
211
75
  export declare function manifestProblems(manifest: unknown): string[];
212
76
  export declare function loadStudio(root: string): Promise<{
@@ -220,8 +84,6 @@ export interface CheckReport {
220
84
  problems: string[];
221
85
  warnings: string[];
222
86
  }
223
- /** The studio's own interface must not import a design system. */
224
- export declare function chromeIssues(appDir: string): Promise<string[]>;
225
87
  /**
226
88
  * Every problem in the studio, as readable lines, and the warnings the
227
89
  * prototype checks found (prototype-checks.ts). No problems when all is
@@ -1,15 +1,17 @@
1
1
  import { NOT_RECOGNISED, youOf } from "../shared/studio-routes.mjs";
2
+ import { isOneOf, isRecord, isText } from "../shared/checks.mjs";
2
3
  import { PROTOTYPES_FOLDER, framePage, isSlug, newFileId, prototypeFiles, prototypePage, slugify } from "../shared/prototypes-core.mjs";
4
+ import { appendOwnFrame, canvasFrames, canvasProblems, placeViewInCell, rowTitleProblems, shapeProblems, uniqueId, viewOf } from "../shared/canvas-core.mjs";
5
+ import { agentChange } from "../shared/threads-core.mjs";
3
6
  import { targetForPath } from "../shared/live-presence.mjs";
4
7
  import { prepareState, studioState } from "../server/state.mjs";
5
8
  import { openPresence } from "../server/presence.mjs";
6
- import { isOneOf, isRecord, isText } from "../shared/checks.mjs";
7
9
  import { clashingViews, peopleOf, prototypeExists, prototypePaths, prototypeTitles, splitPrototypeFile, viewFiles, walkPrototypes } from "./prototypes.mjs";
8
- import { STUDIO_FILES } from "../shared/studio-files.mjs";
10
+ import { DISCIPLINES, STUDIO_FILES } from "../shared/studio-files.mjs";
9
11
  import { dexRunner, packageManager } from "../config/package-manager.mjs";
10
12
  import { formattedJson } from "../shared/json-style.mjs";
11
- import { appendOwnFrame, canvasFrames, canvasProblems, placeViewInCell, rowTitleProblems, shapeProblems, uniqueId, viewOf } from "../shared/canvas-core.mjs";
12
- import { agentChange } from "../shared/threads-core.mjs";
13
+ import { checkPrototype, errorLines, findingLine } from "./prototype-checks.mjs";
14
+ import { nextRemovals, removalsOf } from "../shared/removed-views-core.mjs";
13
15
  import { features } from "../server/features.mjs";
14
16
  import { notRunning, studioFor } from "../server/studio-for.mjs";
15
17
  import { combineCanvases, copyOnEdit, isOthers, isOthersRow, labelAuthors, liftRows, ownRow, ownSections, withFrameUids, withoutOthersRows } from "../shared/people-core.mjs";
@@ -17,11 +19,9 @@ import { checkFrameAnchor, readAnnotations, withAnnotation, withoutAnnotation }
17
19
  import { TWO_VERSIONS_LEAD } from "../shared/block-merge.mjs";
18
20
  import { defaultDevice } from "../shared/devices.mjs";
19
21
  import { LARGE_CANVAS_BYTES } from "../shared/live-core.mjs";
20
- import { nextRemovals, removalsOf } from "../shared/removed-views-core.mjs";
21
22
  import { findBiome, formatText } from "./biome.mjs";
22
23
  import { inTurn, replaceFile } from "./file-turns.mjs";
23
24
  import { loadDevices } from "./devices.mjs";
24
- import { checkPrototype, errorLines, findingLine } from "./prototype-checks.mjs";
25
25
  import { SnapshotError, snapshotView } from "./snapshot-client.mjs";
26
26
  import { openThreads } from "./thread-module.mjs";
27
27
  import { existsSync } from "node:fs";
@@ -40,19 +40,11 @@ const STATUSES = [
40
40
  "handed-off",
41
41
  "archived"
42
42
  ];
43
- const DISCIPLINES = [
44
- "product",
45
- "brand",
46
- "engineering"
47
- ];
48
43
  const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
49
44
  const GITHUB_LOGIN_RE = /^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}(?:_[a-z\d]+)?$/i;
50
45
  const GITHUB_NOREPLY_RE = /^(?:\d+\+)?([^@]+)@users\.noreply\.github\.com$/i;
51
46
  const LEADING_AT_RE = /^@/;
52
47
  const GH_TIMEOUT_MS = 5e3;
53
- const SOURCE_FILE_RE = /\.(?:tsx?|css)$/;
54
- const TEST_FILE_RE = /\.(?:test|bench)\.[cm]?[jt]sx?$/;
55
- const TEST_SUPPORT_DIR = "testing";
56
48
  const DOC_FILE_RE = /\.md$/;
57
49
  /** A JSON file, as the shape the caller reads it into. */
58
50
  const readJson = async (path) => {
@@ -151,53 +143,6 @@ async function prototypeIssues(root, { slug, path, manifest, problem }, designSy
151
143
  warnings: [...annotations, ...findings.filter((finding) => finding.level === "warning").map(findingLine)]
152
144
  };
153
145
  }
154
- const CHROME_IMPORTS = [
155
- "react",
156
- "virtual:studio-ui",
157
- "react-dom",
158
- "wouter",
159
- "next-themes",
160
- "react-markdown",
161
- "remark-gfm",
162
- "@base-ui/react",
163
- "class-variance-authority",
164
- "cn",
165
- "lucide-react",
166
- "@tiptap/",
167
- "yaml",
168
- "canvas-confetti",
169
- "motion/react",
170
- "tw-animate-css",
171
- "@lingui/",
172
- "@fontsource-variable/inter",
173
- "@studio/",
174
- "@dexhq/canvas/kit/",
175
- "@studio-content/",
176
- "@studio-entry.css",
177
- "@studio-frame.css",
178
- "virtual:studio-design-system",
179
- "virtual:studio-components",
180
- "virtual:studio-provider",
181
- "virtual:studio-threads",
182
- "node:",
183
- "../types"
184
- ];
185
- const IMPORT_RE = /(?:from|import)\s+["']([^"']+)["']/g;
186
- /** The studio's own interface must not import a design system. */
187
- async function chromeIssues(appDir) {
188
- const entries = await readdir(appDir, {
189
- recursive: true,
190
- withFileTypes: true
191
- });
192
- const problems = [];
193
- for (const entry of entries) {
194
- if (!(entry.isFile() && SOURCE_FILE_RE.test(entry.name)) || TEST_FILE_RE.test(entry.name) || relative(appDir, entry.parentPath).split(sep).includes(TEST_SUPPORT_DIR)) continue;
195
- const file = join(entry.parentPath, entry.name);
196
- const source = await readFile(file, "utf8");
197
- for (const [, specifier] of source.matchAll(IMPORT_RE)) if (!(specifier.startsWith(".") || specifier.startsWith("/") || specifier.startsWith("../../") || CHROME_IMPORTS.some((name) => specifier === name || specifier.startsWith(name)))) problems.push(`${relative(appDir, file)}: imports "${specifier}". The studio's interface must not depend on a design system; go through virtual:studio-design-system.`);
198
- }
199
- return problems;
200
- }
201
146
  /**
202
147
  * Every problem in the studio, as readable lines, and the warnings the
203
148
  * prototype checks found (prototype-checks.ts). No problems when all is
@@ -1363,4 +1308,4 @@ function createContentCommands({ content, port, designSystem, root: projectRoot
1363
1308
  };
1364
1309
  }
1365
1310
  //#endregion
1366
- export { DISCIPLINES, STATUSES, addContributor, allowedPrefixes, canvasParts, changedFiles, check, checkStudio, chromeIssues, contributorProblems, createContentCommands, createPrototype, createUntitledPrototype, currentPerson, deletePrototype, duplicatePrototype, framePageOf, git, githubAccountLogin, githubLogin, identify, identityFrom, joinCurrentPerson, knownFor, linkGithub, loadStudio, manifestProblems, outOfScope, ownCell, placeViewFrame, queued, readCanvas, readCanvasRevision, readPrototypeAnnotations, removeAnnotation, saveAnnotation, scratchView, setPrototypeCover, setPrototypeStatus, setPrototypeTitle, snapshot, targetForFile, whoami, writeCanvas };
1311
+ export { STATUSES, addContributor, allowedPrefixes, canvasParts, changedFiles, check, checkStudio, contributorProblems, createContentCommands, createPrototype, createUntitledPrototype, currentPerson, deletePrototype, duplicatePrototype, framePageOf, git, githubAccountLogin, githubLogin, identify, identityFrom, joinCurrentPerson, knownFor, linkGithub, loadStudio, manifestProblems, outOfScope, ownCell, placeViewFrame, queued, readCanvas, readCanvasRevision, readPrototypeAnnotations, removeAnnotation, saveAnnotation, scratchView, setPrototypeCover, setPrototypeStatus, setPrototypeTitle, snapshot, targetForFile, whoami, writeCanvas };
@@ -1,7 +1,7 @@
1
1
  import { personSpecPath, prototypeFiles } from "../shared/prototypes-core.mjs";
2
+ import { SPEC_SIZE, canvasFrames, isNoteFrame, isSlideFrame, kinded, placedAt, specName } from "../shared/canvas-core.mjs";
2
3
  import { peopleOf } from "./prototypes.mjs";
3
4
  import { frontMatterTitle, splitFrontMatter } from "../shared/front-matter.mjs";
4
- import { SPEC_SIZE, canvasFrames, isNoteFrame, isSlideFrame, kinded, placedAt, specName } from "../shared/canvas-core.mjs";
5
5
  import { readCanvas } from "./content.mjs";
6
6
  import { readText } from "./read-text.mjs";
7
7
  import { join } from "node:path";
@@ -1,44 +1,8 @@
1
- import { FrameKind, KeyedFrame, Viewport } from "../shared/canvas-core.mjs";
2
- import { Sketch } from "../shared/sketch-core.mjs";
1
+ import { FrameKind, KeyedFrame } from "../shared/canvas-core.mjs";
2
+ import { Frame } from "../shared/canvas-file.mjs";
3
3
  //#region src/content/prototype-summary.d.ts
4
- export type CanvasFrame = (ViewFrame | {
5
- doc: string;
6
- id: string;
7
- sketch?: undefined;
8
- view?: undefined;
9
- } | {
10
- doc?: undefined;
11
- id: string;
12
- sketch?: undefined;
13
- spec: string;
14
- view?: undefined;
15
- } | {
16
- doc?: undefined;
17
- id: string;
18
- sketch: Sketch;
19
- title: string;
20
- view?: undefined;
21
- } | UnknownFrame) & {
22
- uid?: string;
23
- };
24
- interface UnknownFrame {
25
- doc?: undefined;
26
- id: string;
27
- sketch?: undefined;
28
- spec?: undefined;
29
- view?: undefined;
30
- }
31
- /** A frame showing a view, in its viewport and state. */
32
- export interface ViewFrame {
33
- doc?: undefined;
34
- id: string;
35
- params?: Record<string, string>;
36
- sketch?: undefined;
37
- view: string;
38
- viewport?: Viewport;
39
- }
40
4
  /** Every frame on a prototype's canvas, with its key, as the studio shows it. */
41
- export declare function prototypeFrames(root: string, slug: string): Promise<KeyedFrame<CanvasFrame>[]>;
5
+ export declare function prototypeFrames(root: string, slug: string): Promise<KeyedFrame<Frame>[]>;
42
6
  interface SummaryFrame {
43
7
  author?: string;
44
8
  doc?: string;
@@ -1,7 +1,7 @@
1
1
  import { shownFrom } from "../paths.mjs";
2
- import { prototypePaths, prototypeTitle, viewFiles } from "./prototypes.mjs";
3
2
  import { outlineSketch } from "../shared/sketch-core.mjs";
4
3
  import { canvasFrames, frameTitle, kinded } from "../shared/canvas-core.mjs";
4
+ import { prototypePaths, prototypeTitle, viewFiles } from "./prototypes.mjs";
5
5
  import { rowOwner } from "../shared/people-core.mjs";
6
6
  import { placePicks } from "../shared/annotations-core.mjs";
7
7
  import { knownFor, readCanvas, readPrototypeAnnotations } from "./content.mjs";
@@ -13,8 +13,7 @@ const HEADING_RE = /^#\s+(.+)$/m;
13
13
  /** Every frame on a prototype's canvas, with its key, as the studio shows it. */
14
14
  async function prototypeFrames(root, slug) {
15
15
  try {
16
- const canvas = await readCanvas(slug, root);
17
- return canvasFrames(canvas);
16
+ return canvasFrames(await readCanvas(slug, root));
18
17
  } catch {
19
18
  return [];
20
19
  }
@@ -1,5 +1,5 @@
1
- import { PROTOTYPES_FOLDER, isSlug, prototypeFiles, splitPrototypePath, viewInFrame } from "../shared/prototypes-core.mjs";
2
1
  import { isText } from "../shared/checks.mjs";
2
+ import { PROTOTYPES_FOLDER, isSlug, prototypeFiles, splitPrototypePath, viewInFrame } from "../shared/prototypes-core.mjs";
3
3
  import { existsSync, readFileSync, readdirSync } from "node:fs";
4
4
  import { join, relative, sep } from "node:path";
5
5
  import { readFile, readdir } from "node:fs/promises";