figdriver 0.0.0-stage → 0.4.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 +86 -0
- package/LICENSE +21 -0
- package/README.md +87 -2
- package/cli/result.ts +231 -0
- package/dist/cli.js +4125 -0
- package/index.d.ts +12 -0
- package/index.js +8 -0
- package/package.json +78 -4
- package/src/core/color.ts +435 -0
- package/src/core/css.ts +668 -0
- package/src/core/foundations.ts +389 -0
- package/src/core/json.d.ts +4 -0
- package/src/core/layout.ts +684 -0
- package/src/core/naming.ts +129 -0
- package/src/core/protocol.ts +328 -0
- package/src/core/rerun.ts +130 -0
- package/src/core/reuse.ts +149 -0
- package/src/core/snapshot.ts +88 -0
- package/src/core/spec.ts +167 -0
- package/src/core/text.ts +37 -0
- package/src/core/tokens.ts +77 -0
- package/src/core/types.ts +181 -0
- package/src/core/users.ts +17 -0
- package/src/figma/helpers.ts +238 -0
- package/src/figma/import.ts +962 -0
- package/src/figma/inspect.ts +254 -0
- package/src/figma/kit.ts +562 -0
- package/src/figma/migrate.ts +301 -0
- package/src/figma/owned.ts +56 -0
- package/src/figma/read.ts +618 -0
- package/src/figma/rerun.ts +387 -0
- package/src/figma/review.ts +481 -0
- package/src/figma/tokens.ts +97 -0
- package/src/page/capture.ts +999 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
- Renamed the package, CLI, and agent skill from `figwright` to `figdriver` (`FIGDRIVER_FILE`, `FIGDRIVER_BROWSER`, `~/.cache/figdriver-profile`, `fd` eval helpers, `figdriver` shared plugin data namespace, `com.figdriver` DTCG token extensions, and `skills/figdriver/`).
|
|
6
|
+
|
|
7
|
+
## 0.4.0
|
|
8
|
+
|
|
9
|
+
- `<video>` and animated `<canvas>` elements, WebGL included, import as Figma video fills. A `<video>` keeps its original file when fetchable, else records while playing. A moving canvas records a 5-second WebM clip with reduced motion lifted, and canvases that only draw when motion is on now keep both their still frame and clip. `import capture` writes clips to `assets/video/`, reports them in `videos`, and exports `videos` and `VideoName` from `assets.gen.ts`. Figma adds video only to files in a paid team, so elsewhere the element keeps its still frame and `import run` warns. A still canvas or a paused stream whose file cannot be fetched imports as that still.
|
|
10
|
+
- Every CSS Color 4 color imports across fills, strokes, text, shadows, variables, and SVGs: `lab()`, `lch()`, `hwb()`, `oklab()`, `oklch()`, and `color()` in any predefined space, including `display-p3` and `rec2020`. Out-of-gamut colors clip to sRGB as Chromium draws them.
|
|
11
|
+
- Gradients blend the way the browser draws them. They honor `in <space>`, hue methods, `none` components, and layer `background-size` and `background-position`, default to oklab when a stop uses a modern color, blend alpha premultiplied, and follow color hints. Figwright adds as many Figma stops as it takes to stay within one 8-bit step, keeps hard-stop positions strictly increasing for Figma's renderer, and imports `repeating-*` gradients instead of dropping them.
|
|
12
|
+
- `import capture` hoists visible children out of `display: contents` wrappers instead of dropping them, and waits up to 30 seconds for headless Chromium cold startup.
|
|
13
|
+
|
|
14
|
+
## 0.3.0
|
|
15
|
+
|
|
16
|
+
### Grouped CLI and per-command help
|
|
17
|
+
|
|
18
|
+
- Grouped the CLI into 10 top-level commands, each with its own `--help`. Root `--help` shrank from 1,280 to about 206 words, and `eval --help` lists every `fw` helper signature.
|
|
19
|
+
- `browser open|tabs|close|stop|screenshot` replaces `browser`, `open`, `tabs`, `close`, and tab screenshots from `shot`.
|
|
20
|
+
- `export` replaces `shot`. It takes `export <out-file> <node-id>` or `export <out-dir> --node|--selection|--page|--screens`.
|
|
21
|
+
- `import capture|outline|run|audit|parity|plugin` replaces top-level `capture`, `outline`, `run`, and `build`. Top-level `parity <node-id> <reference.png>` and `audit [--page]` now have one grammar each.
|
|
22
|
+
- `tree` is hidden from `--help` and stays callable for `scripts/pin.ts`.
|
|
23
|
+
- Removed `inspect --css` in favor of `tokens export`. Bare `inspect` rejects `--depth`. Terminal `inspect` dumps over 16 KB print a summary that points to `find`.
|
|
24
|
+
|
|
25
|
+
### Inspect, search, and tokens
|
|
26
|
+
|
|
27
|
+
- Added `find`, which searches layers by `--name`, `--type`, `--text`, or `--component` across the current page, `--page`, `--all-pages`, or `--under <node-id>`. It prints compact paths and instance property keys.
|
|
28
|
+
- Added `inspect --include prototype,handoff,variables,text-runs,grids,vectors|all` and `--expand-instances`. They report prototype reactions and flows, Dev Mode data, variable modes, text runs, layout grids, constraints, vector paths, FigJam nodes, and Slides grids. Read commands no longer scan every page for owned roots.
|
|
29
|
+
- Added `tokens export` for CSS custom properties, Tailwind v4 `@theme`, and W3C DTCG JSON, with `--collection` and `--strict`. Added `tokens import` for CSS and DTCG, with `--dry-run`, mode creation, and alias binding.
|
|
30
|
+
- Accepted `/buzz/` and `/site/` file URLs. `doctor` reports `pageCount` and editor `capabilities`. `export --page` follows Slides grid order and FigJam sections.
|
|
31
|
+
|
|
32
|
+
### Eval, export, parity, audit, and browser
|
|
33
|
+
|
|
34
|
+
- Added global `fw` helpers to `eval`: `find`, `mainOf`, `replaceText`, `setProps`, `setSlot`, `placeInstance`, `bindColor`, and `page`. Bundled `.ts` errors map back to `.ts` files and lines.
|
|
35
|
+
- Added `export --format png|svg|pdf|jpg`, `--bounds render|layout`, and `--screens`.
|
|
36
|
+
- `import parity` exports sections at layout bounds, composites transparent areas over ancestor backdrops, warns on size mismatches, and fails past `--max-mismatch <pct>`. Top-level `parity` diffs any node against any PNG.
|
|
37
|
+
- Added top-level `audit [--page <name|id>] [--ruleset authored|run]`. `import audit <dir>` checks draft builds the way `import parity` does. Audits flag negative spacing, overlapping auto-layout siblings, and broken prototype links.
|
|
38
|
+
- Added multi-viewport `import capture --viewport`, `import capture --embed <node-id>`, and `browser open --new-window`.
|
|
39
|
+
|
|
40
|
+
### Web-to-Figma import engine
|
|
41
|
+
|
|
42
|
+
- Multi-color, gradient, text, and large SVGs import as full-color vector frames in place of monochrome icons. `import outline` prints an `icons` footer.
|
|
43
|
+
- Added radial and conic gradients, multi-layer, inset, and spread `box-shadow` effect styles, `filter: blur()`, `mix-blend-mode`, per-run font families, strikethrough, hyperlinks, and color modes from `[data-theme]`, `.dark`, and `prefers-color-scheme: dark`.
|
|
44
|
+
- Fixed negative gap inference in wrapped flex rows, `z-index` on grid wrapper frames, manual grid layer order, `outline` heading and paragraph folding, starter specs that shared `cls[0]`, and spurious `"background none"` warnings.
|
|
45
|
+
- Added `booleans`, `renames`, `annotations`, and `slides` to `ImportSpec`. Component fallbacks name the exact child difference, and refused reruns list the edited layers.
|
|
46
|
+
|
|
47
|
+
## 0.2.0
|
|
48
|
+
|
|
49
|
+
- Scoped plain JavaScript `eval` (`file.js`, stdin `-`, and `-e`) in an isolated async function parsed with `acorn`, so top-level declarations never leak across runs while top-level `await`, `return`, bare object literals, and trailing expressions work natively.
|
|
50
|
+
- Added `--wait` queueing across `run`, `eval`, `doctor`, `inspect`, `audit`, `export`, `parity`, `shot`, and `tree`, with bounded retry timeouts and idempotent write-lock recovery.
|
|
51
|
+
- Added `inspect --page <name|id>` (reporting the resolved target page in `--json`) and separated `me` from other active sessions (`users`) in `doctor`.
|
|
52
|
+
- Added CSS Grid cell-collision fallback to absolute positioning (with flex/grid `z-index` paint ordering), bound `Landing Page` backgrounds from `body` or white tokens on short pages, improved capture linting for grid clashes, painted inline text, and pseudo-element text, and fixed background-layer, CSS angle/shadow, SVG `viewBox`/dashed-stroke, and circular variable alias edge cases.
|
|
53
|
+
- Made `cli/result.ts` and `src/core/protocol.ts` pure types-only with `NodeNext`-compatible declaration imports, memoized the `inspect` bundle per session, added `NodeNext` smoke checks and release gates, and streamlined docs and skills.
|
|
54
|
+
|
|
55
|
+
## 0.1.1
|
|
56
|
+
|
|
57
|
+
### CLI and browser ergonomics
|
|
58
|
+
|
|
59
|
+
- Made `browser <url>` open or focus the requested URL when Chromium is already running instead of only listing tabs, and added `--json` output typed by `BrowserResult`.
|
|
60
|
+
- Normalized Figma layer URLs (`?node-id=1-23`) and dashed node IDs (`1-23`, `I1-23;4-56`) at the CLI boundary for `inspect --node` and `shot`.
|
|
61
|
+
- Added `screens` node-to-PNG mappings to `shot --json` (`ShotResult`) and added `shot <out-dir> --selection` to export the current Figma selection in one connection.
|
|
62
|
+
- Fixed `export --page` to reject ambiguous duplicate page names with the same ID-listing error as `run`/`eval`, report the resolved page in `ExportResult`, and rejected combining `--node` and `--selection` in `inspect`.
|
|
63
|
+
- Streamed `console.log`, `console.warn`, and `console.error` from `eval` and `run` to stderr (`[figma] ...`) without replaying prior console history, added `eval -` to read code from stdin, added `--timeout` to `eval` and `run` (extending the write lock lease accordingly), rejected combining `-e` with a script path, and clarified `--read-only` behavior in help text.
|
|
64
|
+
|
|
65
|
+
## 0.1.0
|
|
66
|
+
|
|
67
|
+
First release of figwright.
|
|
68
|
+
|
|
69
|
+
### CLI and browser automation
|
|
70
|
+
|
|
71
|
+
- Added `browser`, `tabs`, `open`, `close`, and `doctor` to manage an isolated Chromium profile at `~/.cache/figwright-profile`, detect system and Playwright Chromium builds, deduplicate tabs, and verify file edit access.
|
|
72
|
+
- Added `inspect` to read pages, variables, styles, components, and layer trees as JSON, and `--css` to export color and number variables as CSS custom properties.
|
|
73
|
+
- Added `eval` to run Plugin API code in the open file, with `--bundle` for multi-file TypeScript and JavaScript imports and `--read-only` for non-mutating queries.
|
|
74
|
+
- Added `shot`, `export`, `audit`, and `tree` to export nodes or pages as PNGs, audit builds, and print stable JSON trees.
|
|
75
|
+
- Enforced `--file` or `FIGWRIGHT_FILE` on write commands, a per-tab write lock, `chrome://version` profile verification, early view-only detection, and duplicate-tab rejection on writes.
|
|
76
|
+
|
|
77
|
+
### Web-to-Figma import
|
|
78
|
+
|
|
79
|
+
- Added `capture` to render a URL, local HTML file, or Figma Make embed into `snapshot.json`, images, `ref/page.png`, and a starter `index.ts`. Runs headless when `figwright browser` is not open.
|
|
80
|
+
- Added `outline`, `run`, `parity`, and `build` to inspect captured trees, build Figma components and tokens, compare rebuilt sections against `ref/page.png`, and bundle offline scripts or development plugins.
|
|
81
|
+
- Added safe reruns that replace prior output only when the build is clean, the existing output is unedited, and every external reference migrates unambiguously. Failed replacements roll back automatically before removing old output.
|
|
82
|
+
|
|
83
|
+
### Packaging and agent skill
|
|
84
|
+
|
|
85
|
+
- Shipped the agent skill in `skills/figwright/` for installation with `npx skills add MahmoudOmiesh/figwright`.
|
|
86
|
+
- Shipped TypeScript types in `index.d.ts` and JSON result types under `figwright/result` (`cli/result.ts`), targeting Node.js 22.1 or later across npm, pnpm, Yarn Plug'n'Play, and Bun.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mahmoud Omiesh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,88 @@
|
|
|
1
|
-
#
|
|
1
|
+
# figdriver
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/figdriver)
|
|
4
|
+
[](https://github.com/MahmoudOmiesh/figdriver/actions/workflows/check.yml)
|
|
5
|
+
[](https://nodejs.org)
|
|
6
|
+
[](https://github.com/MahmoudOmiesh/figdriver/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
Playwright for Figma. figdriver drives Figma, FigJam, and Slides files from the terminal or a coding agent.
|
|
9
|
+
|
|
10
|
+
It runs Figma's Plugin API in a logged-in Chromium tab over the Chrome DevTools Protocol. You get read and write access to any file you can edit. It needs no API token, paid plan, MCP server, or published plugin.
|
|
11
|
+
|
|
12
|
+
## Use with a coding agent
|
|
13
|
+
|
|
14
|
+
Install the agent skill with [skills.sh](https://skills.sh):
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npx skills add MahmoudOmiesh/figdriver
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Without the skill, give your agent this prompt:
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
Use `npx figdriver` on my Figma file <file URL>. Run `npx figdriver --help` and `npx figdriver <command> --help` for flags.
|
|
24
|
+
Start with `npx figdriver browser open "<file URL>"`, set FIGDRIVER_FILE="<file URL>", and run `npx figdriver doctor --json`.
|
|
25
|
+
Locate layers with `find`, edit with `eval` and its `fd` helpers, then `export` every changed node and look at the PNGs.
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Requirements
|
|
29
|
+
|
|
30
|
+
- Node.js 22.1+
|
|
31
|
+
- A Chromium-based browser
|
|
32
|
+
- Edit access to the Figma file
|
|
33
|
+
|
|
34
|
+
## Quick start
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npx figdriver browser open "<file URL>" # log in once in the window that opens
|
|
38
|
+
export FIGDRIVER_FILE="<file URL>"
|
|
39
|
+
npx figdriver doctor
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npx figdriver find --type INSTANCE --component Button --all-pages
|
|
44
|
+
npx figdriver inspect --node 1:23 --include prototype,handoff
|
|
45
|
+
npx figdriver tokens export tokens.css --collection Brand
|
|
46
|
+
npx figdriver eval -e 'await fd.replaceText("1:23", "Ship calmer", { replace: "Ship" })'
|
|
47
|
+
npx figdriver export out/frame.png 1:23
|
|
48
|
+
npx figdriver parity 1:23 ref.png --max-mismatch 2
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Commands that accept `--json` print one JSON object on stdout, typed in [cli/result.ts](https://github.com/MahmoudOmiesh/figdriver/blob/main/cli/result.ts). Exit 0 means `"ok": true`. Install with `npm install -D figdriver` for TypeScript spec types.
|
|
52
|
+
|
|
53
|
+
## Commands
|
|
54
|
+
|
|
55
|
+
| Group | Command | Does |
|
|
56
|
+
| ------------ | --------- | ----------------------------------------------------------------------- |
|
|
57
|
+
| Connect | `browser` | `open`, `tabs`, `close`, `stop`, `screenshot` for the debugging browser |
|
|
58
|
+
| | `doctor` | Checks browser, file access, capabilities, active users, write lock |
|
|
59
|
+
| Read, tokens | `find` | Searches layers by name, type, text, or component |
|
|
60
|
+
| | `inspect` | Prints the file inventory or a node's layer tree |
|
|
61
|
+
| | `tokens` | `export`, `import` variables as CSS, Tailwind `@theme`, or DTCG JSON |
|
|
62
|
+
| Edit, verify | `eval` | Runs Plugin API JS or TS with global `fd` helpers |
|
|
63
|
+
| | `export` | Writes nodes, a selection, a page, or built screens as PNG/SVG/PDF/JPG |
|
|
64
|
+
| | `parity` | Diffs a node against a reference PNG |
|
|
65
|
+
| | `audit` | Checks a page for text styles, bound colors, and layout issues |
|
|
66
|
+
| Web to Figma | `import` | `capture`, `outline`, `run`, `audit`, `parity`, `plugin` |
|
|
67
|
+
|
|
68
|
+
Run `npx figdriver <command> --help` for flags and examples.
|
|
69
|
+
|
|
70
|
+
## Rebuild a web page in Figma
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npx figdriver import capture ./landing https://example.com
|
|
74
|
+
npx figdriver import outline ./landing
|
|
75
|
+
# define sections, components, variants, and icons in ./landing/index.ts
|
|
76
|
+
npx figdriver import run ./landing
|
|
77
|
+
npx figdriver import parity ./landing
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The rebuild keeps shadows, gradients in any CSS color space, videos and animated canvases (as video in paid-team files), blurs, blend modes, mixed fonts, links, multi-color SVGs, and theme modes. A rerun replaces earlier output only when the build is clean and nobody edited that output. Otherwise the new build stays on a draft page.
|
|
81
|
+
|
|
82
|
+
## Contributing
|
|
83
|
+
|
|
84
|
+
Pull requests must pass `bun run check`. See [CONTRIBUTING.md](https://github.com/MahmoudOmiesh/figdriver/blob/main/CONTRIBUTING.md), [AGENTS.md](https://github.com/MahmoudOmiesh/figdriver/blob/main/AGENTS.md), [CHANGELOG.md](https://github.com/MahmoudOmiesh/figdriver/blob/main/CHANGELOG.md), and [SECURITY.md](https://github.com/MahmoudOmiesh/figdriver/blob/main/SECURITY.md).
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
[MIT](https://github.com/MahmoudOmiesh/figdriver/blob/main/LICENSE)
|
package/cli/result.ts
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AuditRules,
|
|
3
|
+
EditorCapabilities,
|
|
4
|
+
ExportBounds,
|
|
5
|
+
ExportFormat,
|
|
6
|
+
FindMatch,
|
|
7
|
+
FindQuery,
|
|
8
|
+
Imported,
|
|
9
|
+
ImportSummary,
|
|
10
|
+
Inventory,
|
|
11
|
+
Layer,
|
|
12
|
+
Outcome,
|
|
13
|
+
OwnedAudit,
|
|
14
|
+
RunPage,
|
|
15
|
+
TokenImportSummary,
|
|
16
|
+
} from "../src/core/protocol.js";
|
|
17
|
+
|
|
18
|
+
export type {
|
|
19
|
+
AuditRules,
|
|
20
|
+
EditorCapabilities,
|
|
21
|
+
ExportBounds,
|
|
22
|
+
ExportFormat,
|
|
23
|
+
FindMatch,
|
|
24
|
+
FindQuery,
|
|
25
|
+
Imported,
|
|
26
|
+
ImportSummary,
|
|
27
|
+
RunPage,
|
|
28
|
+
TokenImportSummary,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type FileRef = { name: string; key: string; url: string };
|
|
32
|
+
|
|
33
|
+
export type PageRef = { name: string; id: string };
|
|
34
|
+
|
|
35
|
+
type Common = { ok: boolean; warnings: string[]; files: string[] };
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The file and page a command acted on. For `import run` and `eval`, the page is `--page`'s or else the current one, as
|
|
39
|
+
* `pageSource` says; a command that reads every page, such as `import audit`, reports the current page.
|
|
40
|
+
*/
|
|
41
|
+
type InFile = { file: FileRef; page: PageRef };
|
|
42
|
+
|
|
43
|
+
export type Audit = OwnedAudit;
|
|
44
|
+
|
|
45
|
+
export type AuditReport = Audit & { found: boolean; clean: boolean };
|
|
46
|
+
|
|
47
|
+
/** What `figdriver import run` records in <dir>/out/design.json, so `import audit` and `import parity` compare that build. */
|
|
48
|
+
export type BuiltDesign = { name: string; file: string; page: PageRef; owner: string; nodes: string[] };
|
|
49
|
+
|
|
50
|
+
export type Screen = { name: string; id: string; file: string };
|
|
51
|
+
|
|
52
|
+
export type SkippedImage = { url: string; reason: string };
|
|
53
|
+
|
|
54
|
+
export type ParitySection = {
|
|
55
|
+
name: string;
|
|
56
|
+
id: string;
|
|
57
|
+
/** [width, height] of the section in the source page, of the rebuild's export, and of the area compared: the union of both. */
|
|
58
|
+
source: [number, number];
|
|
59
|
+
rebuilt: [number, number];
|
|
60
|
+
compared: [number, number];
|
|
61
|
+
/** Share of the compared area that differs, counting area only one image covers. */
|
|
62
|
+
mismatch: number;
|
|
63
|
+
file: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** `writing` is the command still writing to the file from this browser tab, and how many seconds it has run. */
|
|
67
|
+
export type DoctorResult = Common &
|
|
68
|
+
InFile & {
|
|
69
|
+
command: "doctor";
|
|
70
|
+
version: string;
|
|
71
|
+
browser: string;
|
|
72
|
+
editor: string;
|
|
73
|
+
me: string | null;
|
|
74
|
+
users: string[] | null;
|
|
75
|
+
built: string[];
|
|
76
|
+
writing: { command: string; seconds: number } | null;
|
|
77
|
+
pageCount: number;
|
|
78
|
+
capabilities: EditorCapabilities;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/** One viewport of a capture: the first is the capture's own folder, each other one `<dir>/<width>x<height>/`. */
|
|
82
|
+
export type CapturedViewport = {
|
|
83
|
+
dir: string;
|
|
84
|
+
viewport: [number, number];
|
|
85
|
+
snapshot: string;
|
|
86
|
+
reference: string | null;
|
|
87
|
+
starter: string | null;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/** The top-level fields describe the first viewport. `viewports` lists every one, and only when `--viewport` named several. */
|
|
91
|
+
export type CaptureResult = Common & {
|
|
92
|
+
command: "import capture";
|
|
93
|
+
dir: string;
|
|
94
|
+
source: string;
|
|
95
|
+
snapshot: string;
|
|
96
|
+
viewport: [number, number];
|
|
97
|
+
tokens: number;
|
|
98
|
+
images: string[];
|
|
99
|
+
videos: string[];
|
|
100
|
+
skippedImages: SkippedImage[];
|
|
101
|
+
reference: string | null;
|
|
102
|
+
starter: string | null;
|
|
103
|
+
viewports?: CapturedViewport[];
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* `outcome` is "replace" when the build replaced its name's output on `page`; otherwise the build is on `draft`, `reason` says why,
|
|
108
|
+
* and after "failed" `committed` lists each change that stayed. `ok` is true only for "replace" with its screens exported.
|
|
109
|
+
*/
|
|
110
|
+
export type RunResult = Common & {
|
|
111
|
+
command: "import run";
|
|
112
|
+
file: FileRef;
|
|
113
|
+
page: RunPage;
|
|
114
|
+
design: string;
|
|
115
|
+
pageSource: "flag" | "current";
|
|
116
|
+
outcome: Outcome;
|
|
117
|
+
committed: string[];
|
|
118
|
+
draft: PageRef | null;
|
|
119
|
+
reason: string | null;
|
|
120
|
+
output: string[];
|
|
121
|
+
built: ImportSummary;
|
|
122
|
+
audit: AuditReport;
|
|
123
|
+
screens: Screen[];
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* `design` is the folder's design for `import audit <dir>`, or null for whole-file `import audit` and page `audit`.
|
|
128
|
+
* `ruleset` is the rules applied: `authored` for `audit`, `run` for `import audit`.
|
|
129
|
+
*/
|
|
130
|
+
export type AuditResult = Common &
|
|
131
|
+
InFile & { command: "audit" | "import audit"; design: string | null; ruleset: AuditRules; audit: AuditReport };
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* `node` is the exported node id when a single node was exported, otherwise null.
|
|
135
|
+
*/
|
|
136
|
+
export type ExportResult = Common &
|
|
137
|
+
InFile & {
|
|
138
|
+
command: "export";
|
|
139
|
+
node: string | null;
|
|
140
|
+
format: ExportFormat;
|
|
141
|
+
bounds: ExportBounds;
|
|
142
|
+
screens: Screen[];
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* For `import parity <dir>`, `build` is the build compared on its page or draft page. For `parity <node-id> <ref.png>`,
|
|
147
|
+
* `design` and `build` are null and `node` is the compared node id. `ok` is false when a section exceeds `maxMismatch` percent.
|
|
148
|
+
*/
|
|
149
|
+
export type ParityResult = Common &
|
|
150
|
+
InFile & {
|
|
151
|
+
command: "parity" | "import parity";
|
|
152
|
+
design: string | null;
|
|
153
|
+
build: BuiltDesign | null;
|
|
154
|
+
node: string | null;
|
|
155
|
+
reference: string;
|
|
156
|
+
maxMismatch: number | null;
|
|
157
|
+
sections: ParitySection[];
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export type EvalResult = Common & InFile & { command: "eval"; pageSource: "flag" | "current"; result: unknown };
|
|
161
|
+
|
|
162
|
+
/** `result` is the file's inventory, or the layers named with `--node`, `--page`, or `--selection`. */
|
|
163
|
+
export type InspectResult = Common & InFile & { command: "inspect"; result: Inventory | Layer[] };
|
|
164
|
+
|
|
165
|
+
/** `total` counts every match; `matches` holds the first `--limit` of them, and `truncated` says whether that left any out. */
|
|
166
|
+
export type FindResult = Common &
|
|
167
|
+
InFile & { command: "find"; query: FindQuery; matches: FindMatch[]; total: number; truncated: boolean };
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* `count` is the variables exported, or the variables the file read. `imported` says what an import changed, or with `dryRun` what it
|
|
171
|
+
* would change.
|
|
172
|
+
*/
|
|
173
|
+
export type TokensResult = Common &
|
|
174
|
+
InFile & {
|
|
175
|
+
command: "tokens export" | "tokens import";
|
|
176
|
+
action: "export" | "import";
|
|
177
|
+
format: "css" | "tailwind" | "dtcg";
|
|
178
|
+
dryRun?: boolean;
|
|
179
|
+
count: number;
|
|
180
|
+
imported?: TokenImportSummary;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export type PluginResult = Common & { command: "import plugin"; dir: string };
|
|
184
|
+
|
|
185
|
+
export type TabInfo = { id: string; title: string; url: string; fileKey: string | null };
|
|
186
|
+
|
|
187
|
+
export type BrowserOpenResult = Common & {
|
|
188
|
+
command: "browser open";
|
|
189
|
+
action: "started" | "opened" | "focused" | "running";
|
|
190
|
+
browser: string | null;
|
|
191
|
+
url: string | null;
|
|
192
|
+
fileKey: string | null;
|
|
193
|
+
reused: boolean;
|
|
194
|
+
tabs: TabInfo[];
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
export type BrowserTabsResult = Common & { command: "browser tabs"; tabs: TabInfo[]; duplicates: string[] };
|
|
198
|
+
|
|
199
|
+
export type BrowserCloseResult = Common & { command: "browser close"; closed: TabInfo[] };
|
|
200
|
+
|
|
201
|
+
export type BrowserStopResult = Common & { command: "browser stop"; action: "stopped" | "not-running" };
|
|
202
|
+
|
|
203
|
+
/** `page` is null when the tab's plugin API was down, as in a view-only file. */
|
|
204
|
+
export type BrowserScreenshotResult = Common & {
|
|
205
|
+
command: "browser screenshot";
|
|
206
|
+
file: FileRef;
|
|
207
|
+
page: PageRef | null;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
export type VersionResult = Common & { command: "version"; version: string };
|
|
211
|
+
|
|
212
|
+
export type ErrorResult = { command: string; ok: false; error: string };
|
|
213
|
+
|
|
214
|
+
export type Result =
|
|
215
|
+
| BrowserOpenResult
|
|
216
|
+
| BrowserTabsResult
|
|
217
|
+
| BrowserCloseResult
|
|
218
|
+
| BrowserStopResult
|
|
219
|
+
| BrowserScreenshotResult
|
|
220
|
+
| DoctorResult
|
|
221
|
+
| CaptureResult
|
|
222
|
+
| RunResult
|
|
223
|
+
| AuditResult
|
|
224
|
+
| ExportResult
|
|
225
|
+
| ParityResult
|
|
226
|
+
| EvalResult
|
|
227
|
+
| InspectResult
|
|
228
|
+
| FindResult
|
|
229
|
+
| TokensResult
|
|
230
|
+
| PluginResult
|
|
231
|
+
| VersionResult;
|