@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.
- package/CHANGELOG.md +17 -0
- package/README.md +16 -15
- package/app/canvas/frame-node.tsx +34 -17
- package/app/canvas/tool-cursors.ts +16 -16
- package/app/i18n/locales/en/messages.po +26 -4
- package/app/i18n/locales/en/messages.ts +1 -1
- package/app/i18n/locales/pseudo/messages.po +26 -4
- package/app/i18n/locales/pseudo/messages.ts +1 -1
- package/app/icons/{sets/lucide.tsx → glyphs.tsx} +3 -5
- package/app/icons/index.tsx +3 -3
- package/app/icons/types.ts +3 -10
- package/app/index.html +3 -3
- package/app/pages/canvas-settings.tsx +35 -0
- package/app/shell/about.tsx +5 -4
- package/app/shell/feedback-details.ts +0 -3
- package/app/shell/instructions-editor.tsx +1 -1
- package/app/shell/presence-style.ts +59 -0
- package/app/shell/presence.tsx +6 -3
- package/app/shell/settings-sections.ts +12 -0
- package/app/shell/sidebar.tsx +1 -1
- package/app/studio-ui.d.ts +0 -9
- package/app/ui/prompt-editor.tsx +1 -1
- package/dist/cli/commands/create.d.mts +26 -14
- package/dist/cli/commands/create.mjs +13 -7
- package/dist/cli/commands/dev.mjs +2 -3
- package/dist/cli/commands/init.d.mts +11 -6
- package/dist/cli/help.d.mts +1 -1
- package/dist/cli/help.mjs +3 -3
- package/dist/cli/main.d.mts +22 -12
- package/dist/config/index.d.mts +6 -5
- package/dist/config/project-files.d.mts +0 -3
- package/dist/config/project-files.mjs +0 -3
- package/dist/config/schema.d.mts +0 -5
- package/dist/config/schema.mjs +0 -5
- package/dist/content/content.mjs +0 -3
- package/dist/content/snapshot-client.mjs +1 -1
- package/dist/paste/paste.mjs +1 -1
- package/dist/server/brief.mjs +3 -3
- package/dist/server/channel.d.mts +6 -0
- package/dist/server/channel.mjs +16 -1
- package/dist/server/claimed-presence.d.mts +17 -0
- package/dist/server/claimed-presence.mjs +50 -0
- package/dist/server/dev-server.mjs +9 -0
- package/dist/server/file-errors.d.mts +7 -2
- package/dist/server/file-errors.mjs +31 -8
- package/dist/server/requests.mjs +1 -1
- package/dist/server/studio-for.mjs +1 -1
- package/dist/server/vite.mjs +26 -29
- package/dist/server/web-app.mjs +3 -3
- package/dist/setup/apply.mjs +8 -14
- package/dist/setup/create.mjs +51 -19
- package/dist/setup/desktop-app.mjs +1 -1
- package/dist/setup/detect.d.mts +14 -5
- package/dist/setup/detect.mjs +56 -8
- package/dist/setup/doctor.mjs +1 -3
- package/dist/setup/existing-setup.d.mts +1 -3
- package/dist/setup/existing-setup.mjs +10 -11
- package/dist/setup/own-app.d.mts +1 -2
- package/dist/setup/own-app.mjs +4 -5
- package/dist/setup/plan.d.mts +8 -6
- package/dist/setup/plan.mjs +64 -48
- package/dist/setup/project.d.mts +0 -16
- package/dist/setup/project.mjs +8 -52
- package/dist/setup/prompts.d.mts +5 -5
- package/dist/setup/prompts.mjs +28 -61
- package/dist/setup/questions.d.mts +12 -4
- package/dist/setup/questions.mjs +10 -25
- package/dist/setup/starters.mjs +19 -8
- package/dist/setup/workspace-setup.d.mts +1 -2
- package/dist/setup/workspace-setup.mjs +4 -6
- package/dist/setup/write.d.mts +15 -5
- package/dist/setup/write.mjs +35 -9
- package/dist/shared/server-page.mjs +6 -0
- package/extension/dist/feedback.js +1 -1
- package/extension/dist/manifest.json +1 -1
- package/package.json +2 -19
- package/src/cli/commands/create.ts +17 -9
- package/src/cli/commands/dev.ts +0 -3
- package/src/cli/help.ts +3 -3
- package/src/config/index.ts +6 -5
- package/src/config/project-files.ts +0 -5
- package/src/config/schema.ts +0 -1
- package/src/content/content.ts +0 -3
- package/src/content/snapshot-client.ts +1 -1
- package/src/server/brief.ts +8 -3
- package/src/server/channel.ts +27 -0
- package/src/server/claimed-presence.ts +77 -0
- package/src/server/dev-server.ts +13 -0
- package/src/server/file-errors.ts +47 -13
- package/src/server/studio-for.ts +1 -1
- package/src/server/vite.ts +37 -40
- package/src/server/web-app.ts +3 -3
- package/src/setup/apply.ts +10 -16
- package/src/setup/create.ts +52 -20
- package/src/setup/desktop-app.ts +1 -1
- package/src/setup/detect.ts +56 -10
- package/src/setup/doctor.ts +4 -4
- package/src/setup/existing-setup.ts +10 -12
- package/src/setup/own-app.ts +2 -5
- package/src/setup/plan.ts +93 -84
- package/src/setup/project.ts +16 -110
- package/src/setup/prompts.ts +44 -127
- package/src/setup/questions.ts +27 -29
- package/src/setup/starters.ts +27 -9
- package/src/setup/workspace-setup.ts +8 -18
- package/src/setup/write.ts +52 -9
- package/src/shared/server-page.ts +9 -0
- package/templates/methods/review.md +2 -2
- package/templates/rules/canvas-frames.md +104 -0
- package/templates/rules/canvas.md +8 -142
- package/templates/rules/prototypes.md +1 -1
- package/templates/rules/snapshots.md +52 -0
- package/templates/starters/standalone/README.md +7 -7
- package/templates/starters/standalone/components.json +1 -1
- package/templates/starters/standalone/package.json +1 -2
- package/templates/starters/turborepo/README.md +6 -6
- package/templates/starters/turborepo/apps/web/components.json +1 -1
- package/templates/starters/turborepo/apps/web/package.json +1 -2
- package/templates/starters/turborepo/apps/web/src/app.tsx +4 -5
- package/templates/starters/turborepo/packages/ui/components.json +1 -1
- package/templates/starters/turborepo/packages/ui/package.json +1 -2
- package/templates/starters/vite/README.md +7 -6
- package/templates/starters/vite/components.json +1 -1
- package/templates/starters/vite/package.json +1 -2
- package/templates/starters/vite/src/app.tsx +3 -4
- package/templates/starters/vite/src/components/ui/accordion.tsx +71 -0
- package/templates/starters/vite/src/components/ui/attachment.tsx +1 -1
- package/templates/starters/vite/src/components/ui/badge.tsx +2 -2
- package/templates/starters/vite/src/components/ui/button.tsx +17 -12
- package/templates/starters/vite/src/components/ui/card.tsx +1 -1
- package/templates/starters/vite/src/components/ui/checkbox.tsx +28 -0
- package/templates/starters/vite/src/components/ui/dialog.tsx +5 -5
- package/templates/starters/vite/src/components/ui/dropdown-menu.tsx +17 -14
- package/templates/starters/vite/src/components/ui/field.tsx +3 -1
- package/templates/starters/vite/src/components/ui/input-group.tsx +5 -3
- package/templates/starters/vite/src/components/ui/input.tsx +1 -1
- package/templates/starters/vite/src/components/ui/label.tsx +2 -0
- package/templates/starters/vite/src/components/ui/native-select.tsx +3 -4
- package/templates/starters/vite/src/components/ui/popover.tsx +1 -1
- package/templates/starters/vite/src/components/ui/separator.tsx +2 -0
- package/templates/starters/vite/src/components/ui/spinner.tsx +3 -7
- package/templates/starters/vite/src/components/ui/switch.tsx +1 -1
- package/templates/starters/vite/src/components/ui/textarea.tsx +1 -1
- package/templates/starters/vite/src/components/ui/toggle.tsx +4 -2
- package/templates/starters/vite/src/index.css +533 -111
- package/app/icons/sets/hugeicons.tsx +0 -259
- package/app/icons/sets/phosphor.tsx +0 -251
- package/dist/server/icon-set.d.mts +0 -15
- package/dist/server/icon-set.mjs +0 -31
- package/dist/shared/icon-sets.d.mts +0 -9
- package/dist/shared/icon-sets.mjs +0 -21
- package/src/server/icon-set.ts +0 -56
- package/src/shared/icon-sets.ts +0 -23
- /package/app/public/{sudio-192.png → dex-192.png} +0 -0
- /package/app/public/{sudio-512.png → dex-512.png} +0 -0
- /package/app/public/{apple-touch-icon.png → dex-apple-touch-icon.png} +0 -0
- /package/app/public/{favicon-32.png → dex-icon-32.png} +0 -0
- /package/app/public/{favicon.svg → dex-icon.svg} +0 -0
- /package/app/public/{sudio-maskable-512.png → dex-maskable-512.png} +0 -0
package/dist/config/schema.mjs
CHANGED
|
@@ -105,11 +105,6 @@ const ui = z.looseObject({
|
|
|
105
105
|
accent: z.string().optional(),
|
|
106
106
|
chromeTheme: z.partialRecord(z.enum(CHROME_VARIABLES), z.string()).optional(),
|
|
107
107
|
components: text.optional(),
|
|
108
|
-
icons: z.enum([
|
|
109
|
-
"phosphor",
|
|
110
|
-
"lucide",
|
|
111
|
-
"hugeicons"
|
|
112
|
-
]).optional(),
|
|
113
108
|
locale: z.string().optional(),
|
|
114
109
|
primitives: z.union([text, z.literal(true)]).optional(),
|
|
115
110
|
subtitle: z.string().optional(),
|
package/dist/content/content.mjs
CHANGED
|
@@ -154,7 +154,6 @@ async function prototypeIssues(root, { slug, path, manifest, problem }, designSy
|
|
|
154
154
|
const CHROME_IMPORTS = [
|
|
155
155
|
"react",
|
|
156
156
|
"virtual:studio-ui",
|
|
157
|
-
"virtual:studio-icons",
|
|
158
157
|
"react-dom",
|
|
159
158
|
"wouter",
|
|
160
159
|
"next-themes",
|
|
@@ -169,8 +168,6 @@ const CHROME_IMPORTS = [
|
|
|
169
168
|
"canvas-confetti",
|
|
170
169
|
"motion/react",
|
|
171
170
|
"tw-animate-css",
|
|
172
|
-
"@hugeicons/",
|
|
173
|
-
"@phosphor-icons/",
|
|
174
171
|
"@lingui/",
|
|
175
172
|
"@fontsource-variable/inter",
|
|
176
173
|
"@studio/",
|
|
@@ -17,7 +17,7 @@ const NOT_LISTENING = /* @__PURE__ */ new Set([
|
|
|
17
17
|
/** Why fetch could not reach the studio, in words a person can act on. */
|
|
18
18
|
function unreachable(url, error) {
|
|
19
19
|
const cause = error?.cause;
|
|
20
|
-
if (cause?.code && NOT_LISTENING.has(cause.code)) return new SnapshotError(`Dex is not running at ${url}. Start it with \`npx dex dev\` (or the project's own script, such as \`npm run
|
|
20
|
+
if (cause?.code && NOT_LISTENING.has(cause.code)) return new SnapshotError(`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.`);
|
|
21
21
|
return new SnapshotError(`Dex at ${url} could not be asked: ${cause?.message ?? error?.message ?? String(error)}`);
|
|
22
22
|
}
|
|
23
23
|
const strings = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
package/dist/paste/paste.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MAX_SIDE } from "../content/capture.mjs";
|
|
2
1
|
import { isSnapshotClipboard, snapshotFrom } from "../shared/snapshot-clipboard.mjs";
|
|
3
2
|
import { fontBringer } from "./fonts.mjs";
|
|
3
|
+
import { MAX_SIDE } from "../content/capture.mjs";
|
|
4
4
|
import { PASTED_IMAGE_TYPES } from "../shared/pasted-image.mjs";
|
|
5
5
|
import { imageDataUrl, withImages } from "../shared/snapshot-images.mjs";
|
|
6
6
|
import { isFigmaClipboard } from "./figma/decode.mjs";
|
package/dist/server/brief.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { shownFrom } from "../paths.mjs";
|
|
1
|
+
import { TEMPLATES_DIR, shownFrom } from "../paths.mjs";
|
|
2
2
|
import { youOf } from "../shared/studio-routes.mjs";
|
|
3
3
|
import { fileLabel } from "../shared/prototypes-core.mjs";
|
|
4
4
|
import { prototypePaths } from "../content/prototypes.mjs";
|
|
@@ -154,9 +154,9 @@ async function guidesSection(guides, show) {
|
|
|
154
154
|
const always = ALWAYS_ON.includes(guide.path);
|
|
155
155
|
if (always && body.trim().length <= MAX_RULE) return "";
|
|
156
156
|
const when = always ? "Whatever the work: read it first" : frontMatterValue(yaml, WHEN_RE);
|
|
157
|
-
return `\`${show(guide.file)}
|
|
157
|
+
return `${guide.own ? `\`${show(guide.file)}\` (the team's own)` : `\`${guide.path}\``}${when ? `: ${words(when)}` : ""}`;
|
|
158
158
|
}));
|
|
159
|
-
return ["## Dex's rules and methods", `Read one when the work is what it says.\n\n${listed(entries.filter(Boolean), (more) => `and ${more} in those folders`, MAX_GUIDES)}`];
|
|
159
|
+
return ["## Dex's rules and methods", `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(entries.filter(Boolean), (more) => `and ${more} in those folders`, MAX_GUIDES)}`];
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
162
|
* The few lines an agent is told when it first hears from Dex, whether or
|
|
@@ -142,6 +142,12 @@ export declare function connectedAgents(root: string, { now, listeningMs, onGone
|
|
|
142
142
|
now?: number;
|
|
143
143
|
onGone?: OnGone;
|
|
144
144
|
}): Promise<ConnectedAgent[]>;
|
|
145
|
+
/**
|
|
146
|
+
* The agent sessions running on this machine now, by their heartbeats: not a
|
|
147
|
+
* teammate's, whose claims come from the workspace. Reads only; clearing old
|
|
148
|
+
* heartbeats is connectedAgents's.
|
|
149
|
+
*/
|
|
150
|
+
export declare function localSessions(root: string, now?: number): Promise<Set<string>>;
|
|
145
151
|
/** Why a session was left running: it isn't one Stop is for. */
|
|
146
152
|
export declare class NotAnOldSession extends Error {}
|
|
147
153
|
/**
|
package/dist/server/channel.mjs
CHANGED
|
@@ -214,6 +214,21 @@ async function connectedAgents(root, { now = Date.now(), listeningMs = LISTENING
|
|
|
214
214
|
}
|
|
215
215
|
return agents;
|
|
216
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* The agent sessions running on this machine now, by their heartbeats: not a
|
|
219
|
+
* teammate's, whose claims come from the workspace. Reads only; clearing old
|
|
220
|
+
* heartbeats is connectedAgents's.
|
|
221
|
+
*/
|
|
222
|
+
async function localSessions(root, now = Date.now()) {
|
|
223
|
+
const dir = studioState(root).agents;
|
|
224
|
+
const sessions = /* @__PURE__ */ new Set();
|
|
225
|
+
const names = await readdir(dir).catch(() => []);
|
|
226
|
+
for (const name of names.filter(isHeartbeat)) try {
|
|
227
|
+
const beat = JSON.parse(await readFile(join(dir, name), "utf8"));
|
|
228
|
+
if (beat.session && now - beat.at < 3e4) sessions.add(beat.session);
|
|
229
|
+
} catch {}
|
|
230
|
+
return sessions;
|
|
231
|
+
}
|
|
217
232
|
/** A heartbeat file's process, as it is named: "62653.json". */
|
|
218
233
|
const pidOf = (name) => {
|
|
219
234
|
const digits = PID_FILE_RE.exec(name)?.[1];
|
|
@@ -651,4 +666,4 @@ async function startChannel(server, root, threads, session, { from = process.cwd
|
|
|
651
666
|
return stop;
|
|
652
667
|
}
|
|
653
668
|
//#endregion
|
|
654
|
-
export { CHANNEL_ENV, CHANNEL_INSTRUCTIONS, CHANNEL_SERVER, FEEDBACK_WORKFLOW, GATHER_MS, LISTENING_MS, NotAnOldSession, OLD_CHANNEL_SERVERS, WATCH_GRACE_MS, channelEvent, connectedAgents, isWatching, openReceipt, receiptEvent, releaseAbandoned, releaseGone, sessionReport, setWatching, startChannel, startHeartbeat, stopAgentServer, trackAgents };
|
|
669
|
+
export { CHANNEL_ENV, CHANNEL_INSTRUCTIONS, CHANNEL_SERVER, FEEDBACK_WORKFLOW, GATHER_MS, LISTENING_MS, NotAnOldSession, OLD_CHANNEL_SERVERS, WATCH_GRACE_MS, channelEvent, connectedAgents, isWatching, localSessions, openReceipt, receiptEvent, releaseAbandoned, releaseGone, sessionReport, setWatching, startChannel, startHeartbeat, stopAgentServer, trackAgents };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ThreadModule } from "../content/thread-module.mjs";
|
|
2
|
+
import { PresenceMark } from "./presence.mjs";
|
|
3
|
+
//#region src/server/claimed-presence.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Mark the agent sessions with a claimed thread on the view or doc `file`
|
|
6
|
+
* belongs to as working on it. `file` is absolute; `content` is the studio's
|
|
7
|
+
* content folder. `sessions` are the agent sessions running on this machine:
|
|
8
|
+
* a teammate's claim, synced from the workspace, is never marked here.
|
|
9
|
+
*/
|
|
10
|
+
export declare function claimedPresence({ content, mark, sessions, threads, now }: {
|
|
11
|
+
content: string;
|
|
12
|
+
mark: (entry: PresenceMark) => Promise<void>;
|
|
13
|
+
sessions: () => Promise<Set<string>>;
|
|
14
|
+
threads: Pick<ThreadModule, "list">;
|
|
15
|
+
now?: () => number;
|
|
16
|
+
}): (file: string) => Promise<void>;
|
|
17
|
+
//#endregion
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { targetForPath } from "../shared/live-presence.mjs";
|
|
2
|
+
import { presenceTargetOf } from "./agent-session.mjs";
|
|
3
|
+
import { claimOf } from "../shared/threads-core.mjs";
|
|
4
|
+
import { relative } from "node:path";
|
|
5
|
+
//#region src/server/claimed-presence.ts
|
|
6
|
+
/** How often one claim's session is marked again while it edits. */
|
|
7
|
+
const REMARK_MS = 1e4;
|
|
8
|
+
/**
|
|
9
|
+
* Mark the agent sessions with a claimed thread on the view or doc `file`
|
|
10
|
+
* belongs to as working on it. `file` is absolute; `content` is the studio's
|
|
11
|
+
* content folder. `sessions` are the agent sessions running on this machine:
|
|
12
|
+
* a teammate's claim, synced from the workspace, is never marked here.
|
|
13
|
+
*/
|
|
14
|
+
function claimedPresence({ content, mark, sessions, threads, now = Date.now }) {
|
|
15
|
+
const marked = /* @__PURE__ */ new Map();
|
|
16
|
+
return async (file) => {
|
|
17
|
+
const edited = targetForPath(relative(content, file).replaceAll("\\", "/"));
|
|
18
|
+
if (!edited || edited.target === "prototype") return;
|
|
19
|
+
const claimed = await threads.list({
|
|
20
|
+
prototype: edited.slug,
|
|
21
|
+
status: "acknowledged"
|
|
22
|
+
});
|
|
23
|
+
const time = now();
|
|
24
|
+
const marks = [];
|
|
25
|
+
let local;
|
|
26
|
+
for (const thread of claimed) {
|
|
27
|
+
const claim = claimOf(thread);
|
|
28
|
+
const session = claim?.session;
|
|
29
|
+
if (!(claim && session) || presenceTargetOf(thread)?.target !== edited.target) continue;
|
|
30
|
+
const key = [
|
|
31
|
+
session,
|
|
32
|
+
thread.id,
|
|
33
|
+
edited.slug,
|
|
34
|
+
edited.target
|
|
35
|
+
].join("");
|
|
36
|
+
if (time - (marked.get(key) ?? Number.NEGATIVE_INFINITY) < REMARK_MS) continue;
|
|
37
|
+
local ??= await sessions();
|
|
38
|
+
if (!local.has(session)) continue;
|
|
39
|
+
marked.set(key, time);
|
|
40
|
+
marks.push({
|
|
41
|
+
...edited,
|
|
42
|
+
agent: claim.by,
|
|
43
|
+
session
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
await Promise.all(marks.map(mark));
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { claimedPresence };
|
|
@@ -6,6 +6,7 @@ import { prototypesDir } from "../content/prototypes.mjs";
|
|
|
6
6
|
import { checkForUpdate } from "./updates.mjs";
|
|
7
7
|
import { STUDIO_FILES, classify } from "../shared/studio-files.mjs";
|
|
8
8
|
import { openThreads } from "../content/thread-module.mjs";
|
|
9
|
+
import { localSessions } from "./channel.mjs";
|
|
9
10
|
import { WORKSPACE_ICON_FILES } from "../shared/workspace.mjs";
|
|
10
11
|
import { findConfigFile } from "../config/load.mjs";
|
|
11
12
|
import { closeScreenshotBrowser } from "../content/screenshot.mjs";
|
|
@@ -13,6 +14,7 @@ import { purgeTrash } from "../content/trash.mjs";
|
|
|
13
14
|
import { desktopApp, desktopAppUnavailable, macLaunchServices, openApp, refreshDesktopApp, revealInFinder } from "../setup/desktop-app.mjs";
|
|
14
15
|
import { AVATAR_FILES } from "../shared/avatar-file.mjs";
|
|
15
16
|
import { eventsForFile, studioEvent } from "../shared/studio-events.mjs";
|
|
17
|
+
import { claimedPresence } from "./claimed-presence.mjs";
|
|
16
18
|
import { eventHub, studioRequests } from "./requests.mjs";
|
|
17
19
|
import { existsSync, realpathSync } from "node:fs";
|
|
18
20
|
import { basename, dirname, join, relative, sep } from "node:path";
|
|
@@ -99,6 +101,12 @@ function studioDev(project) {
|
|
|
99
101
|
const parent = dirname(path);
|
|
100
102
|
return [content, realContent].some((root) => parent === join(root, ".studio") || parent === root && !READ_FOLDERS.has(basename(path)));
|
|
101
103
|
};
|
|
104
|
+
const markClaimed = claimedPresence({
|
|
105
|
+
content,
|
|
106
|
+
mark: presence.mark,
|
|
107
|
+
sessions: () => localSessions(content),
|
|
108
|
+
threads
|
|
109
|
+
});
|
|
102
110
|
const sendPresence = async () => events.send(studioEvent.presence(await presence.list()));
|
|
103
111
|
return {
|
|
104
112
|
name: "studio-dev",
|
|
@@ -132,6 +140,7 @@ function studioDev(project) {
|
|
|
132
140
|
return;
|
|
133
141
|
}
|
|
134
142
|
for (const event of eventsForFile(relative(content, file))) events.send(event);
|
|
143
|
+
markClaimed(file).catch(() => void 0);
|
|
135
144
|
};
|
|
136
145
|
for (const event of [
|
|
137
146
|
"add",
|
|
@@ -12,6 +12,11 @@ interface TransformError {
|
|
|
12
12
|
}
|
|
13
13
|
/** What went wrong in `file`, as a page shows it. */
|
|
14
14
|
export declare function describeFileError(file: string, path: string, error: TransformError): FileError;
|
|
15
|
-
/**
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Keeps a broken file in the content folder from breaking every page on the
|
|
17
|
+
* server. `imports` is the folder outside it that views import from, the
|
|
18
|
+
* components' (vite.ts): Vite watches only the files it loaded, so a file
|
|
19
|
+
* appearing there, such as a component shadcn adds, would go unseen.
|
|
20
|
+
*/
|
|
21
|
+
export declare const fileErrors: (content: string, imports?: string) => Plugin;
|
|
17
22
|
//#endregion
|
|
@@ -39,15 +39,33 @@ function describeFileError(file, path, error) {
|
|
|
39
39
|
...error.frame ? { frame: error.frame } : {}
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
/**
|
|
43
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Keeps a broken file in the content folder from breaking every page on the
|
|
44
|
+
* server. `imports` is the folder outside it that views import from, the
|
|
45
|
+
* components' (vite.ts): Vite watches only the files it loaded, so a file
|
|
46
|
+
* appearing there, such as a component shadcn adds, would go unseen.
|
|
47
|
+
*/
|
|
48
|
+
const fileErrors = (content, imports) => {
|
|
44
49
|
const errors = /* @__PURE__ */ new Map();
|
|
45
50
|
let server;
|
|
46
51
|
const list = () => [...errors.values()];
|
|
47
52
|
const tell = () => server?.ws.send(FILE_ERRORS_EVENT, list());
|
|
48
|
-
const
|
|
53
|
+
const listed = (file) => {
|
|
49
54
|
const path = inContent(content, file.replace(QUERY_RE, ""));
|
|
50
|
-
|
|
55
|
+
return path && errors.has(path) ? path : void 0;
|
|
56
|
+
};
|
|
57
|
+
const forget = (file) => {
|
|
58
|
+
const path = listed(file);
|
|
59
|
+
if (path) {
|
|
60
|
+
errors.delete(path);
|
|
61
|
+
tell();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const forgetAll = () => {
|
|
65
|
+
if (errors.size > 0) {
|
|
66
|
+
errors.clear();
|
|
67
|
+
tell();
|
|
68
|
+
}
|
|
51
69
|
};
|
|
52
70
|
return {
|
|
53
71
|
name: "studio-file-errors",
|
|
@@ -56,8 +74,16 @@ const fileErrors = (content) => {
|
|
|
56
74
|
server = devServer;
|
|
57
75
|
devServer.ws.on(FILE_ERRORS_EVENT, (_data, client) => client.send(FILE_ERRORS_EVENT, list()));
|
|
58
76
|
devServer.watcher.on("change", forget);
|
|
59
|
-
devServer.watcher.on("add",
|
|
77
|
+
devServer.watcher.on("add", forgetAll);
|
|
60
78
|
devServer.watcher.on("unlink", forget);
|
|
79
|
+
if (imports) devServer.watcher.add(imports);
|
|
80
|
+
devServer.middlewares.use((request, response, next) => {
|
|
81
|
+
const file = errors.size > 0 ? fileOf({}, request.url, devServer.config.root) : void 0;
|
|
82
|
+
if (file && listed(file)) response.once("finish", () => {
|
|
83
|
+
if (response.statusCode < 400) forget(file);
|
|
84
|
+
});
|
|
85
|
+
next();
|
|
86
|
+
});
|
|
61
87
|
return () => {
|
|
62
88
|
const onError = (error, request, response, next) => {
|
|
63
89
|
const file = fileOf(error, request.url, devServer.config.root);
|
|
@@ -78,9 +104,6 @@ const fileErrors = (content) => {
|
|
|
78
104
|
};
|
|
79
105
|
devServer.middlewares.use(onError);
|
|
80
106
|
};
|
|
81
|
-
},
|
|
82
|
-
transform(_code, id) {
|
|
83
|
-
if (errors.size > 0) forget(id);
|
|
84
107
|
}
|
|
85
108
|
};
|
|
86
109
|
};
|
package/dist/server/requests.mjs
CHANGED
|
@@ -27,6 +27,7 @@ import { NotAnOldSession, connectedAgents, isWatching, setWatching, stopAgentSer
|
|
|
27
27
|
import { addAgent, agentRootOf, agentSetups, isLaunchAgent, launchAgent } from "./agents.mjs";
|
|
28
28
|
import { BUILD_DEFAULTS } from "../shared/build-settings.mjs";
|
|
29
29
|
import { saveCaptures } from "../content/capture.mjs";
|
|
30
|
+
import { PasteProblem, readPaste } from "../paste/paste.mjs";
|
|
30
31
|
import { readText } from "../content/read-text.mjs";
|
|
31
32
|
import { removedSpecs } from "../content/flow-specs.mjs";
|
|
32
33
|
import { editProps } from "../content/prop-edit.mjs";
|
|
@@ -36,7 +37,6 @@ import { placeReviewPages } from "../content/review-pages.mjs";
|
|
|
36
37
|
import { isViewPage, screenshotFrame } from "../content/screenshot.mjs";
|
|
37
38
|
import { editText } from "../content/text-edit.mjs";
|
|
38
39
|
import { dismissThreadsOn, emptyTrash, removedViewsWithComments, trashHolds, trashViews } from "../content/trash.mjs";
|
|
39
|
-
import { PasteProblem, readPaste } from "../paste/paste.mjs";
|
|
40
40
|
import { readGitSettings, writeGitSettings } from "./git-settings.mjs";
|
|
41
41
|
import { checkGitSetup, checkLog, realGitProbes } from "../setup/git-checks.mjs";
|
|
42
42
|
import { bundlePath, desktopAppState, installDesktopApp, removeDesktopApp } from "../setup/desktop-app.mjs";
|
|
@@ -57,7 +57,7 @@ async function studioFor({ content, root, port: configured }, { holderOf = lsofH
|
|
|
57
57
|
holder: holderName(holder)
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
const START = "Start it with `npx dex dev` (or the project's own script, such as `npm run
|
|
60
|
+
const START = "Start it with `npx dex dev` (or the project's own script, such as `npm run dex`), then try again.";
|
|
61
61
|
const ports = (tried) => tried.map((port) => `:${port}`).join(", ");
|
|
62
62
|
/** Why there is no Dex to ask, in words a person can act on. */
|
|
63
63
|
function notRunning(found) {
|
package/dist/server/vite.mjs
CHANGED
|
@@ -14,7 +14,6 @@ import { EXAMPLE_FILES, OLD_EXAMPLE_FILES, findConfigFile } from "../config/load
|
|
|
14
14
|
import { componentFileProps, withConfiguredProps } from "../content/component-props.mjs";
|
|
15
15
|
import { prepareContent } from "../content/first-run.mjs";
|
|
16
16
|
import { lacksNext, next } from "./next.mjs";
|
|
17
|
-
import { interfaceIconSet } from "./icon-set.mjs";
|
|
18
17
|
import { readBuildSettings } from "./build-settings.mjs";
|
|
19
18
|
import { readMe } from "./me.mjs";
|
|
20
19
|
import { findWorkspaceIcon, readWorkspace, workspaceIconBytes } from "./workspace-settings.mjs";
|
|
@@ -129,6 +128,25 @@ const GENERATED = "/* Generated by Dex on every start. Do not edit. */";
|
|
|
129
128
|
*/
|
|
130
129
|
const interfaceTakesDesignSystem = (project) => project.ui?.theme === "design-system" || Boolean(project.ui?.components || project.ui?.primitives);
|
|
131
130
|
/**
|
|
131
|
+
* Where views import the project's components from: the top folder of the
|
|
132
|
+
* package they are in ("src" for src/components/ui), which holds what views
|
|
133
|
+
* import beside them too, such as a block shadcn adds to src/components.
|
|
134
|
+
* Vite's root is Dex's own, so neither Tailwind nor Vite's watcher finds any
|
|
135
|
+
* of it on their own, as they do in the project: views' Tailwind scans it,
|
|
136
|
+
* and the watcher sees a file appear in it (file-errors.ts). Never the
|
|
137
|
+
* package itself, which for an app is the whole repository, its node_modules
|
|
138
|
+
* and Dex's output with it; a package in node_modules gives its components'
|
|
139
|
+
* folder alone.
|
|
140
|
+
*/
|
|
141
|
+
function componentsRoot(project) {
|
|
142
|
+
const folder = project.designSystem?.componentSource?.folder;
|
|
143
|
+
if (!folder) return;
|
|
144
|
+
const home = project.designSystem?.componentPackage ?? project.root;
|
|
145
|
+
const path = relative(home, folder);
|
|
146
|
+
if (!path || path.startsWith("..") || isAbsolute(path) || folder.split(sep).includes("node_modules")) return folder;
|
|
147
|
+
return join(home, path.split(sep)[0] ?? "");
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
132
150
|
* Two stylesheets per project, one for each page. The frame page's is what
|
|
133
151
|
* the real product would have: the design system's CSS (it brings Tailwind
|
|
134
152
|
* and the tokens) and Tailwind told where the prototypes and the design
|
|
@@ -143,7 +161,6 @@ async function writeEntries(project) {
|
|
|
143
161
|
return `@import "${isAbsolute(entry) ? from(entry) : entry}"${layer ? ` layer(${layer})` : ""};`;
|
|
144
162
|
});
|
|
145
163
|
const sources = (values) => [...new Set(values.map((value) => value && folderOf(value, project.root)).filter((folder) => Boolean(folder)).map((folder) => `@source "${from(folder)}";`))];
|
|
146
|
-
const componentFolder = project.designSystem?.componentSource?.folder;
|
|
147
164
|
const tailwind = tailwindSetup(project.root);
|
|
148
165
|
const tailwind3 = tailwind3Config([project.designSystem?.componentPackage, project.root])?.config;
|
|
149
166
|
const config = tailwind3 ? [`@config "${from(tailwind3)}";`] : [];
|
|
@@ -155,7 +172,7 @@ async function writeEntries(project) {
|
|
|
155
172
|
`@import "${from(join(APP_DIR, "frame.css"))}";`,
|
|
156
173
|
...config,
|
|
157
174
|
`@source "${from(prototypesDir(project.content))}";`,
|
|
158
|
-
...sources([
|
|
175
|
+
...sources([componentsRoot(project)]),
|
|
159
176
|
""
|
|
160
177
|
].join("\n");
|
|
161
178
|
const own = [
|
|
@@ -189,18 +206,14 @@ async function sourceFiles(dir) {
|
|
|
189
206
|
}
|
|
190
207
|
return files;
|
|
191
208
|
}
|
|
192
|
-
const ICON_SETS_DIR = join(APP_DIR, "icons", "sets");
|
|
193
|
-
const iconSetFile = (set) => join(ICON_SETS_DIR, `${set}.tsx`);
|
|
194
209
|
/**
|
|
195
|
-
* Every library the studio's own interface imports
|
|
196
|
-
* it draws with: the others may not be installed. Installed from npm, the
|
|
210
|
+
* Every library the studio's own interface imports. Installed from npm, the
|
|
197
211
|
* interface lives in node_modules, where Vite neither crawls imports nor
|
|
198
212
|
* converts CommonJS for the browser, so they are listed for it to prepare.
|
|
199
213
|
*/
|
|
200
|
-
async function interfaceDependencies(
|
|
214
|
+
async function interfaceDependencies() {
|
|
201
215
|
const found = /* @__PURE__ */ new Set();
|
|
202
|
-
const
|
|
203
|
-
for (const file of files) for (const specifier of importsIn(await readFile(file, "utf8"))) if (!MACRO_IMPORT_RE.test(specifier)) found.add(specifier);
|
|
216
|
+
for (const file of await sourceFiles(APP_DIR)) for (const specifier of importsIn(await readFile(file, "utf8"))) if (!MACRO_IMPORT_RE.test(specifier)) found.add(specifier);
|
|
204
217
|
return [...found].sort();
|
|
205
218
|
}
|
|
206
219
|
const LINGUI_MACRO = "@lingui/babel-plugin-lingui-macro";
|
|
@@ -248,20 +261,6 @@ const studioMacros = () => {
|
|
|
248
261
|
}
|
|
249
262
|
};
|
|
250
263
|
};
|
|
251
|
-
const ICONS_MODULE = "virtual:studio-icons";
|
|
252
|
-
const RESOLVED_ICONS_MODULE = `\0${ICONS_MODULE}`;
|
|
253
|
-
/**
|
|
254
|
-
* `virtual:studio-icons`: the glyphs of the icon set the interface draws
|
|
255
|
-
* with (interfaceIconSet). Only that set is bundled.
|
|
256
|
-
*/
|
|
257
|
-
const studioIcons = (project) => {
|
|
258
|
-
const set = interfaceIconSet(project);
|
|
259
|
-
return {
|
|
260
|
-
name: "studio-icons",
|
|
261
|
-
resolveId: (id) => id === ICONS_MODULE ? RESOLVED_ICONS_MODULE : void 0,
|
|
262
|
-
load: (id) => id === RESOLVED_ICONS_MODULE ? `export { glyphs } from ${JSON.stringify(iconSetFile(set))};\n` : void 0
|
|
263
|
-
};
|
|
264
|
-
};
|
|
265
264
|
/**
|
|
266
265
|
* While serving, what a module made from `build` in dex.config.ts has is
|
|
267
266
|
* made again once the file changes (Settings → Deployment writes it), so a
|
|
@@ -352,14 +351,13 @@ const studioInterface = (project) => {
|
|
|
352
351
|
load: async (id) => {
|
|
353
352
|
if (id !== RESOLVED_UI_MODULE) return;
|
|
354
353
|
const build = serving ? await readBuildSettings(project.root) : project.build;
|
|
355
|
-
const { title, subtitle, theme, locale, chromeTheme, components
|
|
354
|
+
const { title, subtitle, theme, locale, chromeTheme, components } = project.ui ?? {};
|
|
356
355
|
return `${`export const ui = ${JSON.stringify({
|
|
357
356
|
title: workspaceName(title),
|
|
358
357
|
subtitle,
|
|
359
358
|
theme,
|
|
360
359
|
locale,
|
|
361
360
|
chromeTheme,
|
|
362
|
-
icons,
|
|
363
361
|
workspaceIcon
|
|
364
362
|
})};`}\n${components ? `export * as slots from ${JSON.stringify(resolve(project.root, components))};` : "export const slots = {};"}\nexport const features = ${JSON.stringify(features())};\nexport const build = ${JSON.stringify(build)};\n`;
|
|
365
363
|
}
|
|
@@ -686,7 +684,6 @@ async function viteConfig(project, mode) {
|
|
|
686
684
|
reactFromStudio(),
|
|
687
685
|
tailwindcss(),
|
|
688
686
|
studioInterface(project),
|
|
689
|
-
studioIcons(project),
|
|
690
687
|
studioThreads(project),
|
|
691
688
|
studioDesignSystem(project),
|
|
692
689
|
studioComponents(project),
|
|
@@ -695,7 +692,7 @@ async function viteConfig(project, mode) {
|
|
|
695
692
|
...project.plugins,
|
|
696
693
|
...await lacksNext(project) ? [next()] : [],
|
|
697
694
|
studioDev(project),
|
|
698
|
-
fileErrors(project.content),
|
|
695
|
+
fileErrors(project.content, componentsRoot(project)),
|
|
699
696
|
studioWebApp(project),
|
|
700
697
|
projectPublic(project.root)
|
|
701
698
|
],
|
|
@@ -736,7 +733,7 @@ async function viteConfig(project, mode) {
|
|
|
736
733
|
searchForWorkspaceRoot(PACKAGE_ROOT)
|
|
737
734
|
] }
|
|
738
735
|
},
|
|
739
|
-
optimizeDeps: { include: await interfaceDependencies(
|
|
736
|
+
optimizeDeps: { include: await interfaceDependencies() },
|
|
740
737
|
preview: { port: project.port },
|
|
741
738
|
build: {
|
|
742
739
|
outDir: project.outDir,
|
package/dist/server/web-app.mjs
CHANGED
|
@@ -30,17 +30,17 @@ const webAppManifest = (name) => ({
|
|
|
30
30
|
theme_color: LIGHT,
|
|
31
31
|
icons: [
|
|
32
32
|
{
|
|
33
|
-
src: "
|
|
33
|
+
src: "dex-192.png",
|
|
34
34
|
sizes: "192x192",
|
|
35
35
|
type: "image/png"
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
|
-
src: "
|
|
38
|
+
src: "dex-512.png",
|
|
39
39
|
sizes: "512x512",
|
|
40
40
|
type: "image/png"
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
|
-
src: "
|
|
43
|
+
src: "dex-maskable-512.png",
|
|
44
44
|
sizes: "512x512",
|
|
45
45
|
type: "image/png",
|
|
46
46
|
purpose: "maskable"
|
package/dist/setup/apply.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { PACKAGE_NAME, posix as posix$1 } from "../paths.mjs";
|
|
2
2
|
import { STATE_FOLDER } from "../server/state.mjs";
|
|
3
3
|
import { STUDIO_FILES } from "../shared/studio-files.mjs";
|
|
4
|
-
import { ICON_SET_NAMES } from "../shared/icon-sets.mjs";
|
|
5
4
|
import { compilerOption, tsconfigFile } from "../config/project-files.mjs";
|
|
6
5
|
import { componentFiles, isPath, providerModule } from "../config/design-system.mjs";
|
|
7
6
|
import { draftFor } from "./design-md-setup.mjs";
|
|
@@ -13,7 +12,7 @@ import { agentName, componentsChoice, connectInStudio } from "./project.mjs";
|
|
|
13
12
|
import { nextPackage } from "../server/next.mjs";
|
|
14
13
|
import { choicesOnly } from "./config-choices.mjs";
|
|
15
14
|
import { formatAsProject, keepLockfilesFormatted, readLockfiles } from "./host-format.mjs";
|
|
16
|
-
import { STUDIO_TYPES, configSource, designSystemConfig, fromStudio, ignoreFile, missingIgnoreLines, missingScripts, tsconfigJson, withIgnoreLines, withPointer } from "./write.mjs";
|
|
15
|
+
import { STUDIO_TYPES, configSource, designSystemConfig, fromStudio, ignoreFile, missingIgnoreLines, missingScripts, pnpmDecidesEsbuild, tsconfigJson, withEsbuildBuilds, withIgnoreLines, withPointer } from "./write.mjs";
|
|
17
16
|
import { appPackageJson, appTsconfigJson, turboJson } from "./own-app.mjs";
|
|
18
17
|
import { PROVIDER_FILE } from "./questions.mjs";
|
|
19
18
|
import { commandLine, planCounts } from "./plan.mjs";
|
|
@@ -125,18 +124,12 @@ function afterShadcn(root, decisions) {
|
|
|
125
124
|
kind: "folder",
|
|
126
125
|
choice
|
|
127
126
|
};
|
|
128
|
-
const icons = choice.icons ?? decisions.icons.value;
|
|
129
127
|
return {
|
|
130
128
|
...decisions,
|
|
131
129
|
components: {
|
|
132
130
|
...decisions.components,
|
|
133
131
|
value
|
|
134
132
|
},
|
|
135
|
-
icons: decisions.icons.source === "--icons" ? decisions.icons : {
|
|
136
|
-
...decisions.icons,
|
|
137
|
-
value: icons,
|
|
138
|
-
shown: ICON_SET_NAMES[icons]
|
|
139
|
-
},
|
|
140
133
|
styles: decisions.styles.value || decisions.styles.source === "--styles none" ? decisions.styles : {
|
|
141
134
|
...decisions.styles,
|
|
142
135
|
value: choice.styles,
|
|
@@ -195,7 +188,6 @@ async function writeStep(step, context) {
|
|
|
195
188
|
await write(file, configSource(written, {
|
|
196
189
|
studio: posix$1(relative(packageDir, content)) || ".",
|
|
197
190
|
primitives: decisions.primitives.value,
|
|
198
|
-
icons: decisions.icons.value,
|
|
199
191
|
next: nextPackage(nextFolders(packageDir, decisions, resolved?.componentPackage)) !== void 0
|
|
200
192
|
}));
|
|
201
193
|
} else if (step.write === "provider" && decisions.provider?.value.kind === "write") await write(file, decisions.provider.value.need.source);
|
|
@@ -203,7 +195,6 @@ async function writeStep(step, context) {
|
|
|
203
195
|
else if (step.write === "types") await write(file, STUDIO_TYPES);
|
|
204
196
|
else if (step.write === "scripts") {
|
|
205
197
|
const spec = plan.workspace?.studioSpec;
|
|
206
|
-
const icons = plan.workspace ? plan.iconPackages : {};
|
|
207
198
|
const own = plan.target.kind === "own-app";
|
|
208
199
|
await editManifest(file, (manifest) => {
|
|
209
200
|
const scripts = recordAt(manifest, "scripts");
|
|
@@ -211,10 +202,9 @@ async function writeStep(step, context) {
|
|
|
211
202
|
...scripts,
|
|
212
203
|
...missingScripts(scripts)
|
|
213
204
|
};
|
|
214
|
-
if (spec
|
|
205
|
+
if (spec) manifest.devDependencies = {
|
|
215
206
|
...recordAt(manifest, "devDependencies"),
|
|
216
|
-
|
|
217
|
-
...icons
|
|
207
|
+
[PACKAGE_NAME]: spec
|
|
218
208
|
};
|
|
219
209
|
});
|
|
220
210
|
} else if (step.write === "root-script" && plan.workspace) {
|
|
@@ -223,7 +213,7 @@ async function writeStep(step, context) {
|
|
|
223
213
|
const scripts = recordAt(manifest, "scripts");
|
|
224
214
|
manifest.scripts = {
|
|
225
215
|
...scripts,
|
|
226
|
-
|
|
216
|
+
dex: scripts.dex ?? script
|
|
227
217
|
};
|
|
228
218
|
});
|
|
229
219
|
} else await editProjectFile(step, file, plan);
|
|
@@ -240,6 +230,10 @@ async function editProjectFile(step, file, plan) {
|
|
|
240
230
|
const missing = missingIgnoreLines(text, lines);
|
|
241
231
|
await writeFile(file, withIgnoreLines(text, missing));
|
|
242
232
|
} else if (step.write === "pointer") await writeFile(file, withPointer(text, studio));
|
|
233
|
+
else if (step.write === "pnpm-builds") {
|
|
234
|
+
const edited = withEsbuildBuilds(text);
|
|
235
|
+
if (edited !== void 0 && !pnpmDecidesEsbuild(text)) await writeFile(file, edited);
|
|
236
|
+
}
|
|
243
237
|
}
|
|
244
238
|
/**
|
|
245
239
|
* The studio's DESIGN.md, when it starts from a draft or an import: the
|