@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.
- package/CHANGELOG.md +36 -0
- package/README.md +5 -3
- package/app/canvas/activity.tsx +8 -15
- package/app/canvas/anchoring.ts +3 -5
- package/app/canvas/canvas-input.ts +151 -14
- package/app/canvas/canvas-keys.ts +9 -0
- package/app/canvas/canvas-model.ts +5 -42
- package/app/canvas/canvas-panels.ts +1 -17
- package/app/canvas/canvas-scene.ts +7 -3
- package/app/canvas/canvas-ui.ts +2 -1
- package/app/canvas/canvas.css +61 -26
- package/app/canvas/change-notice.tsx +10 -1
- package/app/canvas/comment-layer.tsx +2 -1
- package/app/canvas/comments.tsx +204 -82
- package/app/canvas/element-picker.ts +200 -27
- package/app/canvas/engine/canvas-gestures.ts +72 -17
- package/app/canvas/engine/canvas-store.ts +17 -1
- package/app/canvas/engine/engine.css +6 -3
- package/app/canvas/find-bar.tsx +817 -0
- package/app/canvas/find-model.ts +135 -0
- package/app/canvas/flow-canvas.tsx +18 -2
- package/app/canvas/follow-pin.ts +26 -6
- package/app/canvas/frame-node.tsx +9 -9
- package/app/canvas/imported-reviews.tsx +12 -22
- package/app/canvas/layout.ts +27 -0
- package/app/canvas/live-page.ts +142 -19
- package/app/canvas/page-find.ts +220 -0
- package/app/canvas/page-style.ts +23 -0
- package/app/canvas/section-node.tsx +2 -0
- package/app/canvas/spec-threads.ts +24 -23
- package/app/canvas/thread-focus.tsx +14 -12
- package/app/canvas/use-activity.ts +0 -8
- package/app/canvas/use-agent-changes.tsx +34 -40
- package/app/canvas/use-canvas-clipboard.tsx +11 -14
- package/app/canvas/xray.ts +3 -12
- package/app/frame.tsx +5 -0
- package/app/i18n/locales/en/messages.po +88 -8
- package/app/i18n/locales/en/messages.ts +1 -1
- package/app/i18n/locales/pseudo/messages.po +88 -8
- package/app/i18n/locales/pseudo/messages.ts +1 -1
- package/app/icons/glyphs.tsx +4 -0
- package/app/main.tsx +3 -0
- package/app/pages/canvas.tsx +27 -8
- package/app/pages/commands-settings.tsx +16 -2
- package/app/shell/feedback-form.tsx +10 -21
- package/app/shell/feedback-link.tsx +2 -1
- package/app/shell/scaled-frame.tsx +21 -9
- package/app/types.ts +21 -205
- package/app/ui/file-drop.ts +128 -0
- package/app/ui/shadcn/input-group.tsx +2 -2
- package/dist/cli/banner.d.mts +4 -2
- package/dist/cli/banner.mjs +34 -11
- package/dist/cli/commands/app.mjs +19 -11
- package/dist/cli/commands/hook.mjs +2 -1
- package/dist/config/project-files.d.mts +6 -0
- package/dist/config/project-files.mjs +14 -2
- package/dist/config/renamed.d.mts +0 -2
- package/dist/config/renamed.mjs +1 -3
- package/dist/content/capture.d.mts +2 -2
- package/dist/content/capture.mjs +2 -2
- package/dist/content/content.d.mts +3 -141
- package/dist/content/content.mjs +7 -62
- package/dist/content/flow-specs.mjs +1 -1
- package/dist/content/prototype-summary.d.mts +3 -39
- package/dist/content/prototype-summary.mjs +2 -3
- package/dist/content/prototypes.mjs +1 -1
- package/dist/content/text-replace.d.mts +30 -0
- package/dist/content/text-replace.mjs +309 -0
- package/dist/content/thread-module.mjs +1 -1
- package/dist/content/threads.mjs +1 -1
- package/dist/paste/paste.mjs +1 -1
- package/dist/paths.d.mts +0 -2
- package/dist/paths.mjs +1 -3
- package/dist/server/agent-env.d.mts +5 -1
- package/dist/server/agent-env.mjs +7 -2
- package/dist/server/agent-session.d.mts +14 -1
- package/dist/server/agent-session.mjs +84 -19
- package/dist/server/build-pictures.mjs +1 -1
- package/dist/server/channel.d.mts +13 -24
- package/dist/server/channel.mjs +55 -37
- package/dist/server/claimed-presence.d.mts +3 -2
- package/dist/server/claimed-presence.mjs +15 -7
- package/dist/server/close-check.mjs +2 -2
- package/dist/server/comments/actions.d.mts +153 -0
- package/dist/server/comments/actions.mjs +154 -0
- package/dist/server/comments/routes.d.mts +25 -0
- package/dist/server/comments/routes.mjs +88 -0
- package/dist/server/comments/tools.d.mts +6 -0
- package/dist/server/comments/tools.mjs +154 -0
- package/dist/server/dev-server.mjs +27 -13
- package/dist/server/file-lock.d.mts +2 -2
- package/dist/server/file-lock.mjs +130 -36
- package/dist/server/mcp.d.mts +0 -2
- package/dist/server/mcp.mjs +7 -8
- package/dist/server/me.d.mts +1 -1
- package/dist/server/open-page.d.mts +22 -0
- package/dist/server/open-page.mjs +20 -2
- package/dist/server/outcome.d.mts +22 -0
- package/dist/server/outcome.mjs +8 -0
- package/dist/server/own-copies.mjs +2 -2
- package/dist/server/people.d.mts +1 -1
- package/dist/server/port.d.mts +12 -0
- package/dist/server/port.mjs +66 -14
- package/dist/server/presence.d.mts +4 -1
- package/dist/server/presence.mjs +2 -2
- package/dist/server/requests.d.mts +5 -1
- package/dist/server/requests.mjs +33 -48
- package/dist/server/studio-for.d.mts +5 -0
- package/dist/server/studio-for.mjs +17 -3
- package/dist/server/sync-install.d.mts +8 -12
- package/dist/server/sync-install.mjs +12 -30
- package/dist/server/thread-source.mjs +2 -2
- package/dist/server/tools/describe.d.mts +1 -1
- package/dist/server/tools/describe.mjs +1 -1
- package/dist/server/tools/feedback.d.mts +1 -1
- package/dist/server/tools/reading.mjs +13 -4
- package/dist/server/tools/show.d.mts +1 -1
- package/dist/server/tools/snapshot.d.mts +1 -1
- package/dist/server/tools/thread-list.mjs +1 -1
- package/dist/server/tools/watch.mjs +5 -3
- package/dist/server/vite.mjs +2 -2
- package/dist/server/web-app.mjs +4 -7
- package/dist/server/work-groups.mjs +1 -1
- package/dist/setup/create.d.mts +4 -2
- package/dist/setup/create.mjs +67 -17
- package/dist/setup/design-system-checks.mjs +3 -12
- package/dist/setup/desktop-app-script.mjs +4 -3
- package/dist/setup/desktop-app-start.d.mts +8 -2
- package/dist/setup/desktop-app-start.mjs +64 -29
- package/dist/setup/desktop-app.d.mts +8 -0
- package/dist/setup/desktop-app.mjs +19 -3
- package/dist/setup/detect.d.mts +0 -2
- package/dist/setup/detect.mjs +1 -3
- package/dist/setup/doctor.mjs +1 -1
- package/dist/setup/migrate/row-titles.mjs +1 -1
- package/dist/setup/project.d.mts +6 -1
- package/dist/setup/project.mjs +9 -9
- package/dist/setup/starters.d.mts +2 -0
- package/dist/setup/starters.mjs +7 -1
- package/dist/shared/annotations-core.mjs +1 -1
- package/dist/shared/canvas-core.mjs +1 -1
- package/dist/shared/canvas-file.d.mts +201 -0
- package/dist/shared/canvas-file.mjs +1 -0
- package/dist/shared/comments/routes.d.mts +53 -0
- package/dist/shared/comments/routes.mjs +37 -0
- package/dist/shared/feedback.d.mts +8 -0
- package/dist/shared/feedback.mjs +10 -2
- package/dist/shared/page-review.d.mts +2 -11
- package/dist/shared/page-review.mjs +4 -13
- package/dist/shared/presence-core.d.mts +11 -0
- package/dist/shared/presence-core.mjs +11 -2
- package/dist/shared/review-file.d.mts +5 -0
- package/dist/shared/review-file.mjs +23 -13
- package/dist/shared/server-page.mjs +1 -1
- package/dist/shared/signup.d.mts +2 -5
- package/dist/shared/signup.mjs +2 -35
- package/dist/shared/studio-events.d.mts +0 -6
- package/dist/shared/studio-events.mjs +1 -5
- package/dist/shared/studio-files.d.mts +12 -0
- package/dist/shared/studio-files.mjs +6 -1
- package/dist/shared/studio-routes.d.mts +16 -62
- package/dist/shared/studio-routes.mjs +1 -69
- package/dist/shared/threads-core.d.mts +2 -2
- package/dist/shared/threads-core.mjs +1 -1
- package/extension/dist/feedback.js +148 -138
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/picker.js +146 -136
- package/package.json +2 -2
- package/src/cli/banner.ts +45 -11
- package/src/cli/commands/app.ts +23 -8
- package/src/cli/commands/hook.ts +4 -1
- package/src/config/project-files.ts +21 -6
- package/src/config/renamed.ts +0 -3
- package/src/content/capture.ts +6 -12
- package/src/content/content.ts +7 -241
- package/src/content/flow-specs.ts +2 -1
- package/src/content/prototype-summary.ts +4 -44
- package/src/content/review-pages.ts +2 -1
- package/src/content/text-replace.ts +449 -0
- package/src/paths.ts +0 -8
- package/src/server/agent-env.ts +12 -2
- package/src/server/agent-session.ts +124 -34
- package/src/server/channel.ts +94 -52
- package/src/server/claimed-presence.ts +26 -10
- package/src/server/comments/actions.ts +352 -0
- package/src/server/comments/routes.ts +176 -0
- package/src/server/comments/tools.ts +317 -0
- package/src/server/dev-server.ts +36 -15
- package/src/server/file-lock.ts +205 -54
- package/src/server/mcp.ts +13 -14
- package/src/server/me.ts +2 -5
- package/src/server/open-page.ts +54 -4
- package/src/server/outcome.ts +26 -0
- package/src/server/people.ts +2 -1
- package/src/server/port.ts +94 -20
- package/src/server/presence.ts +11 -3
- package/src/server/requests.ts +60 -70
- package/src/server/studio-for.ts +26 -2
- package/src/server/sync-install.ts +35 -26
- package/src/server/thread-place.ts +2 -4
- package/src/server/tools/reading.ts +16 -3
- package/src/server/tools/watch.ts +7 -7
- package/src/server/web-app.ts +11 -9
- package/src/setup/create.ts +91 -17
- package/src/setup/design-system-checks.ts +7 -15
- package/src/setup/desktop-app-script.ts +4 -3
- package/src/setup/desktop-app-start.ts +94 -26
- package/src/setup/desktop-app.ts +23 -2
- package/src/setup/detect.ts +0 -4
- package/src/setup/project.ts +9 -8
- package/src/setup/starters.ts +8 -1
- package/src/shared/canvas-file.ts +205 -0
- package/src/shared/comments/routes.ts +79 -0
- package/src/shared/feedback.ts +14 -4
- package/src/shared/page-review.ts +11 -16
- package/src/shared/presence-core.ts +16 -2
- package/src/shared/review-file.ts +28 -12
- package/src/shared/server-page.ts +2 -1
- package/src/shared/signup.ts +4 -28
- package/src/shared/studio-events.ts +0 -13
- package/src/shared/studio-files.ts +14 -0
- package/src/shared/studio-routes.ts +21 -64
- package/src/shared/threads-core.ts +2 -2
- package/dist/server/tools/close-reply.d.mts +0 -6
- package/dist/server/tools/close-reply.mjs +0 -138
- package/dist/server/tools/comment.d.mts +0 -6
- package/dist/server/tools/comment.mjs +0 -49
- package/src/server/tools/close-reply.ts +0 -271
- package/src/server/tools/comment.ts +0 -96
|
@@ -1,36 +1,21 @@
|
|
|
1
|
-
import { lsofHolder, whatHolds } from "../server/port.mjs";
|
|
1
|
+
import { heldOnLocalhost, lsofHolder, whatHolds } from "../server/port.mjs";
|
|
2
|
+
import { GIVE_UP_AFTER_MS } from "../shared/server-page.mjs";
|
|
2
3
|
import { FROM_APP_ENV } from "../server/roster.mjs";
|
|
4
|
+
import { ownPort, studioFor } from "../server/studio-for.mjs";
|
|
3
5
|
import { logFile, pidFile, projectGone } from "./desktop-app.mjs";
|
|
4
6
|
import { existsSync } from "node:fs";
|
|
5
7
|
import { dirname } from "node:path";
|
|
6
8
|
import { promisify } from "node:util";
|
|
7
9
|
import { execFile, spawn } from "node:child_process";
|
|
8
|
-
import { mkdir, open, rm, writeFile } from "node:fs/promises";
|
|
9
|
-
import { connect } from "node:net";
|
|
10
|
+
import { mkdir, open, readFile, rm, stat, writeFile } from "node:fs/promises";
|
|
10
11
|
//#region src/setup/desktop-app-start.ts
|
|
11
12
|
const run = promisify(execFile);
|
|
12
13
|
/** Where Node, git and the rest usually are on a Mac, when the shell can't say. */
|
|
13
14
|
const DEFAULT_PATH = "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin";
|
|
14
15
|
/** How long the login shell may take to say its PATH. */
|
|
15
16
|
const SHELL_TIMEOUT_MS = 5e3;
|
|
16
|
-
/** How long the port may take to answer a connection. */
|
|
17
|
-
const CONNECT_TIMEOUT_MS = 1e3;
|
|
18
17
|
/** Comes before the PATH in the shell's output, past whatever its startup prints. */
|
|
19
18
|
const PATH_MARK = "__DEX_PATH__";
|
|
20
|
-
/** Whether anything accepts a connection on the port, on localhost. */
|
|
21
|
-
const listening = (port) => new Promise((answer) => {
|
|
22
|
-
const socket = connect({
|
|
23
|
-
port,
|
|
24
|
-
host: "localhost"
|
|
25
|
-
});
|
|
26
|
-
const done = (open) => {
|
|
27
|
-
socket.destroy();
|
|
28
|
-
answer(open);
|
|
29
|
-
};
|
|
30
|
-
socket.setTimeout(CONNECT_TIMEOUT_MS, () => done(false));
|
|
31
|
-
socket.once("connect", () => done(true));
|
|
32
|
-
socket.once("error", () => done(false));
|
|
33
|
-
});
|
|
34
19
|
/**
|
|
35
20
|
* The PATH the person's own shell sets up at login, as a terminal has it:
|
|
36
21
|
* the app is opened with only the system's, and `dex dev` runs git,
|
|
@@ -88,26 +73,76 @@ async function startDev(options) {
|
|
|
88
73
|
}
|
|
89
74
|
}
|
|
90
75
|
/**
|
|
76
|
+
* The `dex dev` the last start began, while it may still come up: alive,
|
|
77
|
+
* and started less than the minute the app's window waits for it. Past
|
|
78
|
+
* that, its pid may be another process's.
|
|
79
|
+
*/
|
|
80
|
+
async function startUnderWay(file) {
|
|
81
|
+
try {
|
|
82
|
+
const [text, { mtimeMs }] = await Promise.all([readFile(file, "utf8"), stat(file)]);
|
|
83
|
+
const pid = Number(text.trim());
|
|
84
|
+
const young = Date.now() - mtimeMs <= GIVE_UP_AFTER_MS;
|
|
85
|
+
if (!(Number.isInteger(pid) && pid > 0 && young)) return;
|
|
86
|
+
process.kill(pid, 0);
|
|
87
|
+
return pid;
|
|
88
|
+
} catch {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The port this project's Dex is on, as its roster says, or undefined.
|
|
94
|
+
* On the app's port, it was only slow to answer, and the app opens it. On
|
|
95
|
+
* another port, the app can't open it, so it says where it is.
|
|
96
|
+
*/
|
|
97
|
+
async function ownDexPort(root, port, holderOf) {
|
|
98
|
+
try {
|
|
99
|
+
const { loadProject } = await import("../config/load.mjs");
|
|
100
|
+
const { content } = await loadProject(root);
|
|
101
|
+
return ownPort(await studioFor({
|
|
102
|
+
content,
|
|
103
|
+
root,
|
|
104
|
+
port
|
|
105
|
+
}, { holderOf }));
|
|
106
|
+
} catch {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
91
111
|
* Show this project's Dex, or start it: never a server another project,
|
|
92
|
-
* or anything else, put on the port.
|
|
112
|
+
* or anything else, put on the port. The app's start link asks again as
|
|
113
|
+
* the app opens: then the `dex dev` it started is still coming up, and
|
|
114
|
+
* it waits on that one rather than start another.
|
|
93
115
|
*/
|
|
94
116
|
async function startForApp(options) {
|
|
95
117
|
const { home, project, root, port, holderOf = lsofHolder } = options;
|
|
96
|
-
|
|
97
|
-
if (!existsSync(root))
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
118
|
+
const pidPath = pidFile(home, project);
|
|
119
|
+
if (!existsSync(root)) {
|
|
120
|
+
await rm(pidPath, { force: true });
|
|
121
|
+
return {
|
|
122
|
+
state: "gone",
|
|
123
|
+
message: projectGone(root, home)
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
if (await heldOnLocalhost(port)) {
|
|
102
127
|
const taken = await whatHolds(port, project, holderOf);
|
|
103
|
-
|
|
128
|
+
if (taken.sameProject) return { state: "running" };
|
|
129
|
+
const underWay = taken.by === "Dex" ? void 0 : await startUnderWay(pidPath);
|
|
130
|
+
if (underWay) return {
|
|
131
|
+
state: "started",
|
|
132
|
+
pid: underWay
|
|
133
|
+
};
|
|
134
|
+
const own = await ownDexPort(root, port, holderOf);
|
|
135
|
+
if (own === port) return { state: "running" };
|
|
136
|
+
await rm(pidPath, { force: true });
|
|
137
|
+
return {
|
|
104
138
|
state: "taken",
|
|
105
|
-
taken
|
|
139
|
+
taken,
|
|
140
|
+
...own === void 0 ? {} : { ownUrl: `http://localhost:${own}` }
|
|
106
141
|
};
|
|
107
142
|
}
|
|
108
143
|
return {
|
|
109
144
|
state: "started",
|
|
110
|
-
pid: await startDev(options)
|
|
145
|
+
pid: await startUnderWay(pidPath) ?? await startDev(options)
|
|
111
146
|
};
|
|
112
147
|
}
|
|
113
148
|
//#endregion
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ViteDevServer } from "vite";
|
|
1
2
|
//#region src/setup/desktop-app.d.ts
|
|
2
3
|
/**
|
|
3
4
|
* The launcher's answer when `dex app start` started `dex dev`; 0 is
|
|
@@ -72,6 +73,11 @@ export declare const urlScheme: (root: string) => string;
|
|
|
72
73
|
export declare function desktopApp(project: DesktopProject, running?: {
|
|
73
74
|
execPath: string;
|
|
74
75
|
}): DesktopApp;
|
|
76
|
+
/**
|
|
77
|
+
* The app a `dex dev` server makes: for the port and base it is served
|
|
78
|
+
* at, so the app opens that server, also when it moved off a taken port.
|
|
79
|
+
*/
|
|
80
|
+
export declare const servedApp: (root: string, server: ViteDevServer) => DesktopApp;
|
|
75
81
|
/** Where the app goes: `~/Applications/Dex.app`. */
|
|
76
82
|
export declare const bundlePath: (home: string) => string;
|
|
77
83
|
/**
|
|
@@ -109,6 +115,8 @@ export declare const projectGone: (root: string, home: string) => string;
|
|
|
109
115
|
* start`, whose output goes in the log after the mark and whose answer is
|
|
110
116
|
* the launcher's. All it does itself is what `dex` cannot: say the
|
|
111
117
|
* project is gone (and the `dex` installed in it with it), and find Node.
|
|
118
|
+
* It keeps the pid file of a start still coming up, which `dex app start`
|
|
119
|
+
* waits on, and clears it when it gives up.
|
|
112
120
|
* The Node (or Bun) the app was made with may be gone since (a version
|
|
113
121
|
* manager's, an upgrade): one on the PATH will do then, or the one the
|
|
114
122
|
* person's own shell finds, as nvm and fnm set theirs up there. With none
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { APP_DIR, PACKAGE_ROOT, installedBin, studioVersion } from "../paths.mjs";
|
|
2
2
|
import { projectId } from "../server/project-id.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { servedPort } from "../server/port.mjs";
|
|
4
|
+
import { GIVE_UP_AFTER_MS, STATE_SLOT, serverPage, shownPath } from "../shared/server-page.mjs";
|
|
4
5
|
import "../shared/product.mjs";
|
|
5
6
|
import { appScript } from "./desktop-app-script.mjs";
|
|
6
7
|
import { basename, dirname, join } from "node:path";
|
|
@@ -103,6 +104,15 @@ function desktopApp(project, running = process) {
|
|
|
103
104
|
version: studioVersion()
|
|
104
105
|
};
|
|
105
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* The app a `dex dev` server makes: for the port and base it is served
|
|
109
|
+
* at, so the app opens that server, also when it moved off a taken port.
|
|
110
|
+
*/
|
|
111
|
+
const servedApp = (root, server) => desktopApp({
|
|
112
|
+
root,
|
|
113
|
+
port: servedPort(server),
|
|
114
|
+
base: server.config.base
|
|
115
|
+
});
|
|
106
116
|
/** Where apps go: `~/Applications`, the person's own. */
|
|
107
117
|
const applications = (home) => join(home, "Applications");
|
|
108
118
|
/** Where the app goes: `~/Applications/Dex.app`. */
|
|
@@ -191,6 +201,7 @@ ${[
|
|
|
191
201
|
const shellWord = (text) => `'${text.replace(CONTROL_RE, "").replaceAll("'", `'\\''`)}'`;
|
|
192
202
|
/** Where the app keeps `dex dev`'s output, by the project's id. */
|
|
193
203
|
const logFile = (home, project) => join(home, "Library", "Logs", "Dex", `${project}.log`);
|
|
204
|
+
const MS_PER_MINUTE = 6e4;
|
|
194
205
|
/** Where the launcher looks for Node besides the PATH it is opened with. */
|
|
195
206
|
const RUNTIME_PLACES = "/opt/homebrew/bin:/usr/local/bin";
|
|
196
207
|
/** Where `dex app start` keeps the process id of the server it started. */
|
|
@@ -209,6 +220,8 @@ const portLine = (app) => `PORT=${shellWord(String(app.port))}`;
|
|
|
209
220
|
* start`, whose output goes in the log after the mark and whose answer is
|
|
210
221
|
* the launcher's. All it does itself is what `dex` cannot: say the
|
|
211
222
|
* project is gone (and the `dex` installed in it with it), and find Node.
|
|
223
|
+
* It keeps the pid file of a start still coming up, which `dex app start`
|
|
224
|
+
* waits on, and clears it when it gives up.
|
|
212
225
|
* The Node (or Bun) the app was made with may be gone since (a version
|
|
213
226
|
* manager's, an upgrade): one on the PATH will do then, or the one the
|
|
214
227
|
* person's own shell finds, as nvm and fnm set theirs up there. With none
|
|
@@ -225,8 +238,10 @@ PID_FILE=${shellWord(pidFile(home, app.project))}
|
|
|
225
238
|
|
|
226
239
|
/bin/mkdir -p "$(/usr/bin/dirname "$LOG")"
|
|
227
240
|
echo ${shellWord(LOG_MARK)} "$(/bin/date -u +%Y-%m-%dT%H:%M:%SZ)" >>"$LOG"
|
|
228
|
-
|
|
241
|
+
# A start older than the window waits for is over; its pid may be reused.
|
|
242
|
+
/usr/bin/find "$PID_FILE" -mmin +${Math.ceil(GIVE_UP_AFTER_MS / MS_PER_MINUTE)} -delete 2>/dev/null
|
|
229
243
|
if [ ! -d "$ROOT" ]; then
|
|
244
|
+
/bin/rm -f "$PID_FILE"
|
|
230
245
|
echo ${shellWord(projectGone(app.root, home))} >>"$LOG"
|
|
231
246
|
exit 1
|
|
232
247
|
fi
|
|
@@ -236,6 +251,7 @@ if [ ! -x "$RUNTIME" ]; then
|
|
|
236
251
|
RUNTIME=$(PATH="$PATH:${RUNTIME_PLACES}" command -v "$NAME") ||
|
|
237
252
|
RUNTIME=$("\${SHELL:-/bin/zsh}" -ilc "command -v $NAME" 2>/dev/null | /usr/bin/tail -n 1)
|
|
238
253
|
if [ ! -x "$RUNTIME" ]; then
|
|
254
|
+
/bin/rm -f "$PID_FILE"
|
|
239
255
|
echo "Dex needs $NAME to start, and $GONE is gone. Install $NAME, then open Dex again." >>"$LOG"
|
|
240
256
|
exit 1
|
|
241
257
|
fi
|
|
@@ -532,4 +548,4 @@ const openApp = async (path) => {
|
|
|
532
548
|
await run("/usr/bin/open", [path]);
|
|
533
549
|
};
|
|
534
550
|
//#endregion
|
|
535
|
-
export { APP_NAME, LOG_MARK, RUNTIME_PLACES, STARTED_EXIT, appSource, bundlePath, desktopApp, desktopAppState, desktopAppUnavailable, infoPlist, installDesktopApp, isConfined, isDexBundle, launcherScript, legacyBundlePath, logFile, macLaunchServices, openApp, pidFile, programStamp, projectGone, refreshDesktopApp, removeDesktopApp, revealInFinder, urlScheme };
|
|
551
|
+
export { APP_NAME, LOG_MARK, RUNTIME_PLACES, STARTED_EXIT, appSource, bundlePath, desktopApp, desktopAppState, desktopAppUnavailable, infoPlist, installDesktopApp, isConfined, isDexBundle, launcherScript, legacyBundlePath, logFile, macLaunchServices, openApp, pidFile, programStamp, projectGone, refreshDesktopApp, removeDesktopApp, revealInFinder, servedApp, urlScheme };
|
package/dist/setup/detect.d.mts
CHANGED
|
@@ -67,8 +67,6 @@ export declare function detectAgentsWithEvidence(root: string, env?: NodeJS.Proc
|
|
|
67
67
|
* (its launch) is on PATH.
|
|
68
68
|
*/
|
|
69
69
|
export declare function installedAgents(): AgentId[];
|
|
70
|
-
/** Which coding agents the project already uses. */
|
|
71
|
-
export declare const detectAgents: (root: string) => AgentId[];
|
|
72
70
|
/** A folder named with `--components`: as it is, whatever is in it. */
|
|
73
71
|
export declare function libraryAt(root: string, components: string): ComponentLibrary;
|
|
74
72
|
/**
|
package/dist/setup/detect.mjs
CHANGED
|
@@ -300,8 +300,6 @@ function installedAgents() {
|
|
|
300
300
|
return id !== "other" && cli !== void 0 && onPath(cli);
|
|
301
301
|
});
|
|
302
302
|
}
|
|
303
|
-
/** Which coding agents the project already uses. */
|
|
304
|
-
const detectAgents = (root) => detectAgentsWithEvidence(root).map(({ id }) => id);
|
|
305
303
|
const MIN_COMPONENTS = 3;
|
|
306
304
|
const COMMON_FOLDERS = [
|
|
307
305
|
"components/ui",
|
|
@@ -391,4 +389,4 @@ function findComponentLibrary(root, { components } = {}) {
|
|
|
391
389
|
return componentLibraries(root)[0];
|
|
392
390
|
}
|
|
393
391
|
//#endregion
|
|
394
|
-
export { builtGlobalCss, componentLibraries,
|
|
392
|
+
export { builtGlobalCss, componentLibraries, detectAgentsWithEvidence, detectDesignSystem, findComponentLibrary, findGlobalCss, globalCssFiles, installedAgents, isMixedFolder, libraryAt, runningAgent };
|
package/dist/setup/doctor.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { outputOf } from "../server/quiet-run.mjs";
|
|
|
5
5
|
import { checkForUpdate, updateCheckProblem } from "../server/updates.mjs";
|
|
6
6
|
import { canImport } from "../config/project-files.mjs";
|
|
7
7
|
import { dexRunner, packageManager, withRunner } from "../config/package-manager.mjs";
|
|
8
|
+
import { checkDesignSystem } from "./design-system-checks.mjs";
|
|
8
9
|
import { check, identify } from "../content/content.mjs";
|
|
9
10
|
import { AGENTS, agentRootOf, agentSetups, claudeHookCommands, studioCommand } from "../server/agents.mjs";
|
|
10
11
|
import { CREATE_COMMAND, connectInStudio } from "./project.mjs";
|
|
@@ -12,7 +13,6 @@ import { findConfigFile, loadProject } from "../config/load.mjs";
|
|
|
12
13
|
import { INSTALL_BROWSER, browserInstalled } from "../content/screenshot.mjs";
|
|
13
14
|
import { lacksNext } from "../server/next.mjs";
|
|
14
15
|
import { readGitSettings } from "../server/git-settings.mjs";
|
|
15
|
-
import { checkDesignSystem } from "./design-system-checks.mjs";
|
|
16
16
|
import { checkGitSetup, checkLog, realGitProbes } from "./git-checks.mjs";
|
|
17
17
|
import { planMigrations, warningsOf } from "./migrate/migrations.mjs";
|
|
18
18
|
import { createRequire } from "node:module";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { foldRowTitles } from "../../shared/canvas-core.mjs";
|
|
1
2
|
import { UPGRADE_COMMAND } from "./migration.mjs";
|
|
2
3
|
import { walkPrototypes } from "../../content/prototypes.mjs";
|
|
3
|
-
import { foldRowTitles } from "../../shared/canvas-core.mjs";
|
|
4
4
|
import { canvasParts } from "../../content/content.mjs";
|
|
5
5
|
import { relative, sep } from "node:path";
|
|
6
6
|
import { readFile, writeFile } from "node:fs/promises";
|
package/dist/setup/project.d.mts
CHANGED
|
@@ -124,7 +124,12 @@ export declare const USER_AGENT_RE: RegExp;
|
|
|
124
124
|
export declare function packageManagerFinding(root: string, { userAgent }?: {
|
|
125
125
|
userAgent?: string;
|
|
126
126
|
}): Promise<Finding<PackageManagerChoice>>;
|
|
127
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* Where the project already resolves the studio from, if it does. Its own
|
|
129
|
+
* node_modules' entry is kept as it is, so `isLinked` sees a `bun link`; one
|
|
130
|
+
* above is followed through its links, as Node resolves it, so a workspace's
|
|
131
|
+
* install is never taken for a link.
|
|
132
|
+
*/
|
|
128
133
|
export declare function resolvedStudio(root: string): string | undefined;
|
|
129
134
|
/** Whether the studio is a dependency already, linked in, or neither. */
|
|
130
135
|
export declare function studioPackage(root: string): StudioPackage;
|
package/dist/setup/project.mjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { PACKAGE_NAME, posix as posix$1 } from "../paths.mjs";
|
|
2
2
|
import { STUDIO_FILES } from "../shared/studio-files.mjs";
|
|
3
|
-
import { dependenciesOf, exportedComponents, filesImport, packageAt, packageFolder } from "../config/project-files.mjs";
|
|
3
|
+
import { dependenciesOf, exportedComponents, filesImport, installedPackageDir, packageAt, packageFolder } from "../config/project-files.mjs";
|
|
4
4
|
import { found } from "./findings.mjs";
|
|
5
5
|
import { findWorkspace, isInside } from "./detect/workspace.mjs";
|
|
6
6
|
import { designMdFinding } from "./design-md-setup.mjs";
|
|
7
7
|
import { builtGlobalCss, componentLibraries, detectAgentsWithEvidence, detectDesignSystem, globalCssFiles, isMixedFolder, libraryAt, runningAgent } from "./detect.mjs";
|
|
8
8
|
import { providerFinding } from "./provider.mjs";
|
|
9
|
-
import { createRequire } from "node:module";
|
|
10
9
|
import { existsSync, lstatSync, readFileSync, realpathSync } from "node:fs";
|
|
11
10
|
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
12
11
|
import { detect } from "package-manager-detector/detect";
|
|
@@ -168,16 +167,17 @@ async function packageManagerFinding(root, { userAgent = process.env.npm_config_
|
|
|
168
167
|
agent: "npm"
|
|
169
168
|
}, "no lockfile, so npm", "guess");
|
|
170
169
|
}
|
|
171
|
-
/**
|
|
170
|
+
/**
|
|
171
|
+
* Where the project already resolves the studio from, if it does. Its own
|
|
172
|
+
* node_modules' entry is kept as it is, so `isLinked` sees a `bun link`; one
|
|
173
|
+
* above is followed through its links, as Node resolves it, so a workspace's
|
|
174
|
+
* install is never taken for a link.
|
|
175
|
+
*/
|
|
172
176
|
function resolvedStudio(root) {
|
|
173
177
|
const local = join(root, "node_modules", PACKAGE_NAME);
|
|
174
178
|
if (existsSync(join(local, "package.json"))) return local;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return dirname(require.resolve(`${PACKAGE_NAME}/package.json`));
|
|
178
|
-
} catch {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
179
|
+
const above = installedPackageDir(dirname(resolve(root)), PACKAGE_NAME);
|
|
180
|
+
return above && realpathSync(above);
|
|
181
181
|
}
|
|
182
182
|
/**
|
|
183
183
|
* Whether `dir` is a link to a studio outside the project (`bun link`, `npm
|
|
@@ -60,6 +60,8 @@ export interface StarterValues {
|
|
|
60
60
|
pmVersion?: string;
|
|
61
61
|
title: string;
|
|
62
62
|
}
|
|
63
|
+
/** What a starter writes at the project's root: "package.json", "src". */
|
|
64
|
+
export declare function starterRootNames(starter: Starter): Promise<string[]>;
|
|
63
65
|
/**
|
|
64
66
|
* Copy `starter` into `root`, which is empty: its own files, then the files
|
|
65
67
|
* it shares with another, with the name, title and package manager filled in.
|
package/dist/setup/starters.mjs
CHANGED
|
@@ -123,6 +123,12 @@ async function packageManagerVersion(pm, exec, cwd) {
|
|
|
123
123
|
return version;
|
|
124
124
|
}
|
|
125
125
|
const RENAMED = { gitignore: ".gitignore" };
|
|
126
|
+
/** What a starter writes at the project's root: "package.json", "src". */
|
|
127
|
+
async function starterRootNames(starter) {
|
|
128
|
+
const own = await readdir(join(STARTERS_DIR, starter.name));
|
|
129
|
+
const shared = starter.shared.map(({ to }) => to.split("/")[0] ?? to);
|
|
130
|
+
return [.../* @__PURE__ */ new Set([...own.map((name) => RENAMED[name] ?? name), ...shared])];
|
|
131
|
+
}
|
|
126
132
|
/** Copy a file or a folder, filling in the values and making the changes. */
|
|
127
133
|
async function copyTree(from, to, fill) {
|
|
128
134
|
if (!(await stat(from)).isDirectory()) {
|
|
@@ -174,4 +180,4 @@ async function copyStarter(starter, root, values) {
|
|
|
174
180
|
else if (values.pm === "pnpm") await writePnpmWorkspace(root, void 0);
|
|
175
181
|
}
|
|
176
182
|
//#endregion
|
|
177
|
-
export { DEFAULT_STARTER, STARTERS, STARTERS_DIR, STARTER_NAMES, TEMPLATE_FLAG, copyStarter, packageManagerVersion, starterNamed, starterPackageManager };
|
|
183
|
+
export { DEFAULT_STARTER, STARTERS, STARTERS_DIR, STARTER_NAMES, TEMPLATE_FLAG, copyStarter, packageManagerVersion, starterNamed, starterPackageManager, starterRootNames };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isSlug } from "./prototypes-core.mjs";
|
|
2
1
|
import { isRecord, isText } from "./checks.mjs";
|
|
2
|
+
import { isSlug } from "./prototypes-core.mjs";
|
|
3
3
|
import { frameKey, isFrameUid, legacyFrameUid } from "./canvas-core.mjs";
|
|
4
4
|
import { rowOwner } from "./people-core.mjs";
|
|
5
5
|
//#region src/shared/annotations-core.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { viewHref } from "./prototypes-core.mjs";
|
|
2
1
|
import { isRecord, isText } from "./checks.mjs";
|
|
3
2
|
import { gridProblems } from "./frame-grids.mjs";
|
|
3
|
+
import { viewHref } from "./prototypes-core.mjs";
|
|
4
4
|
import { isSketch, sketchFrameProblems } from "./sketch-core.mjs";
|
|
5
5
|
//#region src/shared/canvas-core.ts
|
|
6
6
|
/** The page each viewport shows, in CSS pixels. */
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { CanvasPoint, SlideLayout, Viewport } from "./canvas-core.mjs";
|
|
2
|
+
import { Sketch } from "./sketch-core.mjs";
|
|
3
|
+
import { FrameGrid, FrameGuide } from "./frame-grids.mjs";
|
|
4
|
+
//#region src/shared/canvas-file.d.ts
|
|
5
|
+
interface FrameBase {
|
|
6
|
+
/**
|
|
7
|
+
* On a column's first frame: the id of a frame stacked further down a
|
|
8
|
+
* column to its left, in its row, for this column to start level with
|
|
9
|
+
* rather than at the row's top.
|
|
10
|
+
*/
|
|
11
|
+
beside?: string;
|
|
12
|
+
id: string;
|
|
13
|
+
/**
|
|
14
|
+
* The step this frame shows, counted from 1: its column on the canvas. Leave
|
|
15
|
+
* out to follow the previous frame in the row.
|
|
16
|
+
*/
|
|
17
|
+
step?: number;
|
|
18
|
+
title?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Which frame this is, for good: kept when it moves or is renamed, new on
|
|
21
|
+
* a copy. Picks follow it. Given to the saver's frames that have none when
|
|
22
|
+
* they save.
|
|
23
|
+
*/
|
|
24
|
+
uid?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Stacked directly below the frame before it in its row, in that frame's
|
|
27
|
+
* column, rather than in a column of its own.
|
|
28
|
+
*/
|
|
29
|
+
under?: true;
|
|
30
|
+
}
|
|
31
|
+
/** A live, interactive render of one of the prototype's views. */
|
|
32
|
+
export interface ViewFrame extends FrameBase {
|
|
33
|
+
doc?: undefined;
|
|
34
|
+
/** The frame's own grids, shown in place of the canvas's (Figma's, pasted). */
|
|
35
|
+
grids?: FrameGrid[];
|
|
36
|
+
/** Guide lines on the frame. */
|
|
37
|
+
guides?: FrameGuide[];
|
|
38
|
+
params?: Record<string, string>;
|
|
39
|
+
/** A fixed size in pixels, for a snapshot of one element; else the viewport's. */
|
|
40
|
+
size?: {
|
|
41
|
+
height: number;
|
|
42
|
+
width: number;
|
|
43
|
+
};
|
|
44
|
+
sketch?: undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Where a snapshot was captured from, and when; and the image it is, when
|
|
47
|
+
* it is one, in the prototype's folder: "images/….png".
|
|
48
|
+
*/
|
|
49
|
+
snapshot?: {
|
|
50
|
+
captured: string;
|
|
51
|
+
image?: string;
|
|
52
|
+
url: string;
|
|
53
|
+
};
|
|
54
|
+
spec?: undefined;
|
|
55
|
+
view: string;
|
|
56
|
+
viewport?: Viewport;
|
|
57
|
+
}
|
|
58
|
+
/** A markdown document from the prototype's docs folder. */
|
|
59
|
+
export interface DocFrame extends FrameBase {
|
|
60
|
+
doc: string;
|
|
61
|
+
/** A size of its own in pixels, set by resizing it; else 640 by 900. */
|
|
62
|
+
size?: {
|
|
63
|
+
height: number;
|
|
64
|
+
width: number;
|
|
65
|
+
};
|
|
66
|
+
sketch?: undefined;
|
|
67
|
+
spec?: undefined;
|
|
68
|
+
view?: undefined;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A spec, edited in place on the canvas: a markdown file in its placer's
|
|
72
|
+
* folder. In a section, it is that section's spec; outside any section, it is part
|
|
73
|
+
* of the file spec.
|
|
74
|
+
*/
|
|
75
|
+
export interface SpecFrame extends FrameBase {
|
|
76
|
+
doc?: undefined;
|
|
77
|
+
/**
|
|
78
|
+
* A slide's layout: its first frame beside its words (the default), or
|
|
79
|
+
* centred above them. Only a slide (people/<person>/slides/) has one.
|
|
80
|
+
*/
|
|
81
|
+
layout?: SlideLayout;
|
|
82
|
+
/**
|
|
83
|
+
* A width of its own in pixels, set by resizing it; else 520. With a
|
|
84
|
+
* height, it is never taller than that, and scrolls; without one, it is
|
|
85
|
+
* as tall as its words (never less than 240). A slide's is fixed, both
|
|
86
|
+
* ways: 1920 by 1080 until resized.
|
|
87
|
+
*/
|
|
88
|
+
size?: {
|
|
89
|
+
height?: number;
|
|
90
|
+
width: number;
|
|
91
|
+
};
|
|
92
|
+
sketch?: undefined;
|
|
93
|
+
/** Its file, from the file's folder: "people/ana/specs/checkout.md". */
|
|
94
|
+
spec: string;
|
|
95
|
+
view?: undefined;
|
|
96
|
+
}
|
|
97
|
+
export interface SketchFrame extends FrameBase {
|
|
98
|
+
doc?: undefined;
|
|
99
|
+
sketch: Sketch;
|
|
100
|
+
spec?: undefined;
|
|
101
|
+
/** Required, as an older Dex names a frame by its title or view. */
|
|
102
|
+
title: string;
|
|
103
|
+
view?: undefined;
|
|
104
|
+
}
|
|
105
|
+
declare const readFromDisk: unique symbol;
|
|
106
|
+
/**
|
|
107
|
+
* A frame this Dex cannot show: a kind from a newer Dex, or a mistake.
|
|
108
|
+
* Only reading a canvas makes one, so Dex never writes a frame that shows
|
|
109
|
+
* nothing.
|
|
110
|
+
*/
|
|
111
|
+
export interface UnknownFrame extends FrameBase {
|
|
112
|
+
doc?: undefined;
|
|
113
|
+
sketch?: undefined;
|
|
114
|
+
spec?: undefined;
|
|
115
|
+
view?: undefined;
|
|
116
|
+
readonly [readFromDisk]: true;
|
|
117
|
+
}
|
|
118
|
+
export type Frame = ViewFrame | DocFrame | SpecFrame | SketchFrame | UnknownFrame;
|
|
119
|
+
/**
|
|
120
|
+
* One pass through the section's steps: the main path, an error state, an
|
|
121
|
+
* alternative. Its frames are the steps, left to right.
|
|
122
|
+
*/
|
|
123
|
+
export interface Row {
|
|
124
|
+
/**
|
|
125
|
+
* In a person's copy of someone else's section: the id of their row this one
|
|
126
|
+
* is shown under (people-core.ts).
|
|
127
|
+
*/
|
|
128
|
+
after?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Whose it is, when not its section's: someone's version of a row in
|
|
131
|
+
* another person's section. Set when the canvas is read, never written.
|
|
132
|
+
*/
|
|
133
|
+
author?: string;
|
|
134
|
+
/** The id of the section in its author's file that keeps it. */
|
|
135
|
+
copy?: string;
|
|
136
|
+
frames: Frame[];
|
|
137
|
+
id: string;
|
|
138
|
+
title?: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* A section. Rows below the first are iterations of it. With `at`, a frame of
|
|
142
|
+
* its own instead: one frame, drawn at that point, with no section around it.
|
|
143
|
+
*/
|
|
144
|
+
export interface Section {
|
|
145
|
+
/** Where a frame of its own's top left corner is, in canvas pixels. */
|
|
146
|
+
at?: CanvasPoint;
|
|
147
|
+
/**
|
|
148
|
+
* Whose it is: the person whose people/<person>/canvas.json it is in. Set
|
|
149
|
+
* when the canvas is read, never written; only they change it.
|
|
150
|
+
*/
|
|
151
|
+
author?: string;
|
|
152
|
+
/** The id of the section it is a copy of, shown right below it. */
|
|
153
|
+
copyOf?: string;
|
|
154
|
+
/** When it was added, as an ISO date. */
|
|
155
|
+
created?: string;
|
|
156
|
+
description?: string;
|
|
157
|
+
/** Whose section it was copied from, when it is a copy. */
|
|
158
|
+
from?: string;
|
|
159
|
+
id: string;
|
|
160
|
+
/**
|
|
161
|
+
* Where the section's area starts, its top left corner in canvas pixels,
|
|
162
|
+
* once someone has drawn it or dragged it there. None stacks it with the
|
|
163
|
+
* others, top to bottom.
|
|
164
|
+
*/
|
|
165
|
+
position?: CanvasPoint;
|
|
166
|
+
rows: Row[];
|
|
167
|
+
/**
|
|
168
|
+
* The least size of a section's area, in canvas pixels, once someone has
|
|
169
|
+
* sized it or frames have left it: its frames still grow it, but it never
|
|
170
|
+
* shrinks below this.
|
|
171
|
+
*/
|
|
172
|
+
size?: {
|
|
173
|
+
height: number;
|
|
174
|
+
width: number;
|
|
175
|
+
};
|
|
176
|
+
title: string;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* canvas.json: sections stacked top to bottom, and frames of their own where
|
|
180
|
+
* they were drawn. In each section, steps run left to right and iterations
|
|
181
|
+
* (states, errors, alternatives) top to bottom.
|
|
182
|
+
*/
|
|
183
|
+
export interface Canvas {
|
|
184
|
+
/**
|
|
185
|
+
* Set in a person's file once their frames have uids: from then on, a
|
|
186
|
+
* frame of theirs with none is new.
|
|
187
|
+
*/
|
|
188
|
+
frameUids?: true;
|
|
189
|
+
/**
|
|
190
|
+
* Whose sections come first, as the canvas was read: each
|
|
191
|
+
* person by when they joined. Never saved.
|
|
192
|
+
*/
|
|
193
|
+
people?: readonly string[];
|
|
194
|
+
sections: Section[];
|
|
195
|
+
/**
|
|
196
|
+
* Whose canvas.json has given its frames uids, as the canvas was read: a
|
|
197
|
+
* frame of theirs with none is new. Never saved.
|
|
198
|
+
*/
|
|
199
|
+
uidsGiven?: readonly string[];
|
|
200
|
+
}
|
|
201
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Sketch } from "../sketch-core.mjs";
|
|
2
|
+
import { ThreadAudience, ThreadStatus, ThreadTarget, ThreadWithPrototype } from "../threads-core.mjs";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/shared/comments/routes.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A comment to start: what it is on, its first message (left out with a
|
|
7
|
+
* wireframe), who it is for, and a wireframe for an agent to build.
|
|
8
|
+
*/
|
|
9
|
+
export declare const NEW_COMMENT: z.ZodObject<{
|
|
10
|
+
target: z.ZodCustom<ThreadTarget, ThreadTarget>;
|
|
11
|
+
body: z.ZodOptional<z.ZodString>;
|
|
12
|
+
for: z.ZodOptional<z.ZodCustom<ThreadAudience, ThreadAudience>>;
|
|
13
|
+
sketch: z.ZodOptional<z.ZodCustom<Sketch, Sketch>>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
/**
|
|
16
|
+
* A person's change to a comment, by its id: a reply, a status, who it is
|
|
17
|
+
* for, a reaction, an edit or removal of their own message (`on`, by its
|
|
18
|
+
* `at`), or a review's comment hidden from the published site.
|
|
19
|
+
*/
|
|
20
|
+
export declare const COMMENT_CHANGE: z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
body: z.ZodOptional<z.ZodString>;
|
|
23
|
+
edit: z.ZodOptional<z.ZodString>;
|
|
24
|
+
for: z.ZodOptional<z.ZodCustom<ThreadAudience, ThreadAudience>>;
|
|
25
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
26
|
+
on: z.ZodOptional<z.ZodString>;
|
|
27
|
+
react: z.ZodOptional<z.ZodString>;
|
|
28
|
+
remove: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
status: z.ZodOptional<z.ZodCustom<ThreadStatus, ThreadStatus>>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
/**
|
|
32
|
+
* Each comment request, by name, and its answer to each method it takes.
|
|
33
|
+
* The query a request needs is in its comment.
|
|
34
|
+
*/
|
|
35
|
+
export interface CommentAnswers {
|
|
36
|
+
/** ?slug= for one prototype's, or none for every one's. */
|
|
37
|
+
threads: {
|
|
38
|
+
GET: ThreadWithPrototype[];
|
|
39
|
+
POST: ThreadWithPrototype;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** The bodies they take, by request and method, as the schemas above check them. */
|
|
43
|
+
export interface CommentBodies {
|
|
44
|
+
/** A comment to start, or a change to one, by its id. */
|
|
45
|
+
threads: {
|
|
46
|
+
POST: z.input<typeof NEW_COMMENT> | z.input<typeof COMMENT_CHANGE>;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** The comment requests and the methods each takes. */
|
|
50
|
+
export declare const COMMENT_ROUTES: {
|
|
51
|
+
readonly threads: readonly ["GET", "POST"];
|
|
52
|
+
};
|
|
53
|
+
//#endregion
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isRecord } from "../checks.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/shared/comments/routes.ts
|
|
4
|
+
/** An object, of a type whose fields the thread rules check. */
|
|
5
|
+
const record = (what) => z.custom(isRecord, `Expected ${what}`);
|
|
6
|
+
/** Text, of a type whose words the thread rules check. */
|
|
7
|
+
const word = () => z.custom((value) => typeof value === "string", "Expected text");
|
|
8
|
+
/**
|
|
9
|
+
* A comment to start: what it is on, its first message (left out with a
|
|
10
|
+
* wireframe), who it is for, and a wireframe for an agent to build.
|
|
11
|
+
*/
|
|
12
|
+
const NEW_COMMENT = z.object({
|
|
13
|
+
target: record("what the comment is on, with its kind"),
|
|
14
|
+
body: z.string().optional(),
|
|
15
|
+
for: word().optional(),
|
|
16
|
+
sketch: record("a wireframe").optional()
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* A person's change to a comment, by its id: a reply, a status, who it is
|
|
20
|
+
* for, a reaction, an edit or removal of their own message (`on`, by its
|
|
21
|
+
* `at`), or a review's comment hidden from the published site.
|
|
22
|
+
*/
|
|
23
|
+
const COMMENT_CHANGE = z.object({
|
|
24
|
+
id: z.string(),
|
|
25
|
+
body: z.string().optional(),
|
|
26
|
+
edit: z.string().optional(),
|
|
27
|
+
for: word().optional(),
|
|
28
|
+
hidden: z.boolean().optional(),
|
|
29
|
+
on: z.string().optional(),
|
|
30
|
+
react: z.string().optional(),
|
|
31
|
+
remove: z.boolean().optional(),
|
|
32
|
+
status: word().optional()
|
|
33
|
+
});
|
|
34
|
+
/** The comment requests and the methods each takes. */
|
|
35
|
+
const COMMENT_ROUTES = { threads: ["GET", "POST"] };
|
|
36
|
+
//#endregion
|
|
37
|
+
export { COMMENT_CHANGE, COMMENT_ROUTES, NEW_COMMENT };
|