easel-canvas 0.1.1 → 0.2.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/README.md +62 -18
- package/bin/mcp.mjs +143 -40
- package/bin/server.mjs +67 -5
- package/dist/assets/index-BZFSkKqU.css +1 -0
- package/dist/assets/index-BwyrrnkP.js +65 -0
- package/dist/index.html +3 -3
- package/dist/viewer/viewer.css +1 -0
- package/dist/viewer/viewer.js +49 -0
- package/package.json +2 -2
- package/server/activity.mjs +370 -0
- package/server/agents.mjs +20 -0
- package/server/args.mjs +22 -2
- package/server/board.mjs +4 -16
- package/server/boards.mjs +46 -21
- package/server/browser.mjs +68 -0
- package/server/chat.mjs +364 -54
- package/server/connect.mjs +94 -0
- package/server/copies.mjs +105 -0
- package/server/custom.mjs +101 -0
- package/server/export.mjs +627 -0
- package/server/forks.mjs +214 -0
- package/server/fsutil.mjs +8 -0
- package/server/history.mjs +152 -24
- package/server/html.mjs +11 -1
- package/server/index.mjs +153 -16
- package/server/occupancy.mjs +183 -0
- package/server/permissions.mjs +141 -0
- package/server/place.mjs +87 -0
- package/server/registry.mjs +110 -0
- package/server/routes.mjs +23 -54
- package/server/runs.mjs +167 -0
- package/server/snapshot.mjs +21 -9
- package/server/tokens.mjs +4 -1
- package/server/update.mjs +63 -0
- package/server/watch.mjs +12 -1
- package/dist/assets/index-DXUYTbPc.js +0 -55
- package/dist/assets/index-lfQlW-DC.css +0 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://www.npmjs.com/package/easel-canvas)
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
[](package.json)
|
|
10
|
-
[](#connect-your-ai-agent)
|
|
11
11
|
[](#connect-your-ai-agent)
|
|
12
12
|
|
|
13
13
|
<img src="docs/screenshots/demo.gif" alt="Demo: editing text in place on a mobile screen, then asking Claude Code in the AI tab to rename a heading and recolor a bar; the board redraws with the change" width="100%">
|
|
@@ -24,7 +24,7 @@ Easel turns a folder of plain HTML files into a design canvas. Claude Code or Co
|
|
|
24
24
|
npx easel-canvas --demo
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
That copies the "Tidy" habit tracker demo to `./easel-demo` and opens it at http://localhost:4317. Open the **AI** tab (⌘J) and ask Claude Code or Codex for a change, or
|
|
27
|
+
That copies the "Tidy" habit tracker demo to `./easel-demo` and opens it at http://localhost:4317. Open the **AI** tab (⌘J) and ask Claude Code or Codex for a change, or click anything on a screen and start editing.
|
|
28
28
|
|
|
29
29
|
Already have HTML screens? Run it in your project:
|
|
30
30
|
|
|
@@ -37,7 +37,7 @@ npx easel-canvas --dir ./designs # any folder of screens/*.html
|
|
|
37
37
|
## Why Easel
|
|
38
38
|
|
|
39
39
|
- **HTML is the source of truth.** Each `screens/*.html` file is one board. What you see is exactly what ships to the browser, and there's nothing to export or keep in sync.
|
|
40
|
-
- **Built for AI agents.** An MCP server with
|
|
40
|
+
- **Built for AI agents.** An MCP server with 22 tools lets agents see the boards, read what you selected, leave comments, check tokens and arrange the canvas. An in-app chat runs `claude -p`, `codex exec`, `cursor-agent -p`, `gemini -p` or your own command with your selection as context; Claude Code's permission requests come up as cards you answer in the chat.
|
|
41
41
|
- **Surgical edits.** Changes are patched into the exact source range (parse5 locations), so formatting, comments and the rest of the file stay untouched. If an agent edits the same element first, your edit is rejected instead of overwriting it.
|
|
42
42
|
- **Git-friendly by design.** Layout, notes and comments live in small JSON files written one entry per line, so two branches moving different boards merge without conflicts.
|
|
43
43
|
- **Local-first.** It runs on `127.0.0.1` and works directly on the files in your repo. No account, no cloud, no lock-in.
|
|
@@ -46,18 +46,18 @@ npx easel-canvas --dir ./designs # any folder of screens/*.html
|
|
|
46
46
|
|
|
47
47
|
<table>
|
|
48
48
|
<tr>
|
|
49
|
-
<td colspan="2"><img src="docs/screenshots/overview.png" alt="Easel showing a habit tracker app: five mobile screens on an infinite canvas with notes
|
|
49
|
+
<td colspan="2"><img src="docs/screenshots/overview.png" alt="Easel showing a habit tracker app: five mobile screens on an infinite canvas with notes and flow arrows, the board list card at the left and the inspector card at the right with token and accessibility checks"></td>
|
|
50
50
|
</tr>
|
|
51
51
|
<tr>
|
|
52
|
-
<td width="50%"><img src="docs/screenshots/
|
|
53
|
-
<td width="50%"><img src="docs/screenshots/ai-chat.png" alt="AI chat
|
|
52
|
+
<td width="50%"><img src="docs/screenshots/select.png" alt="A card selected inside a mobile screen, its element toolbar (Text, Fill, Radius, Spacing, Ask AI, Comment) in the line above the dock, and the inspector with the breadcrumb, Fill, Text, Corner radius, Padding and Gap"></td>
|
|
53
|
+
<td width="50%"><img src="docs/screenshots/ai-chat.png" alt="AI chat in the inspector card: a reply from Claude Code with Read and Edit tool lines, Undo this run and Compare, and the edited Today screen on the canvas"></td>
|
|
54
54
|
</tr>
|
|
55
55
|
<tr>
|
|
56
56
|
<td><b>Edit in place.</b> Select any element, drag it, resize it, align it, retype its text or change its styles. Layers, wrap in flex/grid, cross-board copy and paste.</td>
|
|
57
57
|
<td><b>Chat with your agent.</b> Pick Claude Code or Codex, send the selection, boards and comments as context, watch the edit stream in, ask for N variants side by side.</td>
|
|
58
58
|
</tr>
|
|
59
59
|
<tr>
|
|
60
|
-
<td width="50%"><img src="docs/screenshots/dark-mode.png" alt="Dark mode with a board context menu:
|
|
60
|
+
<td width="50%"><img src="docs/screenshots/dark-mode.png" alt="Dark mode with a board context menu: Select inside, Ask AI for a review, Focus view, Ask AI, Go to board, Rename, Rename file, Duplicate, Bring to front, Send to back, Delete"></td>
|
|
61
61
|
<td width="50%">
|
|
62
62
|
<b>Everything a canvas should do.</b>
|
|
63
63
|
<ul>
|
|
@@ -74,23 +74,40 @@ npx easel-canvas --dir ./designs # any folder of screens/*.html
|
|
|
74
74
|
|
|
75
75
|
## Connect your AI agent
|
|
76
76
|
|
|
77
|
-
Keep the canvas running (`npx easel-canvas`). Agents write HTML files directly; the MCP server lets them **see** (`list_boards`, `read_board`, `screenshot`, `list_errors`), **know what you mean** (`get_selection` with the selected element, visible boards and the current page), **talk** (comments and replies) and **arrange** (`place_board`, `create_board`, notes, pages, `check_tokens`, `save_snapshot`).
|
|
77
|
+
Keep the canvas running (`npx easel-canvas`). Agents write HTML files directly, and what they change shows up in the canvas's undo history (one step per in-app AI request, or per burst of edits from an outside agent); the MCP server lets them **see** (`list_boards`, `read_board`, `screenshot`, `list_errors`), **know what you mean** (`get_selection` with the selected element, visible boards and the current page), **talk** (comments and replies) and **arrange** (`place_board`, `create_board`, notes, pages, `check_tokens`, `save_snapshot`). When several agents share a canvas, `claim_board` (before editing a file with their own tools) or `write_board` (a whole board through Easel) keeps one writer per board: a second agent on a busy board is given a fork next to it and told which file it is on.
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
Then, in your project folder:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npx easel-canvas connect
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
It adds the Easel MCP server to your agents' configs and leaves everything else in those files as it was: `.mcp.json` (Claude Code), `.cursor/mcp.json` (Cursor) and `.gemini/settings.json` (Gemini CLI) in the project, and `[mcp_servers.easel]` in `~/.codex/config.toml` (Codex). Cursor, Gemini CLI and Codex are written only when they are found on your machine; pick agents with `--agents claude,cursor,gemini,codex`, or preview with `--dry-run`. Restart your agent afterwards.
|
|
86
|
+
|
|
87
|
+
There is no port to set: the MCP server finds the canvas running for the folder your agent works in (each canvas registers itself in `~/.easel/servers/`), and a busy port 4317 simply moves the canvas to the next free one. With several canvases open outside any of their projects, pass `--port <n>` to `easel-mcp` to pick one.
|
|
88
|
+
|
|
89
|
+
<details>
|
|
90
|
+
<summary>Manual setup</summary>
|
|
91
|
+
|
|
92
|
+
**Claude Code** (`.mcp.json` in the project root), **Cursor** (`.cursor/mcp.json`), **Gemini CLI** (`.gemini/settings.json`):
|
|
80
93
|
|
|
81
94
|
```json
|
|
82
|
-
{ "mcpServers": { "easel": { "
|
|
95
|
+
{ "mcpServers": { "easel": { "command": "npx", "args": ["-y", "-p", "easel-canvas", "easel-mcp"] } } }
|
|
83
96
|
```
|
|
84
97
|
|
|
85
|
-
**Codex
|
|
98
|
+
**Codex** (`~/.codex/config.toml`):
|
|
86
99
|
|
|
87
100
|
```toml
|
|
88
101
|
[mcp_servers.easel]
|
|
89
102
|
command = "npx"
|
|
90
|
-
args = ["-y", "-p", "easel-canvas", "easel-mcp"
|
|
103
|
+
args = ["-y", "-p", "easel-canvas", "easel-mcp"]
|
|
91
104
|
default_tools_approval_mode = "approve" # the tools only view, comment and arrange
|
|
92
105
|
```
|
|
93
106
|
|
|
107
|
+
Add `"--port", "4317"` to `args` to pin one canvas instead of finding it by folder.
|
|
108
|
+
|
|
109
|
+
</details>
|
|
110
|
+
|
|
94
111
|
Using Easel as a submodule (below)? Point `args` at `tools/easel/bin/mcp.mjs` with `"command": "node"` instead.
|
|
95
112
|
|
|
96
113
|
Then try:
|
|
@@ -101,6 +118,21 @@ Then try:
|
|
|
101
118
|
|
|
102
119
|
New files with `<meta name="board-size" content="390x844">` are placed on the canvas automatically at that size.
|
|
103
120
|
|
|
121
|
+
## Share a view-only copy
|
|
122
|
+
|
|
123
|
+
**Share** (at the top of the right card) writes a static, read-only copy of the whole canvas, the current page or the selected boards to `<project>/easel-export/`: boards with their pages, notes and comments, Play, and a stamp with the export time and `repo@commit`. Nothing in it calls back to Easel, so any static host works (Vercel, GitHub Pages, a PR preview, under any sub-path), and `index.html` also opens straight from disk (comment pins then stack in their board's corner, because browsers keep `file://` frames apart). **Copy deploy command** gives you `npx vercel deploy easel-export`. Turn on **One .html file** for a single self-contained file to attach to Slack, email or a PR; its size shows before you save. **PDF** (one board per page) and **PNG** (one 2× image per board) need Playwright's Chromium.
|
|
124
|
+
|
|
125
|
+
The same from the terminal, with no canvas running (it works in CI):
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
npx easel-canvas export # web folder in ./easel-export
|
|
129
|
+
npx easel-canvas export --single-file # one self-contained .html
|
|
130
|
+
npx easel-canvas export --page Onboarding --pdf --png
|
|
131
|
+
npx easel-canvas export --boards home.html,stats.html --out dist/design-preview
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Exporting again replaces what the previous export of the same kind wrote there (a small `.easel-export.json` lists it) and leaves anything else in the folder alone; a non-empty folder Easel did not create is never cleared. Dot folders (`.easel/`, `.thumbs/`…) and files outside the design folder are never copied. A single file inlines the screens' images, fonts, CSS and scripts but not HTML embedded with `<iframe>`; the export lists what it skipped.
|
|
135
|
+
|
|
104
136
|
## Pin it in your project
|
|
105
137
|
|
|
106
138
|
`npx easel-canvas` is all most projects need. To pin an exact version for your team, add it as a dev dependency (`npm i -D easel-canvas`, then `"design": "easel-canvas"` in your scripts) or as a git submodule. With your designs in `<project>/docs/design/screens/`:
|
|
@@ -127,6 +159,10 @@ npm run design # http://localhost:4317
|
|
|
127
159
|
- It installs separately from your app, so it never touches your app's dependencies, build or deploy, and CI that skips submodules (the `actions/checkout` default) is unaffected.
|
|
128
160
|
- To update: push to this repo, then run `git submodule update --remote tools/easel` in your project and commit the new pointer. Teammates run `npm run design:install` after `git pull`.
|
|
129
161
|
|
|
162
|
+
## Updates
|
|
163
|
+
|
|
164
|
+
`npx` keeps the copy it downloaded first, so run `npx easel-canvas@latest` to get a new version (and `npm i -D easel-canvas@latest` if you pinned it). To tell you when one is out, the canvas asks the npm registry once a day which version is the latest: one request to `registry.npmjs.org`, nothing about your project. When a newer one exists, the terminal says so at start and a toast at launch shows the update command for how you installed Easel; Copy command or × puts it away until the next version. Set `EASEL_NO_UPDATE_CHECK=1` to turn the check off; it is also off in CI and when Easel runs from a git checkout.
|
|
165
|
+
|
|
130
166
|
|
|
131
167
|
<details>
|
|
132
168
|
<summary><b>Keyboard shortcuts and how-tos</b></summary>
|
|
@@ -140,13 +176,20 @@ npm run design # http://localhost:4317
|
|
|
140
176
|
| Board options | Right "Properties": position, size, Radius, No frame, Interactive (Play), Stretch to window, Open as launch screen, Layout guides (Columns · Rows · Grid, up to 6, ⌃G), Adjustable values |
|
|
141
177
|
| View | Focus view (F, ←→), Play in place (P or ▶, Esc), Play full screen (right-click) |
|
|
142
178
|
| Notes and shapes | Title (T), sticky note (N, 8 colors, size, bold, italic), Rectangle (R), Oval (O), Line (L), Arrow (A), Pen (P when no board is selected), image (Assets or paste) |
|
|
143
|
-
|
|
|
144
|
-
| Direct editing |
|
|
145
|
-
| Undo | ⌘Z / ⌘⇧Z. Canvas actions, HTML edits and board create/delete share one history (100 entries) |
|
|
146
|
-
|
|
|
179
|
+
| Select elements | No mode to enter: click anything on a board (drag the board to move it). Shift-click or Shift-drag for several, Esc lets go (then of the board), ↑ parent, ↓ or Enter first child, ←→ siblings, Option+↑↓ to reorder, ⌘A for all siblings, ⌘G Wrap in flex, Tab into the element toolbar |
|
|
180
|
+
| Direct editing | The element toolbar, in the line above the dock: Text (size, weight), Fill (your tokens first, written as a CSS variable, then Custom), Radius, Spacing (padding, gap), Ask AI, Comment. Double-click text to edit it (Shift+Enter for a line break). Move with handles (Alt drops inside a box) and resize, 6 align options, Properties panel in design words with the breadcrumb (CSS names on hover, everything else under More (CSS), ⚠, contrast), Replace image, ⌘C/⌘V to paste into another board |
|
|
181
|
+
| Undo | ⌘Z / ⌘⇧Z. Canvas actions, HTML edits and board create/delete share one history (100 entries). The ▾ next to Undo lists it newest first (who, what, when; Now marks where you are): Go back to here undoes or redoes step by step to that entry, and Redo brings the rest back. The history lasts until Easel restarts |
|
|
182
|
+
| Who changed what | A board changed by someone else (an agent over MCP or the in-app chat, a file edited outside Easel, another browser) gets a tag above its title, e.g. "Codex · 2m · 1 change", with a person or agent mark and the name, and the changed element is outlined. Click the tag: the change ("Get started" → "Start free"), Before / After, and Undo (only that change; asks first if one of its boards changed since). Tags fade once you open them or select the board, and clear a day later |
|
|
183
|
+
| Design system | Register tokens (`tokens.json`) and themes in the left "Tokens" tab, Theme in the View menu (⋯ at the top of the right card), Token check and Accessibility lists on the right |
|
|
147
184
|
| Collaboration | Comments (Reply, Resolve, author), Snapshot menu (git-commits only the design folder) |
|
|
148
|
-
|
|
|
149
|
-
|
|
|
185
|
+
| Share | "Share" at the top of the right card: whole canvas, this page or the selected boards as a web folder or one .html file, PDF or PNG; Reveal, Copy deploy command, and the matching `npx easel-canvas export` line |
|
|
186
|
+
| Who is on which board | A board someone is editing says so above its title with a mark and the name: "Claude Code is editing…", "You · editing", then "Claude Code · done 13:52"; the board list shows a dot (blue for you, ink for anyone else). An agent holds a board from its first write until its in-app run ends, or 45 s after its last write over MCP (or when it disconnects). A second agent writing a board another agent holds works on a fork beside it ("Welcome · Codex"), with an arrow back that says when and why; you are never forked. When both are done, Use this one on either keeps that version under the original's name, title, position and comments, and sends the other to trash; one Undo brings both back |
|
|
187
|
+
| Pick a variant | Variants from the AI tab land in the first free row (never on notes or boards) and each gets Use this: Apply makes it the original board and sends the other variants to trash (toast with Undo), Keep all leaves them as ordinary boards |
|
|
188
|
+
| AI | Right "AI" tab (⌘J): Claude Code, Codex, Cursor Agent, Gemini CLI, or your own command; selection, boards, visible boards, comments and references go along as context; N variants; Ask AI for a review |
|
|
189
|
+
| AI permissions | When Claude Code wants to run a command or edit outside what it may, the chat shows the exact request: Allow once, Always allow (that tool, or a command's first two words, until Easel restarts; never for file edits, for commands with `;` `&&` `\|` `>` and the like, or for `sh -c`-style wrappers), or Deny |
|
|
190
|
+
| Undo an AI run | Each run that changed files ends with the boards it changed and added: Undo this run (one step, ⌘Z brings it back; asks first if you changed one of them since), Redo, Compare before and after. After a restart: Restore the copy from before this run (the newest 10 are kept) |
|
|
191
|
+
| Custom agent | Agent menu › Custom command…: a name and a command with `{prompt}`, e.g. `aider --message {prompt} --yes`. Saved in `~/.easel/agents.json` (not in the project), run without a shell, output shown as plain text |
|
|
192
|
+
| Screen | F6 to move between regions, Tab to move between boards, ⌘\\ to fold the left card, Appearance (System · Light · Dark) |
|
|
150
193
|
|
|
151
194
|
</details>
|
|
152
195
|
|
|
@@ -163,6 +206,7 @@ your-project/docs/design/
|
|
|
163
206
|
- A small Node server watches the folder (chokidar) and tells the browser which board changed, so only that board reloads, keeping scroll and selection.
|
|
164
207
|
- Element paths and hashes are computed from the source with parse5. Every edit is a minimal string patch into that range, written atomically.
|
|
165
208
|
- The canvas is a Vite + React app. Each board is an iframe of the real HTML, so scripts, links and CSS behave exactly as in a browser.
|
|
209
|
+
- The server listens on 127.0.0.1 only and refuses changes (and the live connection) from other web pages open in your browser: only requests with no `Origin` (the CLI, the MCP server) or from the canvas page itself, on a local host name, get through. Boards are your project's own HTML and run inside the canvas page, with the same access to it as you have, so open only design folders you trust.
|
|
166
210
|
|
|
167
211
|
## Development
|
|
168
212
|
|
package/bin/mcp.mjs
CHANGED
|
@@ -2,25 +2,57 @@
|
|
|
2
2
|
// AI-generated with Claude Code, 2026-10-09, reviewed by Hyun Park
|
|
3
3
|
// MCP server (stdio): exposes boards, selection, screenshots, comments and placement through the app server API (http://localhost:<port>). PLAN.md ch. 6.
|
|
4
4
|
// The agent creates and edits HTML by writing files directly. This server only observes, points at things, and places boards.
|
|
5
|
+
// With --permission it exposes a single tool instead: the permission prompt of an in-app chat run, answered in the Easel chat.
|
|
6
|
+
// No port needed: the canvas for the folder the agent runs in is found through the registry (server/registry.mjs) on each call.
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import fs from "node:fs/promises";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
|
|
5
11
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
12
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
13
|
import { z } from "zod";
|
|
8
14
|
|
|
9
|
-
import {
|
|
15
|
+
import { agentLabel } from "../server/agents.mjs";
|
|
16
|
+
import { parseArgs, TOOL_ROOT } from "../server/args.mjs";
|
|
17
|
+
import { discoverPort } from "../server/registry.mjs";
|
|
18
|
+
|
|
19
|
+
const args = parseArgs();
|
|
20
|
+
const pkg = JSON.parse(readFileSync(path.join(TOOL_ROOT, "package.json"), "utf8"));
|
|
21
|
+
// --port wins; an in-app chat run passes the canvas it was started from
|
|
22
|
+
const explicit = args.portGiven ? args.port : Number(process.env.DESIGN_CANVAS_PORT) || null;
|
|
23
|
+
const IMAGE_LIMIT = 4 * 1024 * 1024;
|
|
10
24
|
|
|
11
|
-
|
|
12
|
-
const
|
|
25
|
+
let port = null;
|
|
26
|
+
const resolvePort = async (fresh = false) => (port = !fresh && port ? port : await discoverPort({ port: explicit }));
|
|
27
|
+
|
|
28
|
+
/** This MCP server's id at the canvas: the boards it writes are released when its client disconnects */
|
|
29
|
+
const CLIENT = `mcp-${process.pid.toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
30
|
+
/** Header values for the app server: who made a change (undo history, comments), which in-app run it belongs to, and this client */
|
|
31
|
+
const agentHeaders = () => ({ "X-Easel-Agent": agent(), "X-Easel-Client": CLIENT, ...(process.env.EASEL_RUN_ID ? { "X-Easel-Run": process.env.EASEL_RUN_ID } : {}) });
|
|
32
|
+
const agent = () => agentLabel(server.server.getClientVersion()?.name);
|
|
13
33
|
|
|
14
34
|
async function call(method, path, body) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
res = await fetch(BASE + path, {
|
|
35
|
+
const send = async () =>
|
|
36
|
+
fetch(`http://127.0.0.1:${port}${path}`, {
|
|
18
37
|
method,
|
|
19
|
-
headers: body ? { "Content-Type": "application/json" } :
|
|
38
|
+
headers: { ...agentHeaders(), ...(body ? { "Content-Type": "application/json" } : {}) },
|
|
20
39
|
body: body ? JSON.stringify(body) : undefined,
|
|
21
40
|
});
|
|
22
|
-
|
|
23
|
-
|
|
41
|
+
let res;
|
|
42
|
+
try {
|
|
43
|
+
await resolvePort();
|
|
44
|
+
res = await send();
|
|
45
|
+
} catch (e) {
|
|
46
|
+
if (e.message?.startsWith("Several Easel canvases")) throw e;
|
|
47
|
+
// Nothing was sent: the canvas may have restarted on another port, or started after this server
|
|
48
|
+
try {
|
|
49
|
+
if (explicit) throw e;
|
|
50
|
+
await resolvePort(true);
|
|
51
|
+
res = await send();
|
|
52
|
+
} catch (e2) {
|
|
53
|
+
if (e2.message?.startsWith("Several Easel canvases")) throw e2;
|
|
54
|
+
throw new Error(`Easel is not running for this project (tried http://localhost:${port}). Start it in the project with \`npx easel-canvas\` (add --dir <design folder> when the screens are not in ./docs/design or the current folder), then try again.`);
|
|
55
|
+
}
|
|
24
56
|
}
|
|
25
57
|
const text = await res.text();
|
|
26
58
|
if (!res.ok) {
|
|
@@ -37,36 +69,83 @@ async function call(method, path, body) {
|
|
|
37
69
|
const callJson = async (m, p, b) => JSON.parse(await call(m, p, b));
|
|
38
70
|
const ok = (data) => ({ content: [{ type: "text", text: typeof data === "string" ? data : JSON.stringify(data, null, 2) }] });
|
|
39
71
|
|
|
40
|
-
|
|
72
|
+
// --permission: started by an in-app Claude Code run (inline --mcp-config) for its permission prompts only, under its own name
|
|
73
|
+
const server = new McpServer({ name: args.permission ? "easel-chat" : "easel", version: pkg.version });
|
|
74
|
+
/** The canvas tools; none of them in --permission mode (the project's own easel server already has them) */
|
|
75
|
+
const tool = args.permission ? () => {} : (...a) => server.registerTool(...a);
|
|
41
76
|
|
|
42
|
-
|
|
77
|
+
if (args.permission)
|
|
78
|
+
server.registerTool(
|
|
79
|
+
"permission",
|
|
80
|
+
{
|
|
81
|
+
description: "Asks the user in the Easel chat whether a tool call may run (Claude Code --permission-prompt-tool). Returns allow or deny.",
|
|
82
|
+
inputSchema: { tool_name: z.string(), input: z.record(z.string(), z.unknown()), tool_use_id: z.string().optional() },
|
|
83
|
+
},
|
|
84
|
+
async ({ tool_name, input, tool_use_id }) => {
|
|
85
|
+
let answer;
|
|
86
|
+
try {
|
|
87
|
+
let r = await callJson("POST", "/api/chat/permission", { tool_name, input, tool_use_id });
|
|
88
|
+
// The user may take a while: poll until the card is answered (or the run is cancelled, which denies it)
|
|
89
|
+
while (r.pending) r = await callJson("GET", `/api/chat/permission?id=${encodeURIComponent(r.id)}`);
|
|
90
|
+
answer = r.behavior === "allow" ? { behavior: "allow", updatedInput: r.updatedInput ?? input } : { behavior: "deny", message: String(r.message ?? "Denied") };
|
|
91
|
+
} catch (e) {
|
|
92
|
+
answer = { behavior: "deny", message: `Easel could not ask the user: ${e.message}` };
|
|
93
|
+
}
|
|
94
|
+
return { content: [{ type: "text", text: JSON.stringify(answer) }] };
|
|
95
|
+
},
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
tool(
|
|
43
99
|
"list_boards",
|
|
44
100
|
{
|
|
45
|
-
description:
|
|
101
|
+
description:
|
|
102
|
+
"List the boards on the design canvas (each board is an .html file in the screens folder, returned as dir) with file, title, size, position and page, who is editing it right now (editing), and origin for a variant or fork of another board. Use it to find which file to read or edit.",
|
|
46
103
|
inputSchema: { page: z.string().optional().describe("Only return boards on this page id") },
|
|
47
104
|
},
|
|
48
105
|
async ({ page }) => {
|
|
49
|
-
const { board, missing } = await callJson("GET", "/api/board");
|
|
106
|
+
const { board, missing, screens } = await callJson("GET", "/api/board");
|
|
107
|
+
const occ = (await callJson("GET", "/api/boards/occupancy").catch(() => null))?.boards ?? {};
|
|
50
108
|
const first = board.pages[0]?.id;
|
|
109
|
+
const editing = (f) => (occ[f] ?? []).filter((h) => h.state === "editing").map((h) => h.by ?? h.person ?? "someone");
|
|
51
110
|
const rows = board.order
|
|
52
111
|
.filter((f) => board.boards[f])
|
|
53
|
-
.map((f) => ({ file: f, ...board.boards[f], page: board.boards[f].page ?? first }))
|
|
112
|
+
.map((f) => ({ file: f, ...board.boards[f], page: board.boards[f].page ?? first, ...(editing(f).length ? { editing: editing(f) } : {}) }))
|
|
54
113
|
.filter((b) => !page || b.page === page);
|
|
55
|
-
return ok({ dir: "
|
|
114
|
+
return ok({ dir: screens ?? "screens", pages: board.pages, boards: rows, missingFiles: missing });
|
|
56
115
|
},
|
|
57
116
|
);
|
|
58
117
|
|
|
59
|
-
|
|
118
|
+
tool(
|
|
60
119
|
"read_board",
|
|
61
120
|
{ description: "Read a board's source HTML exactly as stored in the file. Use it before editing a board.", inputSchema: { file: z.string().describe("Board file name, e.g. scr-01.html") } },
|
|
62
121
|
async ({ file }) => ok(await call("GET", `/api/file?f=${encodeURIComponent(file)}`)),
|
|
63
122
|
);
|
|
64
123
|
|
|
65
|
-
|
|
124
|
+
tool(
|
|
125
|
+
"claim_board",
|
|
126
|
+
{
|
|
127
|
+
description:
|
|
128
|
+
"Call before you edit a board's file with your own file tools, so people and other agents see you are editing it. Returns the file to edit: the board itself, or, when another agent is editing that board right now, a fork next to it (a copy) so you do not overwrite each other. Edit the returned file. Reading never needs this.",
|
|
129
|
+
inputSchema: { file: z.string().describe("Board file name, e.g. scr-01.html") },
|
|
130
|
+
},
|
|
131
|
+
async ({ file }) => ok(await callJson("POST", "/api/boards/claim", { file })),
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
tool(
|
|
135
|
+
"write_board",
|
|
136
|
+
{
|
|
137
|
+
description:
|
|
138
|
+
"Write a board's whole HTML through Easel (instead of writing the file yourself). If another agent is editing that board right now, your version goes to a fork next to it, and the reply says which file you are on; keep writing to that file.",
|
|
139
|
+
inputSchema: { file: z.string().describe("Board file name, e.g. scr-01.html"), html: z.string().describe("The complete HTML of the board") },
|
|
140
|
+
},
|
|
141
|
+
async ({ file, html }) => ok(await callJson("POST", "/api/boards/write", { file, html })),
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
tool(
|
|
66
145
|
"get_selection",
|
|
67
146
|
{
|
|
68
147
|
description:
|
|
69
|
-
"What the user is looking at right now: selection (the element clicked
|
|
148
|
+
"What the user is looking at right now: selection (the element the user clicked on a board: file, path as element indexes from the children of <body>, tag, kind and label, text, source outerHTML up to 4KB, hash, computed styles), mode (canvas, edit = an element is selected, focus, play), page and pageName, visibleArtboards (boards visible on screen), selectedArtboards, dirty (pending saves), edits (recent edit history), erroredArtboards and firstError (boards with errors). Use it for requests like 'fix the selected element' or 'this screen'.",
|
|
70
149
|
inputSchema: {},
|
|
71
150
|
},
|
|
72
151
|
async () => {
|
|
@@ -74,16 +153,24 @@ server.registerTool(
|
|
|
74
153
|
},
|
|
75
154
|
);
|
|
76
155
|
|
|
77
|
-
|
|
156
|
+
tool(
|
|
78
157
|
"screenshot",
|
|
79
158
|
{
|
|
80
|
-
description:
|
|
159
|
+
description:
|
|
160
|
+
"Take a PNG screenshot of a board, or of an element inside it, and return the image (plus the path it was saved to, in the design folder's .easel/screenshots/). Use it to check how a change looks (requires playwright).",
|
|
81
161
|
inputSchema: { file: z.string(), path: z.string().optional().describe("Element path, e.g. 0/2/1; omit for the whole board") },
|
|
82
162
|
},
|
|
83
|
-
async ({ file, path }) =>
|
|
163
|
+
async ({ file, path: elPath }) => {
|
|
164
|
+
const r = await callJson("POST", "/api/screenshot", { file, path: elPath });
|
|
165
|
+
const png = await fs.readFile(r.path).catch(() => null);
|
|
166
|
+
const where = `Saved to ${r.relPath ?? r.path}`;
|
|
167
|
+
if (!png) return ok(where);
|
|
168
|
+
if (png.length > IMAGE_LIMIT) return ok(`${where} (${(png.length / 1048576).toFixed(1)} MB, too large to return inline; open the file or screenshot an element by path)`);
|
|
169
|
+
return { content: [{ type: "image", data: png.toString("base64"), mimeType: "image/png" }, { type: "text", text: where }] };
|
|
170
|
+
},
|
|
84
171
|
);
|
|
85
172
|
|
|
86
|
-
|
|
173
|
+
tool(
|
|
87
174
|
"list_comments",
|
|
88
175
|
{
|
|
89
176
|
description: "List board comments (docs/design/comments.json), optionally for one file or only unresolved ones.",
|
|
@@ -97,22 +184,22 @@ server.registerTool(
|
|
|
97
184
|
},
|
|
98
185
|
);
|
|
99
186
|
|
|
100
|
-
|
|
187
|
+
tool(
|
|
101
188
|
"add_comment",
|
|
102
189
|
{
|
|
103
190
|
description: "Add a comment to a board, or to an element inside it when path is given.",
|
|
104
191
|
inputSchema: { file: z.string(), path: z.string().optional(), text: z.string(), author: z.string().optional() },
|
|
105
192
|
},
|
|
106
|
-
async (args) => ok(await callJson("POST", "/api/comments", { ...args, author: args.author ??
|
|
193
|
+
async (args) => ok(await callJson("POST", "/api/comments", { ...args, author: args.author ?? agent() })),
|
|
107
194
|
);
|
|
108
195
|
|
|
109
|
-
|
|
196
|
+
tool(
|
|
110
197
|
"resolve_comment",
|
|
111
198
|
{ description: "Mark a comment as resolved (pass resolved=false to reopen it). Use it after fixing what a comment asked for.", inputSchema: { id: z.string(), resolved: z.boolean().optional() } },
|
|
112
199
|
async ({ id, resolved }) => ok(await callJson("POST", "/api/comments", { action: "resolve", id, resolved: resolved ?? true })),
|
|
113
200
|
);
|
|
114
201
|
|
|
115
|
-
|
|
202
|
+
tool(
|
|
116
203
|
"place_board",
|
|
117
204
|
{
|
|
118
205
|
description: "Record a board's canvas position, title and page in board.json. Use it after creating a new screen to set its name and position.",
|
|
@@ -127,7 +214,7 @@ server.registerTool(
|
|
|
127
214
|
async (args) => ok(await callJson("POST", "/api/place", args)),
|
|
128
215
|
);
|
|
129
216
|
|
|
130
|
-
|
|
217
|
+
tool(
|
|
131
218
|
"list_errors",
|
|
132
219
|
{ description: "List boards with errors (script errors, images that failed to load, missing files) and the first error. Use it to check your edits did not break a board.", inputSchema: {} },
|
|
133
220
|
async () => {
|
|
@@ -137,7 +224,7 @@ server.registerTool(
|
|
|
137
224
|
},
|
|
138
225
|
);
|
|
139
226
|
|
|
140
|
-
|
|
227
|
+
tool(
|
|
141
228
|
"create_board",
|
|
142
229
|
{
|
|
143
230
|
description: "Create a new board (HTML file) from a template and place it on the canvas. Templates: blank (Blank), mobile (390×844 Mobile screen), desktop (1440×900 Desktop screen), doc (Document). Edit the created file directly afterwards.",
|
|
@@ -155,7 +242,7 @@ server.registerTool(
|
|
|
155
242
|
async (args) => ok(await callJson("POST", "/api/boards/create", args)),
|
|
156
243
|
);
|
|
157
244
|
|
|
158
|
-
|
|
245
|
+
tool(
|
|
159
246
|
"list_notes",
|
|
160
247
|
{ description: "List canvas notes (titles and sticky notes), optionally for one page.", inputSchema: { page: z.string().optional() } },
|
|
161
248
|
async ({ page }) => {
|
|
@@ -165,7 +252,7 @@ server.registerTool(
|
|
|
165
252
|
},
|
|
166
253
|
);
|
|
167
254
|
|
|
168
|
-
|
|
255
|
+
tool(
|
|
169
256
|
"add_note",
|
|
170
257
|
{
|
|
171
258
|
description: "Add a note to the canvas. kind=title (large heading) or sticky (sticky note).",
|
|
@@ -174,7 +261,7 @@ server.registerTool(
|
|
|
174
261
|
async (args) => ok(await callJson("POST", "/api/notes", { action: "add", ...args })),
|
|
175
262
|
);
|
|
176
263
|
|
|
177
|
-
|
|
264
|
+
tool(
|
|
178
265
|
"update_note",
|
|
179
266
|
{
|
|
180
267
|
description: "Edit a note (text, position, width, page, color, size, bold, italic).",
|
|
@@ -194,19 +281,19 @@ server.registerTool(
|
|
|
194
281
|
async (args) => ok(await callJson("POST", "/api/notes", { action: "update", ...args })),
|
|
195
282
|
);
|
|
196
283
|
|
|
197
|
-
|
|
284
|
+
tool(
|
|
198
285
|
"delete_note",
|
|
199
286
|
{ description: "Delete a note (the user can undo it in the app).", inputSchema: { id: z.string() } },
|
|
200
287
|
async ({ id }) => ok(await callJson("POST", "/api/notes", { action: "delete", id })),
|
|
201
288
|
);
|
|
202
289
|
|
|
203
|
-
|
|
290
|
+
tool(
|
|
204
291
|
"list_pages",
|
|
205
292
|
{ description: "List canvas pages (the first page is the default).", inputSchema: {} },
|
|
206
293
|
async () => ok((await callJson("GET", "/api/board")).board.pages),
|
|
207
294
|
);
|
|
208
295
|
|
|
209
|
-
|
|
296
|
+
tool(
|
|
210
297
|
"manage_page",
|
|
211
298
|
{
|
|
212
299
|
description: "Manage pages: add (name), rename (id, name), delete (id; its items move to the first page), move (id, index).",
|
|
@@ -215,7 +302,7 @@ server.registerTool(
|
|
|
215
302
|
async (args) => ok(await callJson("POST", "/api/pages", args)),
|
|
216
303
|
);
|
|
217
304
|
|
|
218
|
-
|
|
305
|
+
tool(
|
|
219
306
|
"get_tokens",
|
|
220
307
|
{
|
|
221
308
|
description:
|
|
@@ -225,7 +312,7 @@ server.registerTool(
|
|
|
225
312
|
async () => ok(await callJson("GET", "/api/tokens?agent=1")),
|
|
226
313
|
);
|
|
227
314
|
|
|
228
|
-
|
|
315
|
+
tool(
|
|
229
316
|
"check_tokens",
|
|
230
317
|
{
|
|
231
318
|
description:
|
|
@@ -235,16 +322,32 @@ server.registerTool(
|
|
|
235
322
|
async ({ file }) => ok(await callJson("GET", `/api/lint${file ? `?f=${encodeURIComponent(file)}` : ""}`)),
|
|
236
323
|
);
|
|
237
324
|
|
|
238
|
-
|
|
325
|
+
tool(
|
|
239
326
|
"reply_comment",
|
|
240
327
|
{ description: "Reply to a comment (resolve=true replies and marks it resolved).", inputSchema: { id: z.string(), text: z.string(), resolve: z.boolean().optional(), author: z.string().optional() } },
|
|
241
|
-
async (args) => ok(await callJson("POST", "/api/comments", { action: "reply", ...args, author: args.author ??
|
|
328
|
+
async (args) => ok(await callJson("POST", "/api/comments", { action: "reply", ...args, author: args.author ?? agent() })),
|
|
242
329
|
);
|
|
243
330
|
|
|
244
|
-
|
|
331
|
+
tool(
|
|
245
332
|
"save_snapshot",
|
|
246
|
-
{
|
|
333
|
+
{
|
|
334
|
+
description: "Save a snapshot (a saved version): commits only the design folder to git, or outside a git repository copies it to .easel/snapshots/. Use only when the user explicitly asks to save.",
|
|
335
|
+
inputSchema: { message: z.string().optional() },
|
|
336
|
+
},
|
|
247
337
|
async ({ message }) => ok(await callJson("POST", "/api/snapshot", { message })),
|
|
248
338
|
);
|
|
249
339
|
|
|
250
340
|
await server.connect(new StdioServerTransport());
|
|
341
|
+
|
|
342
|
+
// The client went away (stdin closed, or we are told to stop): the boards this client was editing are released, then exit
|
|
343
|
+
let leaving = false;
|
|
344
|
+
const leave = async () => {
|
|
345
|
+
if (leaving) return;
|
|
346
|
+
leaving = true;
|
|
347
|
+
if (!args.permission && port)
|
|
348
|
+
await fetch(`http://127.0.0.1:${port}/api/boards/release`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ client: CLIENT }), signal: AbortSignal.timeout(1000) }).catch(() => {});
|
|
349
|
+
process.exit(0);
|
|
350
|
+
};
|
|
351
|
+
process.stdin.on("end", leave);
|
|
352
|
+
process.stdin.on("close", leave);
|
|
353
|
+
for (const sig of ["SIGTERM", "SIGINT", "SIGHUP"]) process.on(sig, leave);
|
package/bin/server.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// AI-generated with Claude Code, 2026-10-09, reviewed by Hyun Park
|
|
3
|
-
// Usage: easel-canvas [--dir <design folder>] [--port 4317] [--open] [--demo] [--init]
|
|
3
|
+
// Usage: easel-canvas [--dir <design folder>] [--port 4317] [--open] [--demo] [--init] | easel-canvas connect [--agents …] [--dry-run]
|
|
4
|
+
// | easel-canvas export [--out <dir>] [--page …] [--boards a.html,b.html] [--single-file] [--pdf] [--png]
|
|
4
5
|
import { spawn } from "node:child_process";
|
|
5
6
|
import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
6
7
|
import path from "node:path";
|
|
@@ -22,19 +23,70 @@ Usage
|
|
|
22
23
|
npx easel-canvas --demo copy the demo project to ./easel-demo and open it
|
|
23
24
|
npx easel-canvas --init create ./docs/design with a starter screen, then open it
|
|
24
25
|
npx easel-canvas --dir <folder> open a specific design folder
|
|
26
|
+
npx easel-canvas connect add the Easel MCP server to your agents' configs (run in the project)
|
|
27
|
+
npx easel-canvas export write a view-only copy of the canvas to ./easel-export (no canvas needed)
|
|
25
28
|
|
|
26
29
|
Options
|
|
27
|
-
--port <n> port to listen on (default 4317)
|
|
30
|
+
--port <n> port to listen on (default 4317; when it is busy and --port is not given, the next free one)
|
|
28
31
|
--open open the canvas in your browser (--demo and --init do this; --no-open to skip)
|
|
29
32
|
-h, --help show this help
|
|
30
33
|
-v, --version
|
|
31
34
|
|
|
35
|
+
connect
|
|
36
|
+
--agents <list> claude,cursor,gemini,codex (default: Claude Code, plus the others found on this machine)
|
|
37
|
+
--dry-run print what would be written, write nothing
|
|
38
|
+
Writes .mcp.json, .cursor/mcp.json, .gemini/settings.json in the project and [mcp_servers.easel] in ~/.codex/config.toml.
|
|
39
|
+
|
|
40
|
+
export
|
|
41
|
+
--out <dir> folder to write to (default <project>/easel-export; replaces the previous export there)
|
|
42
|
+
--page <name|id> only this page
|
|
43
|
+
--boards a,b only these boards (file names under screens/)
|
|
44
|
+
--single-file one self-contained .html instead of a web folder
|
|
45
|
+
--pdf, --png one PDF page / one 2x PNG per board (needs Playwright's Chromium)
|
|
46
|
+
The web folder is static: host it on Vercel, GitHub Pages or a PR preview, or open index.html.
|
|
47
|
+
|
|
32
48
|
A design folder holds screens/*.html (one board per file). Easel keeps board.json and
|
|
33
|
-
comments.json next to them. MCP
|
|
49
|
+
comments.json next to them. The MCP server (npx -y -p easel-canvas easel-mcp) finds the canvas
|
|
50
|
+
running for the folder your agent works in; pass --port <n> to it to pick one by hand.
|
|
34
51
|
Docs: ${pkg.homepage}`);
|
|
35
52
|
process.exit(0);
|
|
36
53
|
}
|
|
37
54
|
|
|
55
|
+
if (args.command === "connect") {
|
|
56
|
+
const { connect } = await import("../server/connect.mjs");
|
|
57
|
+
const { rootOf } = await import("../server/fsutil.mjs");
|
|
58
|
+
try {
|
|
59
|
+
const lines = await connect({ project: args.dirGiven ? rootOf(args.dir) : process.cwd(), agents: args.agents, dryRun: args.dryRun });
|
|
60
|
+
console.log(lines.join("\n"));
|
|
61
|
+
if (!args.dryRun) console.log("\nStart the canvas with npx easel-canvas, then restart your agent so it loads the MCP server.");
|
|
62
|
+
} catch (e) {
|
|
63
|
+
console.error(e.message);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
process.exit(0);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (args.command === "export") {
|
|
70
|
+
const { exportDesign } = await import("../server/export.mjs");
|
|
71
|
+
const { closeBrowser } = await import("../server/browser.mjs");
|
|
72
|
+
const formats = [...(args.singleFile ? ["single"] : []), ...(args.pdf ? ["pdf"] : []), ...(args.png ? ["png"] : [])];
|
|
73
|
+
let code = 0;
|
|
74
|
+
for (const f of formats.length ? formats : ["web"]) {
|
|
75
|
+
try {
|
|
76
|
+
const r = await exportDesign({ dir: args.dir, out: args.out ?? undefined, format: f === "single" ? "web" : f, singleFile: f === "single", page: args.page ?? undefined, boards: args.boards ?? undefined });
|
|
77
|
+
const kb = (n) => (n >= 1048576 ? `${(n / 1048576).toFixed(1)} MB` : `${Math.max(1, Math.round(n / 1024))} KB`);
|
|
78
|
+
console.log(`${{ web: "Web folder", single: "Single file", pdf: "PDF", png: "PNG" }[r.kind]}: ${r.main} (${r.files} file${r.files === 1 ? "" : "s"}, ${kb(r.bytes)})`);
|
|
79
|
+
for (const s of r.skipped) console.log(` skipped ${s.ref} in ${s.from}: ${s.reason}`);
|
|
80
|
+
if (r.deploy) console.log(` Host it: ${r.deploy} (or GitHub Pages / a PR preview: it is plain static files)`);
|
|
81
|
+
} catch (e) {
|
|
82
|
+
console.error(`Export failed: ${e.message}${e.status === 409 ? " Use --out <dir> to pick another folder." : ""}`);
|
|
83
|
+
code = 1;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
await closeBrowser();
|
|
87
|
+
process.exit(code);
|
|
88
|
+
}
|
|
89
|
+
|
|
38
90
|
let dir = args.dir;
|
|
39
91
|
let open = args.open;
|
|
40
92
|
if (args.demo) {
|
|
@@ -67,17 +119,27 @@ Try one of:
|
|
|
67
119
|
|
|
68
120
|
const { createServer } = await import("../server/index.mjs");
|
|
69
121
|
const { attach, closeBrowser, extraRoutes } = await import("../server/routes.mjs");
|
|
70
|
-
|
|
122
|
+
let app;
|
|
123
|
+
try {
|
|
124
|
+
app = await createServer({ dir, port: args.port, dev: !args.prod, extraRoutes, autoPort: !args.portGiven, register: true, updateCheck: true });
|
|
125
|
+
} catch (e) {
|
|
126
|
+
if (e.code !== "EADDRINUSE") throw e;
|
|
127
|
+
console.error(e.message);
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
71
130
|
await attach(app);
|
|
72
|
-
console.log(`Easel: ${app.url} (design folder ${dir})`);
|
|
131
|
+
console.log(`Easel: ${app.url} (design folder ${dir})${app.port !== args.port ? ` port ${args.port} was busy` : ""}`);
|
|
132
|
+
app.update.then((u) => u && console.log(`Easel ${u.latest} is out (you have ${u.current}). Update: ${u.command}, then restart.`));
|
|
73
133
|
|
|
74
134
|
if (open && !args.noOpen) {
|
|
75
135
|
const [cmd, cmdArgs] = process.platform === "darwin" ? ["open", [app.url]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", app.url]] : ["xdg-open", [app.url]];
|
|
76
136
|
spawn(cmd, cmdArgs, { stdio: "ignore", detached: true, windowsHide: true }).on("error", () => {}).unref();
|
|
77
137
|
}
|
|
78
138
|
|
|
139
|
+
process.on("exit", () => app.unregister());
|
|
79
140
|
for (const sig of ["SIGTERM", "SIGINT", "SIGHUP"])
|
|
80
141
|
process.on(sig, async () => {
|
|
142
|
+
app.unregister();
|
|
81
143
|
await closeBrowser();
|
|
82
144
|
process.exit(0);
|
|
83
145
|
});
|