deictic 0.4.0 → 0.6.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/API.md +19 -8
- package/dist/cli.js +34 -28
- package/dist/cli.js.map +1 -1
- package/dist/shared/board.js +8 -19
- package/dist/shared/board.js.map +1 -1
- package/dist/shared/clean.js +105 -0
- package/dist/shared/clean.js.map +1 -0
- package/dist/shared/endpoints.js +35 -9
- package/dist/shared/endpoints.js.map +1 -1
- package/dist/shared/find.js +3 -2
- package/dist/shared/find.js.map +1 -1
- package/dist/shared/frame.js +4 -18
- package/dist/shared/frame.js.map +1 -1
- package/dist/shared/index.d.ts +8 -4
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index7.d.ts +2 -0
- package/dist/shared/index7.d.ts.map +1 -1
- package/dist/shared/init.js +17 -24
- package/dist/shared/init.js.map +1 -1
- package/dist/shared/local.js +2 -1
- package/dist/shared/local.js.map +1 -1
- package/dist/shared/packages.js +9 -2
- package/dist/shared/packages.js.map +1 -1
- package/dist/shared/recording.js +4 -27
- package/dist/shared/recording.js.map +1 -1
- package/dist/shared/src.js.map +1 -1
- package/dist/shared/task.js +43 -10
- package/dist/shared/task.js.map +1 -1
- package/dist/shared/tasks.js +109 -115
- package/dist/shared/tasks.js.map +1 -1
- package/dist/shared/transcribe.js +1 -128
- package/dist/shared/transcribe2.js +119 -0
- package/dist/shared/transcribe2.js.map +1 -0
- package/dist/shared/vb.js +2 -3
- package/dist/shared/vb.js.map +1 -1
- package/dist/shared/voice2.js +4 -17
- package/dist/shared/voice2.js.map +1 -1
- package/dist/shared/watch.js +56 -39
- package/dist/shared/watch.js.map +1 -1
- package/dist/tailwind/index.js +6 -2
- package/dist/tailwind/index.js.map +1 -1
- package/dist/tasks/client.d.ts.map +1 -1
- package/dist/tasks/client.js +4 -5
- package/dist/tasks/client.js.map +1 -1
- package/dist/tasks/index.js +1 -1
- package/package.json +2 -1
- package/skills/deictic/SKILL.md +5 -3
- package/skills/deictic/references/tasks.md +6 -5
- package/src/cli/board.ts +7 -13
- package/src/cli/clean.ts +104 -0
- package/src/cli/find.ts +3 -1
- package/src/cli/frame.ts +3 -13
- package/src/cli/init.ts +16 -20
- package/src/cli/recording.ts +15 -21
- package/src/cli/task.ts +49 -10
- package/src/cli/transcribe.ts +13 -16
- package/src/cli/vb.ts +0 -2
- package/src/cli/voice.ts +3 -12
- package/src/cli/watch.ts +58 -29
- package/src/cli.ts +130 -31
- package/src/index.ts +8 -4
- package/src/plugins/tailwind/index.ts +6 -2
- package/src/plugins/tasks/client.ts +4 -5
- package/src/plugins/tasks/index.ts +113 -124
- package/src/plugins/tasks/local.ts +2 -1
- package/src/tools/endpoints.ts +18 -7
- package/src/tools/packages.ts +3 -0
- package/src/tools/source.ts +25 -5
- package/dist/shared/transcribe.js.map +0 -1
package/dist/shared/watch.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { spawn, spawnSync } from "node:child_process";
|
|
2
2
|
import { createInterface } from "node:readline";
|
|
3
3
|
import { t as watcherAt } from "./watchers.js";
|
|
4
|
-
import {
|
|
4
|
+
import { c as duration, f as vb, g as whoami, h as vbJson, i as boardUrl, n as answers, o as deicticDirs, p as vbCommand, r as boardIn, t as ME } from "./board.js";
|
|
5
5
|
// src/cli/watch.ts
|
|
6
6
|
/**
|
|
7
7
|
* `deictic watch`: the board's tasks for deictic, one line per thing to act on: the tasks ready now as it starts,
|
|
8
8
|
* then each new task, a reply on one, and one canceled (undone in the page, say). Made for an agent's monitor (each
|
|
9
|
-
* line an event). A board that goes away (the dev server restarted, and its board with it
|
|
10
|
-
* again from where it was left; it says so, and ends only if none comes back. It ends by itself once nothing has
|
|
9
|
+
* line an event). A board that goes away (the dev server restarted, and its board with it, maybe on another port) is
|
|
10
|
+
* waited for and followed again from where it was left; it says so, and ends only if none comes back. It ends by itself once nothing has
|
|
11
11
|
* happened on the channel for `--idle` (20m): a watch nobody feeds isn't started again, so no agent watches for ever.
|
|
12
12
|
* With `--once` it ends at the first thing to act on, for a harness that's woken only when a command exits. It ends,
|
|
13
13
|
* too, when the process that started it does: nobody reads its lines then.
|
|
@@ -16,7 +16,6 @@ import { _ as whoami, c as duration, i as boardUrl, m as vbCommand, n as answers
|
|
|
16
16
|
* where it has a name of its own (BOARD_PROFILE): with none it writes as the person. Exits 0 after `--once`'s event,
|
|
17
17
|
* 2 when idle, 1 when the board went away.
|
|
18
18
|
*/
|
|
19
|
-
const usage = "watch [channel] [--idle 20m] [--once] [--label k=v] a line per new task, reply and cancellation";
|
|
20
19
|
/** How long a board that went away is waited for: a dev server's restart takes a few seconds. */
|
|
21
20
|
const BACK = 6e4;
|
|
22
21
|
/** A tail that ends sooner than this after it's started again isn't started a third time: the board isn't the trouble. */
|
|
@@ -60,23 +59,37 @@ function gone(pid) {
|
|
|
60
59
|
return e.code === "ESRCH";
|
|
61
60
|
}
|
|
62
61
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const channel = positionals[0] ?? "deictic";
|
|
62
|
+
/** What `vb` said as it failed: its JSON's `message`, or its last line. */
|
|
63
|
+
function reasonOf(said) {
|
|
64
|
+
const last = said.trim().split("\n").at(-1)?.trim();
|
|
65
|
+
if (last === void 0 || last === "") return void 0;
|
|
66
|
+
try {
|
|
67
|
+
const { message } = JSON.parse(last);
|
|
68
|
+
return typeof message === "string" ? message : last;
|
|
69
|
+
} catch {
|
|
70
|
+
return last;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function run(channel, values) {
|
|
76
74
|
const labels = (values.label ?? []).flatMap((l) => ["--label", l]);
|
|
77
75
|
const idle = duration(values.idle);
|
|
78
76
|
const say = (line) => console.log(line.replace(/\s+/g, " ").trim());
|
|
79
77
|
const first = (text) => (text.split("\n---")[0] ?? "").trim().slice(0, 160);
|
|
78
|
+
const made = () => {
|
|
79
|
+
const [command, argv, options] = vbCommand([
|
|
80
|
+
"channels",
|
|
81
|
+
"create",
|
|
82
|
+
channel
|
|
83
|
+
]);
|
|
84
|
+
spawnSync(command, argv, options);
|
|
85
|
+
};
|
|
86
|
+
made();
|
|
87
|
+
let cursor = vbJson([
|
|
88
|
+
"read",
|
|
89
|
+
channel,
|
|
90
|
+
"--limit",
|
|
91
|
+
"1"
|
|
92
|
+
]).cursor;
|
|
80
93
|
const ready = vb([
|
|
81
94
|
"tasks",
|
|
82
95
|
channel,
|
|
@@ -108,6 +121,7 @@ function run(args) {
|
|
|
108
121
|
say(`watching ${channel} on ${url ?? "the team's board"} as ${me.handle ?? me.actor}`);
|
|
109
122
|
if (me.profile === null) say(`you write as ${me.handle ?? me.actor}, the person's own identity, as nothing here says which agent you are: set BOARD_PROFILE=<your name> (claude, codex) on every command, this watch too, and start it again`);
|
|
110
123
|
const waiting = (ready ? ready.split("\n") : []).filter((line) => /^#\d+/.test(line));
|
|
124
|
+
const told = new Set(waiting.map((line) => /^#(\d+)/.exec(line)?.[1]));
|
|
111
125
|
for (const line of waiting) say(`ready: ${line}`);
|
|
112
126
|
if (values.once && waiting.length > 0) end(0);
|
|
113
127
|
/** One thing to act on: all `--once` waits for. */
|
|
@@ -125,7 +139,6 @@ function run(args) {
|
|
|
125
139
|
};
|
|
126
140
|
heard();
|
|
127
141
|
const roots = /* @__PURE__ */ new Map();
|
|
128
|
-
let cursor;
|
|
129
142
|
const heardOf = (line) => {
|
|
130
143
|
let e;
|
|
131
144
|
try {
|
|
@@ -143,7 +156,7 @@ function run(args) {
|
|
|
143
156
|
const project = label("deictic.project");
|
|
144
157
|
roots.set(p.thread, `"${first(p.text ?? "")}"${at ? ` at ${at}` : ""}${page ? ` on ${page}` : ""}${project ? ` in ${project}` : ""}`);
|
|
145
158
|
}
|
|
146
|
-
if (e.type === "task.created") event(`new task #${p.id}: ${roots.get(p.thread ?? -1) ?? ""}. Read it:
|
|
159
|
+
if (e.type === "task.created" && !told.has(String(p.id))) event(`new task #${p.id}: ${roots.get(p.thread ?? -1) ?? ""}. Read it: ${ME} task ${p.id}`);
|
|
147
160
|
if (e.type === "message.posted" && p.re !== null && p.re !== void 0) {
|
|
148
161
|
if (me.profile !== null && p.by?.actor === me.actor) return;
|
|
149
162
|
const by = e.message?.author?.handle ?? p.by?.actor ?? "someone";
|
|
@@ -151,19 +164,19 @@ function run(args) {
|
|
|
151
164
|
}
|
|
152
165
|
if (e.type === "task.canceled") event(`task #${p.id} canceled: ${p.reason ?? ""}. Stop work on it, and put back what you changed for it.`);
|
|
153
166
|
};
|
|
154
|
-
const over = (
|
|
155
|
-
say(`watch ended (
|
|
167
|
+
const over = (why) => {
|
|
168
|
+
say(`watch ended (${why}): start it again`);
|
|
156
169
|
end(1);
|
|
157
170
|
};
|
|
158
|
-
/** Follows the channel
|
|
171
|
+
/** Follows the channel from `cursor`, and again when the board comes back after going away. */
|
|
159
172
|
const follow = (again) => {
|
|
160
173
|
const started = Date.now();
|
|
161
|
-
const from = cursor === void 0 ? [] : ["--after", cursor];
|
|
162
174
|
const [command, argv, options] = vbCommand([
|
|
163
175
|
"tail",
|
|
164
176
|
channel,
|
|
165
177
|
...labels,
|
|
166
|
-
|
|
178
|
+
"--after",
|
|
179
|
+
cursor,
|
|
167
180
|
"--json"
|
|
168
181
|
]);
|
|
169
182
|
const child = spawn(command, argv, {
|
|
@@ -172,31 +185,35 @@ function run(args) {
|
|
|
172
185
|
stdio: [
|
|
173
186
|
"ignore",
|
|
174
187
|
"pipe",
|
|
175
|
-
"
|
|
188
|
+
"pipe"
|
|
176
189
|
]
|
|
177
190
|
});
|
|
178
191
|
tail = child;
|
|
179
192
|
createInterface({ input: child.stdout }).on("line", heardOf);
|
|
193
|
+
let said = "";
|
|
194
|
+
child.stderr.on("data", (chunk) => said += chunk.toString());
|
|
195
|
+
const at = boardUrl();
|
|
196
|
+
let moved;
|
|
197
|
+
const elsewhere = setInterval(() => {
|
|
198
|
+
const now = boardUrl();
|
|
199
|
+
if (now === at || now === void 0) return;
|
|
200
|
+
moved = now;
|
|
201
|
+
child.kill();
|
|
202
|
+
}, 3e3);
|
|
180
203
|
child.on("exit", (code) => {
|
|
181
|
-
|
|
182
|
-
|
|
204
|
+
clearInterval(elsewhere);
|
|
205
|
+
const reason = reasonOf(said);
|
|
206
|
+
const why = moved === void 0 ? `vb tail exited ${code}${reason === void 0 ? "" : `: ${reason}`}` : `started again on ${moved}`;
|
|
207
|
+
if (again && moved === void 0 && Date.now() - started < SOON) return over(why);
|
|
208
|
+
say(`the board went away (${why}): waiting for it to come back`);
|
|
183
209
|
const until = Date.now() + BACK;
|
|
184
210
|
const tried = () => {
|
|
185
211
|
if (answers()) {
|
|
186
212
|
say(`the board is back on ${boardUrl() ?? "the team's board"}: watching ${channel} again`);
|
|
187
|
-
|
|
188
|
-
const now = vb([
|
|
189
|
-
"tasks",
|
|
190
|
-
channel,
|
|
191
|
-
"--state",
|
|
192
|
-
"ready",
|
|
193
|
-
...labels
|
|
194
|
-
]).trim();
|
|
195
|
-
for (const l of now.split("\n").filter((l) => /^#\d+/.test(l) && !waiting.includes(l))) event(`ready: ${l}`);
|
|
196
|
-
}
|
|
213
|
+
made();
|
|
197
214
|
return follow(true);
|
|
198
215
|
}
|
|
199
|
-
if (Date.now() > until) return over(
|
|
216
|
+
if (Date.now() > until) return over(why);
|
|
200
217
|
setTimeout(tried, 2e3);
|
|
201
218
|
};
|
|
202
219
|
setTimeout(tried, 2e3);
|
|
@@ -204,6 +221,6 @@ function run(args) {
|
|
|
204
221
|
};
|
|
205
222
|
follow(false);
|
|
206
223
|
}
|
|
207
|
-
export { run
|
|
224
|
+
export { run };
|
|
208
225
|
|
|
209
226
|
//# sourceMappingURL=watch.js.map
|
package/dist/shared/watch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.js","names":[],"sources":["../../src/cli/watch.ts"],"sourcesContent":["/**\n * `deictic watch`: the board's tasks for deictic, one line per thing to act on: the tasks ready now as it starts,\n * then each new task, a reply on one, and one canceled (undone in the page, say). Made for an agent's monitor (each\n * line an event). A board that goes away (the dev server restarted, and its board with it) is waited for and followed\n * again from where it was left; it says so, and ends only if none comes back. It ends by itself once nothing has\n * happened on the channel for `--idle` (20m): a watch nobody feeds isn't started again, so no agent watches for ever.\n * With `--once` it ends at the first thing to act on, for a harness that's woken only when a command exits. It ends,\n * too, when the process that started it does: nobody reads its lines then.\n *\n * While it runs the project's Task tab shows who watches (`watcherAt`). Replies the watcher wrote itself are left out\n * where it has a name of its own (BOARD_PROFILE): with none it writes as the person. Exits 0 after `--once`'s event,\n * 2 when idle, 1 when the board went away.\n */\nimport { type ChildProcess, spawn, spawnSync } from 'node:child_process';\nimport { createInterface } from 'node:readline';\n\nimport { watcherAt } from '#src/plugins/tasks/watchers.ts';\n\nimport { answers, boardIn, boardUrl, deicticDirs, duration, parseArgs, vb, vbCommand, whoami } from './board.ts';\n\nexport const usage = 'watch [channel] [--idle 20m] [--once] [--label k=v] a line per new task, reply and cancellation';\n\n/** What `vb tail --json` prints, one per line. */\ninterface Tailed {\n type: string;\n cursor?: string;\n payload?: {\n id?: number;\n thread?: number;\n re?: number | null;\n text?: string;\n reason?: string;\n labels?: Record<string, string>;\n by?: { actor: string };\n };\n message?: { author?: { handle?: string } };\n}\n\n/** How long a board that went away is waited for: a dev server's restart takes a few seconds. */\nconst BACK = 60_000;\n/** A tail that ends sooner than this after it's started again isn't started a third time: the board isn't the trouble. */\nconst SOON = 10_000;\n\n/** Each process's parent, by ID, asked of the system once: empty where it can't say. */\nfunction parents(): Map<number, number> {\n const run =\n process.platform === 'win32'\n ? spawnSync(\n 'powershell',\n ['-NoProfile', '-Command', 'Get-CimInstance Win32_Process | % { \"$($_.ProcessId) $($_.ParentProcessId)\" }'],\n {\n encoding: 'utf8',\n },\n )\n : spawnSync('ps', ['-A', '-o', 'pid=', '-o', 'ppid='], { encoding: 'utf8' });\n const map = new Map<number, number>();\n for (const line of (run.stdout ?? '').split('\\n')) {\n const [pid, ppid] = line.trim().split(/\\s+/).map(Number);\n if (pid !== undefined && ppid !== undefined && Number.isInteger(pid) && Number.isInteger(ppid)) map.set(pid, ppid);\n }\n return map;\n}\n\n/**\n * The processes above this one's parent, the nearest `count` of them. A runner (`npx`, `pnpm exec`, and on Windows the\n * shell and the bin's `.cmd` shim it runs) sits between the watch and the shell that ran it, and outlives that shell.\n */\nfunction ancestors(count: number): number[] {\n const of = parents();\n const out: number[] = [];\n for (let pid = of.get(process.ppid); pid !== undefined && pid > 1 && out.length < count && !out.includes(pid); pid = of.get(pid))\n out.push(pid);\n return out;\n}\n\n/** Whether a process is gone. On Windows a dead parent's ID stays a child's `ppid`, so the system is asked. */\nfunction gone(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return false;\n } catch (e) {\n return (e as { code?: string }).code === 'ESRCH';\n }\n}\n\nexport function run(args: string[]): void {\n const { values, positionals } = parseArgs(args, {\n idle: { type: 'string', default: '20m' },\n once: { type: 'boolean' },\n label: { type: 'string', multiple: true },\n });\n const channel = positionals[0] ?? 'deictic';\n const labels = (values.label ?? []).flatMap((l) => ['--label', l]);\n const idle = duration(values.idle);\n const say = (line: string) => console.log(line.replace(/\\s+/g, ' ').trim());\n const first = (text: string) => (text.split('\\n---')[0] ?? '').trim().slice(0, 160);\n\n const ready = vb(['tasks', channel, '--state', 'ready', ...labels]).trim();\n const me = whoami();\n // In the `.deictic/` whose board this is, or in each one near here where the board is the environment's.\n const url = boardUrl();\n const dirs = deicticDirs();\n const own = dirs.filter((dir) => boardIn(dir) === url);\n const unseen = watcherAt(own.length > 0 ? own : dirs, me.profile ?? me.name ?? me.handle ?? me.actor, channel);\n let tail: ChildProcess | undefined;\n const end = (code: number) => {\n unseen();\n tail?.removeAllListeners('exit');\n tail?.kill();\n process.exit(code);\n };\n // Stopped by its monitor, where the system says so: the page isn't left thinking someone watches.\n for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP'] as const) process.on(signal, () => end(0));\n\n // Whoever started the watch reads its lines. With that gone (a session that ended and left the watch behind) no one\n // does, and the page mustn't go on saying an agent watches. Run through a runner, the shell is a few processes up,\n // so those are watched too: any gone, and the watch ends. A dead parent shows as another parent's ID, except on\n // Windows, where the system is asked whether it's still a process.\n const parent = process.ppid;\n const above = ancestors(3);\n const orphaned = () => process.ppid !== parent || gone(parent) || above.some(gone);\n setInterval(() => orphaned() && end(0), 5000);\n\n say(`watching ${channel} on ${url ?? \"the team's board\"} as ${me.handle ?? me.actor}`);\n // With no profile (an agent `profileOf` doesn't know), the person's replies and the watcher's own are one actor's:\n // none can be left out.\n if (me.profile === null) {\n say(\n `you write as ${me.handle ?? me.actor}, the person's own identity, as nothing here says which agent you are: set BOARD_PROFILE=<your name> (claude, codex) on every command, this watch too, and start it again`,\n );\n }\n const waiting = (ready ? ready.split('\\n') : []).filter((line) => /^#\\d+/.test(line));\n for (const line of waiting) say(`ready: ${line}`);\n if (values.once && waiting.length > 0) end(0);\n\n /** One thing to act on: all `--once` waits for. */\n const event = (line: string) => {\n say(line);\n if (values.once) end(0);\n };\n\n // Anything on the channel puts the end off, the watcher's own claims and replies too: it's being worked.\n let quiet: ReturnType<typeof setTimeout> | undefined;\n const heard = () => {\n clearTimeout(quiet);\n quiet = setTimeout(() => {\n say(\n `idle: nothing on ${channel} in ${values.idle}, so the watch is over. Don't start it again by yourself: tell the person in a line that you've stopped watching, and watch again when they ask. Only if you're working a task now, start it once more when that's done.`,\n );\n end(2);\n }, idle);\n };\n heard();\n\n // What the board says about each thread: its root's first line and where, to name it when a task is made.\n const roots = new Map<number, string>();\n // The last event heard, which a tail started again follows from: nothing left while the board was away is missed.\n let cursor: string | undefined;\n const heardOf = (line: string) => {\n let e: Tailed;\n try {\n e = JSON.parse(line) as Tailed;\n } catch {\n return;\n }\n if (e.cursor !== undefined) cursor = e.cursor;\n heard();\n const p = e.payload ?? {};\n const label = (key: string) => p.labels?.[key];\n if (e.type === 'message.posted' && p.re === null && p.thread !== undefined) {\n const at = label('deictic.at');\n const page = label('deictic.page');\n const project = label('deictic.project');\n roots.set(p.thread, `\"${first(p.text ?? '')}\"${at ? ` at ${at}` : ''}${page ? ` on ${page}` : ''}${project ? ` in ${project}` : ''}`);\n }\n if (e.type === 'task.created') event(`new task #${p.id}: ${roots.get(p.thread ?? -1) ?? ''}. Read it: npx deictic task ${p.id}`);\n if (e.type === 'message.posted' && p.re !== null && p.re !== undefined) {\n if (me.profile !== null && p.by?.actor === me.actor) return;\n const by = e.message?.author?.handle ?? p.by?.actor ?? 'someone';\n event(`reply on #${p.re} by ${by}: ${first(p.text ?? '')}`);\n }\n if (e.type === 'task.canceled')\n event(`task #${p.id} canceled: ${p.reason ?? ''}. Stop work on it, and put back what you changed for it.`);\n };\n\n const over = (code: number | null) => {\n say(`watch ended (vb tail exited ${code}): start it again`);\n end(1);\n };\n\n /** Follows the channel, from `cursor` on where there is one, and again when the board comes back after going away. */\n const follow = (again: boolean) => {\n const started = Date.now();\n const from = cursor === undefined ? [] : ['--after', cursor];\n const [command, argv, options] = vbCommand(['tail', channel, ...labels, ...from, '--json']);\n const child = spawn(command, argv, { env: options.env, shell: options.shell, stdio: ['ignore', 'pipe', 'inherit'] });\n tail = child;\n createInterface({ input: child.stdout }).on('line', heardOf);\n child.on('exit', (code) => {\n if (again && Date.now() - started < SOON) return over(code);\n say(`the board went away (vb tail exited ${code}): waiting for it to come back`);\n const until = Date.now() + BACK;\n const tried = () => {\n // Asked anew each time: a board started again may be at another URL, and the CLI gets itself a new token for it.\n if (answers()) {\n say(`the board is back on ${boardUrl() ?? \"the team's board\"}: watching ${channel} again`);\n // With nothing heard before it went, what's ready is all there is to go by.\n if (cursor === undefined) {\n const now = vb(['tasks', channel, '--state', 'ready', ...labels]).trim();\n for (const l of now.split('\\n').filter((l) => /^#\\d+/.test(l) && !waiting.includes(l))) event(`ready: ${l}`);\n }\n return follow(true);\n }\n if (Date.now() > until) return over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O;KAEzF,IAAI,WAAW,KAAA,GAAW;MACxB,MAAM,MAAM,GAAG;OAAC;OAAS;OAAS;OAAW;OAAS,GAAG;MAAM,CAAC,CAAC,CAAC,KAAK;MACvE,KAAK,MAAM,KAAK,IAAI,MAAM,IAAI,CAAC,CAAC,QAAQ,MAAM,QAAQ,KAAK,CAAC,KAAK,CAAC,QAAQ,SAAS,CAAC,CAAC,GAAG,MAAM,UAAU,GAAG;KAC7G;KACA,OAAO,OAAO,IAAI;IACpB;IACA,IAAI,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,IAAI;IACxC,WAAW,OAAO,GAAI;GACxB;GACA,WAAW,OAAO,GAAI;EACxB,CAAC;CACH;CACA,OAAO,KAAK;AACd"}
|
|
1
|
+
{"version":3,"file":"watch.js","names":[],"sources":["../../src/cli/watch.ts"],"sourcesContent":["/**\n * `deictic watch`: the board's tasks for deictic, one line per thing to act on: the tasks ready now as it starts,\n * then each new task, a reply on one, and one canceled (undone in the page, say). Made for an agent's monitor (each\n * line an event). A board that goes away (the dev server restarted, and its board with it, maybe on another port) is\n * waited for and followed again from where it was left; it says so, and ends only if none comes back. It ends by itself once nothing has\n * happened on the channel for `--idle` (20m): a watch nobody feeds isn't started again, so no agent watches for ever.\n * With `--once` it ends at the first thing to act on, for a harness that's woken only when a command exits. It ends,\n * too, when the process that started it does: nobody reads its lines then.\n *\n * While it runs the project's Task tab shows who watches (`watcherAt`). Replies the watcher wrote itself are left out\n * where it has a name of its own (BOARD_PROFILE): with none it writes as the person. Exits 0 after `--once`'s event,\n * 2 when idle, 1 when the board went away.\n */\nimport { type ChildProcess, spawn, spawnSync } from 'node:child_process';\nimport { createInterface } from 'node:readline';\n\nimport { watcherAt } from '#src/plugins/tasks/watchers.ts';\n\nimport { answers, boardIn, boardUrl, deicticDirs, duration, ME, vb, vbCommand, vbJson, whoami } from './board.ts';\n\n/** What `vb tail --json` prints, one per line. */\ninterface Tailed {\n type: string;\n cursor?: string;\n payload?: {\n id?: number;\n thread?: number;\n re?: number | null;\n text?: string;\n reason?: string;\n labels?: Record<string, string>;\n by?: { actor: string };\n };\n message?: { author?: { handle?: string } };\n}\n\n/** How long a board that went away is waited for: a dev server's restart takes a few seconds. */\nconst BACK = 60_000;\n/** A tail that ends sooner than this after it's started again isn't started a third time: the board isn't the trouble. */\nconst SOON = 10_000;\n\n/** Each process's parent, by ID, asked of the system once: empty where it can't say. */\nfunction parents(): Map<number, number> {\n const run =\n process.platform === 'win32'\n ? spawnSync(\n 'powershell',\n ['-NoProfile', '-Command', 'Get-CimInstance Win32_Process | % { \"$($_.ProcessId) $($_.ParentProcessId)\" }'],\n {\n encoding: 'utf8',\n },\n )\n : spawnSync('ps', ['-A', '-o', 'pid=', '-o', 'ppid='], { encoding: 'utf8' });\n const map = new Map<number, number>();\n for (const line of (run.stdout ?? '').split('\\n')) {\n const [pid, ppid] = line.trim().split(/\\s+/).map(Number);\n if (pid !== undefined && ppid !== undefined && Number.isInteger(pid) && Number.isInteger(ppid)) map.set(pid, ppid);\n }\n return map;\n}\n\n/**\n * The processes above this one's parent, the nearest `count` of them. A runner (`npx`, `pnpm exec`, and on Windows the\n * shell and the bin's `.cmd` shim it runs) sits between the watch and the shell that ran it, and outlives that shell.\n */\nfunction ancestors(count: number): number[] {\n const of = parents();\n const out: number[] = [];\n for (let pid = of.get(process.ppid); pid !== undefined && pid > 1 && out.length < count && !out.includes(pid); pid = of.get(pid))\n out.push(pid);\n return out;\n}\n\n/** Whether a process is gone. On Windows a dead parent's ID stays a child's `ppid`, so the system is asked. */\nfunction gone(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return false;\n } catch (e) {\n return (e as { code?: string }).code === 'ESRCH';\n }\n}\n\n/** What `vb` said as it failed: its JSON's `message`, or its last line. */\nfunction reasonOf(said: string): string | undefined {\n const last = said.trim().split('\\n').at(-1)?.trim();\n if (last === undefined || last === '') return undefined;\n try {\n const { message } = JSON.parse(last) as { message?: unknown };\n return typeof message === 'string' ? message : last;\n } catch {\n return last;\n }\n}\n\nexport function run(channel: string, values: { idle: string; once?: boolean; label?: string[] }): void {\n const labels = (values.label ?? []).flatMap((l) => ['--label', l]);\n const idle = duration(values.idle);\n const say = (line: string) => console.log(line.replace(/\\s+/g, ' ').trim());\n const first = (text: string) => (text.split('\\n---')[0] ?? '').trim().slice(0, 160);\n\n // A board nothing has posted to yet has no channel, and won't list or follow one it hasn't: made here, as the first\n // task would make it. One that's there stays as it is; where the board won't let this make one, `vb tasks` says so.\n const made = () => {\n const [command, argv, options] = vbCommand(['channels', 'create', channel]);\n spawnSync(command, argv, options);\n };\n made();\n // Where the channel is now, taken before what's ready is: followed from here, nothing posted between is missed, and\n // a tail started again after the board went away follows on from what this one heard, never from a list taken earlier.\n let cursor = vbJson<{ cursor: string }>(['read', channel, '--limit', '1']).cursor;\n const ready = vb(['tasks', channel, '--state', 'ready', ...labels]).trim();\n const me = whoami();\n // In the `.deictic/` whose board this is, or in each one near here where the board is the environment's.\n const url = boardUrl();\n const dirs = deicticDirs();\n const own = dirs.filter((dir) => boardIn(dir) === url);\n const unseen = watcherAt(own.length > 0 ? own : dirs, me.profile ?? me.name ?? me.handle ?? me.actor, channel);\n let tail: ChildProcess | undefined;\n const end = (code: number) => {\n unseen();\n tail?.removeAllListeners('exit');\n tail?.kill();\n process.exit(code);\n };\n // Stopped by its monitor, where the system says so: the page isn't left thinking someone watches.\n for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP'] as const) process.on(signal, () => end(0));\n\n // Whoever started the watch reads its lines. With that gone (a session that ended and left the watch behind) no one\n // does, and the page mustn't go on saying an agent watches. Run through a runner, the shell is a few processes up,\n // so those are watched too: any gone, and the watch ends. A dead parent shows as another parent's ID, except on\n // Windows, where the system is asked whether it's still a process.\n const parent = process.ppid;\n const above = ancestors(3);\n const orphaned = () => process.ppid !== parent || gone(parent) || above.some(gone);\n setInterval(() => orphaned() && end(0), 5000);\n\n say(`watching ${channel} on ${url ?? \"the team's board\"} as ${me.handle ?? me.actor}`);\n // With no profile (an agent `profileOf` doesn't know), the person's replies and the watcher's own are one actor's:\n // none can be left out.\n if (me.profile === null) {\n say(\n `you write as ${me.handle ?? me.actor}, the person's own identity, as nothing here says which agent you are: set BOARD_PROFILE=<your name> (claude, codex) on every command, this watch too, and start it again`,\n );\n }\n const waiting = (ready ? ready.split('\\n') : []).filter((line) => /^#\\d+/.test(line));\n // The tasks said, by ID: one made after the cursor above and listed as ready is said once.\n const told = new Set(waiting.map((line) => /^#(\\d+)/.exec(line)?.[1]));\n for (const line of waiting) say(`ready: ${line}`);\n if (values.once && waiting.length > 0) end(0);\n\n /** One thing to act on: all `--once` waits for. */\n const event = (line: string) => {\n say(line);\n if (values.once) end(0);\n };\n\n // Anything on the channel puts the end off, the watcher's own claims and replies too: it's being worked.\n let quiet: ReturnType<typeof setTimeout> | undefined;\n const heard = () => {\n clearTimeout(quiet);\n quiet = setTimeout(() => {\n say(\n `idle: nothing on ${channel} in ${values.idle}, so the watch is over. Don't start it again by yourself: tell the person in a line that you've stopped watching, and watch again when they ask. Only if you're working a task now, start it once more when that's done.`,\n );\n end(2);\n }, idle);\n };\n heard();\n\n // What the board says about each thread: its root's first line and where, to name it when a task is made.\n const roots = new Map<number, string>();\n const heardOf = (line: string) => {\n let e: Tailed;\n try {\n e = JSON.parse(line) as Tailed;\n } catch {\n return;\n }\n // The last event heard, which a tail started again follows from: nothing left while the board was away is missed.\n if (e.cursor !== undefined) cursor = e.cursor;\n heard();\n const p = e.payload ?? {};\n const label = (key: string) => p.labels?.[key];\n if (e.type === 'message.posted' && p.re === null && p.thread !== undefined) {\n const at = label('deictic.at');\n const page = label('deictic.page');\n const project = label('deictic.project');\n roots.set(p.thread, `\"${first(p.text ?? '')}\"${at ? ` at ${at}` : ''}${page ? ` on ${page}` : ''}${project ? ` in ${project}` : ''}`);\n }\n if (e.type === 'task.created' && !told.has(String(p.id)))\n event(`new task #${p.id}: ${roots.get(p.thread ?? -1) ?? ''}. Read it: ${ME} task ${p.id}`);\n if (e.type === 'message.posted' && p.re !== null && p.re !== undefined) {\n if (me.profile !== null && p.by?.actor === me.actor) return;\n const by = e.message?.author?.handle ?? p.by?.actor ?? 'someone';\n event(`reply on #${p.re} by ${by}: ${first(p.text ?? '')}`);\n }\n if (e.type === 'task.canceled')\n event(`task #${p.id} canceled: ${p.reason ?? ''}. Stop work on it, and put back what you changed for it.`);\n };\n\n const over = (why: string) => {\n say(`watch ended (${why}): start it again`);\n end(1);\n };\n\n /** Follows the channel from `cursor`, and again when the board comes back after going away. */\n const follow = (again: boolean) => {\n const started = Date.now();\n const [command, argv, options] = vbCommand(['tail', channel, ...labels, '--after', cursor, '--json']);\n const child = spawn(command, argv, { env: options.env, shell: options.shell, stdio: ['ignore', 'pipe', 'pipe'] });\n tail = child;\n createInterface({ input: child.stdout }).on('line', heardOf);\n // What it said as it ended goes in the watch's own line: a board started again refuses the old token, as expected,\n // and the CLI's raw error isn't something for an agent to act on.\n let said = '';\n child.stderr.on('data', (chunk: Buffer) => (said += chunk.toString()));\n // A dev server started again may start its board on another port: the tail would go on asking the old one for\n // ever, so it's ended once the project's `.deictic/board.json` names another, and followed there.\n const at = boardUrl();\n let moved: string | undefined;\n const elsewhere = setInterval(() => {\n const now = boardUrl();\n if (now === at || now === undefined) return;\n moved = now;\n child.kill();\n }, 3000);\n child.on('exit', (code) => {\n clearInterval(elsewhere);\n const reason = reasonOf(said);\n const why = moved === undefined ? `vb tail exited ${code}${reason === undefined ? '' : `: ${reason}`}` : `started again on ${moved}`;\n if (again && moved === undefined && Date.now() - started < SOON) return over(why);\n say(`the board went away (${why}): waiting for it to come back`);\n const until = Date.now() + BACK;\n const tried = () => {\n // Asked anew each time: a board started again may be at another URL, and the CLI gets itself a new token for it.\n if (answers()) {\n say(`the board is back on ${boardUrl() ?? \"the team's board\"}: watching ${channel} again`);\n // A board started anew (its folder cleaned) has no channel again.\n made();\n return follow(true);\n }\n if (Date.now() > until) return over(why);\n setTimeout(tried, 2000);\n };\n setTimeout(tried,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AAE,OAAO,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,QAAQ,OAAO;EAG3D,IAAI,OAAO;EACX,MAAM,OAAO,GAAG,SAAS,UAAmB,QAAQ,MAAM,SAAS,CAAE;EAGrE,MAAM,KAAK,SAAS;EACpB,IAAI;EACJ,MAAM,YAAY,kBAAkB;GAClC,MAAM,MAAM,SAAS;GACrB,IAAI,QAAQ,MAAM,QAAQ,KAAA,GAAW;GACrC,QAAQ;GACR,MAAM,KAAK;EACb,GAAG,GAAI;EACP,MAAM,GAAG,SAAS,SAAS;GACzB,cAAc,SAAS;GACvB,MAAM,SAAS,SAAS,IAAI;GAC5B,MAAM,MAAM,UAAU,KAAA,IAAY,kBAAkB,OAAO,WAAW,KAAA,IAAY,KAAK,KAAK,aAAa,oBAAoB;GAC7H,IAAI,SAAS,UAAU,KAAA,KAAa,KAAK,IAAI,IAAI,UAAU,MAAM,OAAO,KAAK,GAAG;GAChF,IAAI,wBAAwB,IAAI,+BAA+B;GAC/D,MAAM,QAAQ,KAAK,IAAI,IAAI;GAC3B,MAAM,cAAc;IAElB,IAAI,QAAQ,GAAG;KACb,IAAI,wBAAwB,SAAS,KAAK,mBAAmB,aAAa,QAAQ,OAAO;KAEzF,KAAK;KACL,OAAO,OAAO,IAAI;IACpB;IACA,IAAI,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,GAAG;IACvC,WAAW,OAAO,GAAI;GACxB;GACA,WAAW,OAAO,GAAI;EACxB,CAAC;CACH;CACA,OAAO,KAAK;AACd"}
|
package/dist/tailwind/index.js
CHANGED
|
@@ -367,7 +367,9 @@ function tailwind(options = {}) {
|
|
|
367
367
|
},
|
|
368
368
|
css: async (request, context) => Response.json({ css: (await catalog(context))?.css(await asked(request)) ?? "" })
|
|
369
369
|
},
|
|
370
|
-
read(
|
|
370
|
+
read(source) {
|
|
371
|
+
if (source instanceof Refusal) throw source;
|
|
372
|
+
const { code, element, program } = source;
|
|
371
373
|
const spot = spotOf(element, code, helpers);
|
|
372
374
|
if (spot.kind === "fixed") return {
|
|
373
375
|
editable: false,
|
|
@@ -384,7 +386,9 @@ function tailwind(options = {}) {
|
|
|
384
386
|
...others === void 0 ? {} : { others }
|
|
385
387
|
};
|
|
386
388
|
},
|
|
387
|
-
apply(
|
|
389
|
+
apply(source, _target, { classes, at }) {
|
|
390
|
+
if (source instanceof Refusal) throw source;
|
|
391
|
+
const { file, code, element, program } = source;
|
|
388
392
|
const list = classes.trim().split(/\s+/).filter(Boolean).join(" ");
|
|
389
393
|
const spot = spotOf(element, code, helpers);
|
|
390
394
|
if (spot.kind === "fixed") throw new Refusal("this class list is built at runtime: edit it in the editor");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/plugins/tailwind/catalog.ts","../../src/plugins/tailwind/index.ts"],"sourcesContent":["/**\n * What the project's Tailwind knows, for the panel: every class it can make (to complete what's typed), what\n * each one sets (a colour to show, a value to hint), the classes of the same kind (to switch between), and a\n * class's CSS (to preview one no file uses yet).\n *\n * All of it comes from Tailwind's own design system, loaded from the project (v4, through `@tailwindcss/node`,\n * which every v4 integration brings), so the theme is the project's. Two classes are of a kind when they set the\n * same properties: `text-sm` and `text-lg`, `flex` and `grid`, but not `text-sm` and `text-red-500`.\n */\nimport { readFileSync, statSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\n/** A class as the panel shows it. */\nexport interface ClassInfo {\n name: string;\n /** Whether Tailwind makes anything of it: a class of the project's own isn't known. */\n known: boolean;\n /** The colour it sets, as CSS. */\n color?: string;\n /** What it sets its main property to, theme values resolved: `0.875rem`. */\n value?: string;\n /** A variant to go on typing after (`hover:`), not a class. */\n variant?: true;\n}\n\n/** The classes of one kind, and how to write one with a value of the user's own. */\nexport interface Alternatives {\n /** The property the kind sets: `font-size`. */\n label: string;\n /** Whether the kind is a colour's, shown as swatches. */\n colors: boolean;\n items: ClassInfo[];\n /** A custom value goes between these: `md:text-[` and `]`. None for a kind that takes no value (`flex`). */\n custom?: { before: string; after: string; value?: string };\n}\n\nexport interface Catalog {\n /** Classes for what's typed, the best first: those starting with it, variants, then those holding it. */\n complete(query: string, limit?: number): ClassInfo[];\n info(classes: string[]): ClassInfo[];\n alternatives(name: string): Alternatives | undefined;\n /** CSS for the classes, in Tailwind's order, theme values written out: for a page whose build hasn't seen them. */\n css(classes: string[]): string;\n}\n\n/** The part of Tailwind's design system used here. Unstable there, so everything read from it is checked. */\ninterface DesignSystem {\n getClassList(): [string, { modifiers?: string[] }][];\n getVariants(): { name: string; values: string[]; hasDash: boolean }[];\n candidatesToCss(classes: string[]): (string | null)[];\n parseCandidate(candidate: string): Iterable<{ kind: string; root?: string; value?: { kind: string; value: string } | null }>;\n resolveThemeValue(path: string): string | undefined;\n getClassOrder(classes: string[]): [string, bigint | null][];\n}\n\ninterface Entry {\n name: string;\n /** The kind: the properties it sets, sorted. */\n kind: string;\n color?: string;\n value?: string;\n}\n\n/** Packages that depend on `@tailwindcss/node`, where the project doesn't itself. */\nconst VIA = ['@tailwindcss/vite', '@tailwindcss/postcss', '@tailwindcss/cli', '@tailwindcss/webpack'];\nconst MOST = 400;\nconst natural = new Intl.Collator('en', { numeric: true }).compare;\n\n/**\n * The catalog of the project at `root`, from its stylesheet (`css`, from the root: the one that imports\n * Tailwind and holds the theme), or from Tailwind's defaults without one. Read again when that file changes.\n * Rejects where the project has no Tailwind v4.\n */\nexport async function loadCatalog(root: string, css?: string): Promise<Catalog> {\n const { __unstable__loadDesignSystem: load } = await tailwindOf(root);\n const file = css === undefined ? undefined : resolve(root, css);\n const build = async () =>\n catalogOf(\n file === undefined\n ? await load('@import \"tailwindcss\";', { base: root })\n : await load(readFileSync(file, 'utf8'), { base: dirname(file) }),\n );\n const stamp = () => (file === undefined ? 0 : statSync(file).mtimeMs);\n let built = stamp();\n let current = await build();\n // The latest build, rebuilt when the stylesheet changed since. One that fails (a file half-saved) keeps the last.\n const latest = (): Catalog => {\n const now = stamp();\n if (now !== built) {\n built = now;\n void build().then(\n (next) => (current = next),\n () => {},\n );\n }\n return current;\n };\n return {\n complete: (query, limit) => latest().complete(query, limit),\n info: (classes) => latest().info(classes),\n alternatives: (name) => latest().alternatives(name),\n css: (classes) => latest().css(classes),\n };\n}\n\ntype Loader = (css: string, options: { base: string }) => Promise<DesignSystem>;\n\nasync function tailwindOf(root: string): Promise<{ __unstable__loadDesignSystem: Loader }> {\n const from = createRequire(join(root, 'package.json'));\n const found = [\n () => from.resolve('@tailwindcss/node'),\n ...VIA.map((via) => () => createRequire(from.resolve(via)).resolve('@tailwindcss/node')),\n ];\n for (const find of found) {\n let path: string;\n try {\n path = find();\n } catch {\n continue;\n }\n const module = (await import(pathToFileURL(path).href)) as { __unstable__loadDesignSystem?: Loader };\n if (typeof module.__unstable__loadDesignSystem === 'function')\n return { __unstable__loadDesignSystem: module.__unstable__loadDesignSystem };\n }\n throw new Error(`no Tailwind v4 in ${root}: install @tailwindcss/node there (or one of ${VIA.join(', ')})`);\n}\n\nexport function catalogOf(design: DesignSystem): Catalog {\n /** A value with the theme's variables written out, and what arithmetic is left done: `calc(var(--spacing) * 4)` is `1rem`. */\n const resolved = (value: string): string => {\n let now = value;\n for (let i = 0; i < 4; i++) {\n const next = now.replace(/var\\((--[\\w-]+)\\)/g, (all, name: string) => themed(name) ?? all);\n if (next === now) break;\n now = next;\n }\n return now.replace(/calc\\(([^()]+)\\)/g, (all, sum: string) => computed(sum) ?? all);\n };\n const themed = (name: string): string | undefined => {\n try {\n return design.resolveThemeValue(name) ?? undefined;\n } catch {\n return undefined;\n }\n };\n\n const entryOf = (name: string, css: string): Entry => {\n const set = declarations(css);\n const kind = [...new Set(set.map(([property]) => property))].toSorted().join(',');\n const color = set.findLast(([property, value]) => COLOR.test(property) && !NO_COLOR.test(value))?.[1];\n const main = (set.find(([property]) => !property.startsWith('--')) ?? set[0])?.[1];\n return {\n name,\n kind,\n ...(color === undefined ? {} : { color: resolved(color) }),\n ...(main === undefined ? {} : { value: resolved(main) }),\n };\n };\n\n const names = design\n .getClassList()\n .map(([name]) => name)\n .toSorted(natural);\n const modifiers = new Map(design.getClassList().map(([name, { modifiers = [] }]) => [name, modifiers]));\n const sheets = design.candidatesToCss(names);\n const byName = new Map<string, Entry>();\n const kinds = new Map<string, Entry[]>();\n names.forEach((name, i) => {\n const css = sheets[i];\n if (css === null || css === undefined) return;\n const entry = entryOf(name, css);\n if (entry.kind === '') return;\n byName.set(name, entry);\n const kind = kinds.get(entry.kind);\n if (kind === undefined) kinds.set(entry.kind, [entry]);\n else kind.push(entry);\n });\n for (const kind of kinds.values()) kind.sort(byValue(kind));\n\n const variants = design\n .getVariants()\n .flatMap(({ name, values, hasDash }) => [name, ...values.map((value) => `${name}${hasDash ? '-' : ''}${value}`)])\n // `*` and `**` are variants too, and so are those that only take a value in brackets: neither completes a word.\n .filter((name) => /^[@\\w]/.test(name))\n .toSorted(natural);\n\n /** A class Tailwind makes on asking, not in its list: one with a value in brackets, a modifier, a fraction. */\n const made = new Map<string, Entry | undefined>();\n const make = (body: string): Entry | undefined => {\n if (made.has(body)) return made.get(body);\n const css = design.candidatesToCss([body])[0];\n const entry = css === null || css === undefined ? undefined : entryOf(body, css);\n made.set(body, entry?.kind === '' ? undefined : entry);\n return made.get(body);\n };\n const rootOf = (body: string): string | undefined => {\n for (const candidate of design.parseCandidate(body))\n if (candidate.kind === 'functional' && candidate.root !== undefined && candidate.value) return candidate.root;\n return undefined;\n };\n /** The entry of a class's own part (no variants, no `!`), and the kind it's of among the listed ones. */\n const find = (body: string): { entry: Entry; kind: string } | undefined => {\n const listed = byName.get(body);\n if (listed !== undefined) return { entry: listed, kind: listed.kind };\n const entry = make(body);\n if (entry === undefined) return undefined;\n if (kinds.has(entry.kind)) return { entry, kind: entry.kind };\n // `text-[13px]` sets the size alone, `text-sm` the line height too: the kind is the nearest one of its root's.\n const root = rootOf(body);\n if (root === undefined) return { entry, kind: entry.kind };\n const own = new Set(entry.kind.split(','));\n let best: { kind: string; shared: number } | undefined;\n for (const name of names) {\n if (!name.startsWith(`${root}-`)) continue;\n const kind = byName.get(name)?.kind;\n if (kind === undefined || kind === best?.kind) continue;\n const shared = kind.split(',').filter((property) => own.has(property)).length;\n if (shared > (best?.shared ?? 0)) best = { kind, shared };\n }\n return { entry, kind: best?.kind ?? entry.kind };\n };\n const shown = (name: string, entry: Entry): ClassInfo => ({\n name,\n known: true,\n ...(entry.color === undefined ? {} : { color: entry.color }),\n ...(entry.value === undefined ? {} : { value: entry.value }),\n });\n const info = (name: string): ClassInfo => {\n const found = find(parts(name).body);\n return found === undefined ? { name, known: false } : shown(name, found.entry);\n };\n\n return {\n complete(query, limit = 40) {\n const { before: variantsBefore, bang, body, after } = parts(query.trim());\n if (body === '' && variantsBefore === '') return [];\n const before = `${variantsBefore}${bang}`;\n const starts: ClassInfo[] = [];\n const holds: ClassInfo[] = [];\n const add = (to: ClassInfo[], name: string, entry: Entry) => {\n if (to.length < limit) to.push(shown(`${before}${name}${after}`, entry));\n };\n const exact = byName.get(body);\n if (exact !== undefined) add(starts, body, exact);\n for (const name of names) {\n if (starts.length >= limit) break;\n if (name === body) continue;\n const entry = byName.get(name);\n if (entry === undefined) continue;\n if (name.startsWith(body)) add(starts, name, entry);\n else if (body.length > 1 && name.includes(body)) add(holds, name, entry);\n }\n // `bg-red-500/`: the modifiers the class takes.\n const slash = body.lastIndexOf('/');\n const base = slash < 0 ? undefined : byName.get(body.slice(0, slash));\n const modified =\n base === undefined || starts.length > 0\n ? []\n : (modifiers.get(base.name) ?? [])\n .filter((modifier) => modifier.startsWith(body.slice(slash + 1)))\n .map((modifier) => shown(`${before}${base.name}/${modifier}${after}`, make(`${base.name}/${modifier}`) ?? base));\n const ahead =\n after !== '' || bang !== '' || body === ''\n ? []\n : variants\n .filter((name) => name.startsWith(body))\n .map((name): ClassInfo => ({ name: `${before}${name}:`, known: true, variant: true }));\n return [...starts, ...modified, ...ahead, ...holds].slice(0, limit);\n },\n info: (classes) => classes.map(info),\n alternatives(name) {\n const { before, bang, body, after } = parts(name);\n const found = find(body);\n if (found === undefined) return undefined;\n const { modifier, base } = modified(body, byName);\n const kind = kinds.get(found.kind) ?? [];\n const properties = found.kind.split(',');\n const root = rootOf(body);\n const value = [...design.parseCandidate(body)].find((candidate) => candidate.value?.kind === 'arbitrary')?.value?.value;\n const items = kind.slice(0, MOST).map((entry) => shown(`${before}${bang}${entry.name}${modifier}${after}`, entry));\n // The class itself where it isn't listed (its value is its own), so the panel has it to show as chosen.\n if (!kind.some((entry) => entry.name === base)) items.unshift(shown(name, found.entry));\n return {\n label: properties.find((property) => !property.startsWith('--')) ?? properties[0]!,\n colors: kind.filter((entry) => entry.color !== undefined).length * 2 > kind.length,\n items,\n ...(root === undefined\n ? {}\n : { custom: { before: `${before}${bang}${root}-[`, after: `]${modifier}${after}`, ...(value === undefined ? {} : { value }) } }),\n };\n },\n css(classes) {\n const bodies = [...new Set(classes)];\n const order = new Map(design.getClassOrder(bodies));\n bodies.sort((a, b) => {\n const [x, y] = [order.get(a) ?? null, order.get(b) ?? null];\n if (x === null || y === null) return x === y ? 0 : x === null ? 1 : -1;\n return x < y ? -1 : x > y ? 1 : 0;\n });\n const properties = new Set<string>();\n const rules = design\n .candidatesToCss(bodies)\n .filter((css) => css !== null && css !== undefined)\n // `@property` can't sit in a layer, so each is lifted out, once.\n .map((css) =>\n css.replace(PROPERTY, (rule) => {\n properties.add(rule.trim());\n return '';\n }),\n )\n .join('');\n if (rules.trim() === '') return '';\n // In the layer the page's own utilities are in, so what beats them there (the page's unlayered CSS) beats these.\n return `${[...properties].join('\\n')}\\n@layer utilities {\\n${rules.replace(/var\\((--[\\w-]+)\\)/g, (all, name: string) => themed(name) ?? all)}}\\n`;\n },\n };\n}\n\nconst COLOR = /(^|-)color$|^fill$|^stroke$|^--tw-gradient-(from|via|to)$/;\nconst NO_COLOR = /^(inherit|none|initial|unset)$/;\nconst PROPERTY = /@property [^{]+\\{[^}]*\\}\\n?/g;\n\n/** A rule's declarations, in order, from Tailwind's CSS for one class: one a line, `@property` rules after. */\nfunction declarations(css: string): [property: string, value: string][] {\n const rules = css.replace(PROPERTY, '');\n return [...rules.matchAll(/^\\s+(-{0,2}[\\w-]+):\\s*(.+?)(?:\\s*!important)?;$/gm)].map((match) => [match[1]!, match[2]!]);\n}\n\n/** `0.25rem * 4` as `1rem`: products and quotients of numbers with one unit between them. Anything else is left. */\nfunction computed(sum: string): string | undefined {\n const tokens = sum.trim().split(/\\s+/);\n let total = 1;\n let unit = '';\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i]!;\n if (i % 2 === 1) {\n if (token !== '*' && token !== '/') return undefined;\n continue;\n }\n const match = /^(-?(?:\\d+\\.?\\d*|\\.\\d+))(%|[a-z]+)?$/.exec(token);\n if (match === null) return undefined;\n const divides = tokens[i - 1] === '/';\n if (match[2] !== undefined && (unit !== '' || divides)) return undefined;\n unit = match[2] ?? unit;\n total = divides ? total / Number(match[1]) : total * Number(match[1]);\n }\n if (tokens.length % 2 === 0 || !Number.isFinite(total)) return undefined;\n return `${Number(total.toFixed(4))}${unit}`;\n}\n\n/** A length as a number to order by, where the value is one: `1rem` is 16. */\nfunction measure(value: string | undefined): number | undefined {\n const match = value === undefined ? null : /^(-?(?:\\d+\\.?\\d*|\\.\\d+))(px|rem|em|%)?$/.exec(value);\n if (match === null) return undefined;\n return Number(match[1]) * (match[2] === 'rem' || match[2] === 'em' ? 16 : 1);\n}\n\n/** A kind's order: by size where most of it has one (`text-xs` before `text-sm`), by name else, as it already is. */\nfunction byValue(kind: Entry[]): (a: Entry, b: Entry) => number {\n const sizes = new Map(kind.map((entry) => [entry, measure(entry.value)]));\n const sized = [...sizes.values()].filter((size) => size !== undefined).length;\n if (sized * 10 < kind.length * 7) return () => 0;\n return (a, b) => {\n const [x, y] = [sizes.get(a), sizes.get(b)];\n if (x === undefined || y === undefined) return x === y ? 0 : x === undefined ? 1 : -1;\n return x - y;\n };\n}\n\n/**\n * A class as written, apart: its variants (`md:hover:`), `!` where it leads, its own part, and `!` where it\n * trails. A `:` inside brackets or parentheses is the value's.\n */\nfunction parts(name: string): { before: string; bang: string; body: string; after: string } {\n let depth = 0;\n let cut = 0;\n for (let i = 0; i < name.length; i++) {\n const char = name[i]!;\n if (char === '[' || char === '(') depth++;\n else if (char === ']' || char === ')') depth--;\n else if (char === ':' && depth === 0) cut = i + 1;\n }\n const own = name.slice(cut);\n const bang = own.startsWith('!') ? '!' : '';\n const after = !bang && own.endsWith('!') ? '!' : '';\n return { before: name.slice(0, cut), bang, body: own.slice(bang.length, own.length - after.length), after };\n}\n\n/** A class's modifier (`/50`) and what it's on, where the whole isn't a class itself, as `w-1/2` is. */\nfunction modified(body: string, listed: Map<string, unknown>): { base: string; modifier: string } {\n const slash = body.lastIndexOf('/');\n if (listed.has(body) || slash < 0 || body.indexOf(']', slash) >= 0) return { base: body, modifier: '' };\n return { base: body.slice(0, slash), modifier: body.slice(slash) };\n}\n","/**\n * `deictic/tailwind`: open its tab on an element to edit its classes, written to its `className`.\n *\n * Only a list the source spells out can be edited: `className=\"…\"`, `className={'…'}`, a template\n * with no `${}`, or the first argument of a class helper (`cn('…', active && '…')`), whose other\n * arguments stay as they are. A list built any other way is shown, not edited, since there is no one\n * place for a class to go. An element without the attribute gets one.\n *\n * Its routes answer the panel from the project's own Tailwind (`catalog.ts`): what completes a word typed\n * (`complete`), what each class sets (`info`), the classes of a class's kind (`alternatives`) and the CSS of\n * classes the page's build hasn't seen (`css`). Without Tailwind v4 they answer nothing, and the panel is plain.\n */\nimport type { Argument, Expression, JSXAttribute, JSXOpeningElement, Program } from 'oxc-parser';\n\nimport { definePlugin, Refusal, type ServerContext, type Shortcut } from '#src/index.ts';\n\nimport { type Catalog, loadCatalog } from './catalog.ts';\n\nexport type { Alternatives, ClassInfo } from './catalog.ts';\n\nexport interface TailwindOptions {\n /** Calls whose first argument is a class list: `cn`, `clsx`, `cx`, `twMerge`, `classNames` by default. */\n helpers?: string[];\n /** The attribute an element without one gets: `className`, or `class` for Solid and Preact. */\n attribute?: 'className' | 'class';\n /**\n * The stylesheet that imports Tailwind and holds the theme, from the project's root: `src/index.css`. What\n * the panel completes and shows comes from it. Tailwind's default theme without one.\n */\n css?: string;\n /** What opens its tab directly, beside deictic's own shortcut, which opens any: none by default. */\n shortcut?: Shortcut;\n}\n\nexport type Model =\n | {\n editable: true;\n classes: string;\n /** The helper's other arguments, which add classes at runtime, each read as far as the source says. */\n others?: Extra[];\n }\n | { editable: false; source: string };\n\n/** Classes a helper's argument adds: `active && 'ring'` is `ring` when `active`. */\nexport interface Extra {\n /** The argument, or the part of it these classes come from, as written. */\n source: string;\n /** The classes, where the source spells them out: there, or in a `const` of the file it names. */\n classes?: string;\n /** What must hold for them to be added, as written: `active === 'h3'`. None where they always are. */\n when?: string;\n /** Set where the classes are a string in this file, which an op with `at` can write. */\n editable?: true;\n /** The `const` the string is in, where it isn't the argument itself: other elements may use it too. */\n shared?: string;\n}\n\nexport interface Op {\n classes: string;\n /** Which of the model's `others` the classes are for, by its place there. The element's own list without. */\n at?: number;\n}\n\n/** Where a class list sits in the source: the text between its quotes, or where a missing attribute goes. */\ntype List = { kind: 'list'; start: number; end: number; quote: string; others?: Argument[] };\ntype Spot = List | { kind: 'missing'; at: number } | { kind: 'fixed'; source: string };\n\nconst HELPERS = ['cn', 'clsx', 'cx', 'twMerge', 'classNames'];\n\nexport function tailwind(options: TailwindOptions = {}) {\n const helpers = new Set(options.helpers ?? HELPERS);\n const attribute = options.attribute ?? 'className';\n // Loaded on the first ask, as it takes a moment, and once: a project without Tailwind v4 has none.\n let loading: Promise<Catalog | undefined> | undefined;\n const catalog = ({ root }: ServerContext) =>\n (loading ??= loadCatalog(root, options.css).catch((problem: unknown) => {\n console.warn(`deictic/tailwind: no completions or class details, as ${problem instanceof Error ? problem.message : String(problem)}`);\n return undefined;\n }));\n const asked = async (request: Request): Promise<string[]> => {\n const body = (await request.json().catch(() => undefined)) as { classes?: unknown } | undefined;\n return Array.isArray(body?.classes) ? body.classes.filter((c): c is string => typeof c === 'string').slice(0, 500) : [];\n };\n return definePlugin<Model, Op>({\n name: 'tailwind',\n client: 'deictic/tailwind/client',\n shortcut: options.shortcut,\n routes: {\n // `complete?q=fle`: the classes for a word being typed.\n complete: async (request, context) => {\n const query = new URL(request.url).searchParams.get('q') ?? '';\n return Response.json({ items: (await catalog(context))?.complete(query) ?? [] });\n },\n // What each of `classes` sets. `available` is false where there's no catalog, so the panel stops asking.\n info: async (request, context) => {\n const known = await catalog(context);\n return Response.json({ available: known !== undefined, items: known?.info(await asked(request)) ?? [] });\n },\n // `alternatives?class=text-sm`: the classes of its kind, or nothing for one Tailwind doesn't know.\n alternatives: async (request, context) => {\n const name = new URL(request.url).searchParams.get('class') ?? '';\n return Response.json((await catalog(context))?.alternatives(name) ?? null);\n },\n css: async (request, context) => Response.json({ css: (await catalog(context))?.css(await asked(request)) ?? '' }),\n },\n read({ code, element, program }) {\n const spot = spotOf(element, code, helpers);\n if (spot.kind === 'fixed') return { editable: false, source: spot.source };\n if (spot.kind === 'missing') return { editable: true, classes: '' };\n const others = spot.others?.flatMap((argument) => extrasOf(argument, code, program)).map(({ spot: _, ...extra }) => extra);\n return { editable: true, classes: code.slice(spot.start, spot.end), ...(others === undefined ? {} : { others }) };\n },\n apply({ file, code, element, program }, _target, { classes, at }) {\n const list = classes.trim().split(/\\s+/).filter(Boolean).join(' ');\n const spot = spotOf(element, code, helpers);\n if (spot.kind === 'fixed') throw new Refusal('this class list is built at runtime: edit it in the editor');\n if (at !== undefined) {\n const others = spot.kind === 'list' ? (spot.others ?? []).flatMap((argument) => extrasOf(argument, code, program)) : [];\n const place = others[at]?.spot;\n if (place === undefined)\n throw new Refusal(\"these classes aren't a string in this file any more: reload, or edit them in the editor\");\n return [{ start: place.start, end: place.end, text: quoted(list, place.quote) }];\n }\n // An `.astro` component writes `class`, whatever the JSX beside it does.\n const name = file.endsWith('.astro') ? 'class' : attribute;\n if (spot.kind === 'missing') return list === '' ? [] : [{ start: spot.at, end: spot.at, text: ` ${name}=\"${quoted(list, '\"')}\"` }];\n return [{ start: spot.start, end: spot.end, text: quoted(list, spot.quote) }];\n },\n describe({ classes, at }, before) {\n if (!before.editable) return 'classes';\n if (at === undefined) return diff(before.classes, classes);\n const other = before.others?.[at];\n return `${diff(other?.classes ?? '', classes)}${other?.when === undefined ? '' : ` when ${other.when}`}`;\n },\n });\n}\n\nfunction spotOf(element: JSXOpeningElement, code: string, helpers: Set<string>): Spot {\n const attr = element.attributes.find(\n (a): a is JSXAttribute =>\n a.type === 'JSXAttribute' && a.name.type === 'JSXIdentifier' && (a.name.name === 'className' || a.name.name === 'class'),\n );\n if (attr === undefined) {\n // Astro's `class:list` is the element's class list too: a `class` beside it would be a second one.\n const listed = element.attributes.find(\n (a) => a.type === 'JSXAttribute' && a.name.type === 'JSXIdentifier' && a.name.name === 'class:list',\n );\n return listed === undefined\n ? { kind: 'missing', at: element.name.end }\n : { kind: 'fixed', source: code.slice(listed.start, listed.end) };\n }\n const { value } = attr;\n if (value?.type === 'Literal') return list(value, code);\n if (value?.type !== 'JSXExpressionContainer' || value.expression.type === 'JSXEmptyExpression')\n return { kind: 'fixed', source: code.slice(attr.start, attr.end) };\n const e = value.expression;\n const whole = listIn(e, code);\n if (whole !== undefined) return whole;\n if (e.type === 'CallExpression' && e.callee.type === 'Identifier' && helpers.has(e.callee.name)) {\n const [first, ...others] = e.arguments;\n const head = first === undefined || first.type === 'SpreadElement' ? undefined : listIn(first, code);\n if (head !== undefined) return others.length === 0 ? head : { ...head, others };\n }\n return { kind: 'fixed', source: code.slice(attr.start, attr.end) };\n}\n\n/**\n * What one of a helper's arguments adds, and when: `on && 'ring'`, `on ? 'a' : 'b'`, `{ ring: on }`, a string,\n * or a name for one. Anything else is only its source, as nothing says what it adds.\n */\nfunction extrasOf(argument: Argument, code: string, program: Program): (Extra & { spot?: List })[] {\n const source = (node: { start: number; end: number }) => code.slice(node.start, node.end);\n const added = (e: { type: string; start: number; end: number }, when?: string, key = false): Extra & { spot?: List } => {\n const found = stringOf(e, program, !key);\n if (found === undefined) return { source: source(e), ...(when === undefined ? {} : { when }) };\n return {\n source: source(e),\n classes: found.value,\n ...(when === undefined ? {} : { when }),\n editable: true,\n ...(found.shared === undefined ? {} : { shared: found.shared }),\n spot: list(found.node, code),\n };\n };\n const e = argument;\n if (e.type === 'SpreadElement') return [{ source: source(e) }];\n if (e.type === 'LogicalExpression' && e.operator === '&&') return [added(e.right, source(e.left))];\n if (e.type === 'ConditionalExpression') {\n const test = source(e.test);\n const not = e.test.type === 'Identifier' ? `!${test}` : `!(${test})`;\n // A branch that adds nothing (`on ? 'ring' : undefined`) isn't one to show.\n return [added(e.consequent, test), added(e.alternate, not)].filter(\n (extra) => extra.classes !== '' && !/^(undefined|null|false)$/.test(extra.source),\n );\n }\n if (e.type === 'ObjectExpression') {\n return e.properties.map((property): Extra & { spot?: List } => {\n if (property.type !== 'Property' || property.computed) return { source: source(property) };\n const always = property.value.type === 'Literal' && property.value.value === true;\n const when = always ? {} : { when: source(property.value) };\n // A bare key (`ring`) is a class, but not a string to write a list into.\n if (property.key.type === 'Identifier') return { source: source(property), classes: property.key.name, ...when };\n const { source: _, ...key } = added(property.key, undefined, true);\n return key.classes === undefined ? { source: source(property) } : { source: source(property), ...key, ...when };\n });\n }\n return [added(e)];\n}\n\n/**\n * A string the source spells out, and where: a literal, a template with nothing interpolated, or a top-level\n * `const` of one (`shared`, its name).\n */\nfunction stringOf(\n e: { type: string },\n program: Program,\n named = true,\n): { value: string; node: { start: number; end: number }; shared?: string } | undefined {\n const node = e as Expression;\n if (node.type === 'Literal') return typeof node.value === 'string' ? { value: node.value, node } : undefined;\n if (node.type === 'TemplateLiteral') {\n const value = node.expressions.length === 0 ? node.quasis[0]?.value.cooked : undefined;\n return value === undefined || value === null ? undefined : { value, node };\n }\n if (node.type !== 'Identifier' || !named) return undefined;\n for (const statement of program.body) {\n const declared = statement.type === 'ExportNamedDeclaration' ? statement.declaration : statement;\n if (declared?.type !== 'VariableDeclaration' || declared.kind !== 'const') continue;\n for (const { id, init } of declared.declarations) {\n if (id.type !== 'Identifier' || id.name !== node.name || !init) continue;\n const found = stringOf(init, program, false);\n return found === undefined ? undefined : { ...found, shared: node.name };\n }\n }\n return undefined;\n}\n\n/** A string literal or a template with nothing interpolated, as the text between its quotes. */\nfunction listIn(e: Expression, code: string): List | undefined {\n if (e.type === 'Literal' && typeof e.value === 'string') return list(e, code);\n if (e.type === 'TemplateLiteral' && e.expressions.length === 0) return list(e, code);\n return undefined;\n}\n\nconst list = (node: { start: number; end: number }, code: string): List => ({\n kind: 'list',\n start: node.start + 1,\n end: node.end - 1,\n quote: code[node.start]!,\n});\n\n/** The list as it may sit between `quote`s. A JSX attribute has no escapes, so a quote of its own kind can't. */\nfunction quoted(list: string, quote: string): string {\n if (quote === '`') return list.replaceAll('\\\\', '\\\\\\\\').replaceAll('`', '\\\\`').replaceAll('${', '\\\\${');\n if (!list.includes(quote)) return list;\n throw new Refusal(`a class can't hold ${quote} here: use the other quote inside arbitrary values, as in content-['…']`);\n}\n\n/** What changed between two lists: `+ring -px-2`. */\nfunction diff(before: string, after: string): string {\n const was = new Set(before.split(/\\s+/).filter(Boolean));\n const now = new Set(after.split(/\\s+/).filter(Boolean));\n const parts = [...[...now].filter((c) => !was.has(c)).map((c) => `+${c}`), ...[...was].filter((c) => !now.has(c)).map((c) => `-${c}`)];\n return parts.length > 0 ? parts.join(' ') : 'reordered classes';\n}\n\nexport default tailwind;\n"],"mappings":";;;;;;;;;;;;;;;;AAkEA,MAAM,MAAM;CAAC;CAAqB;CAAwB;CAAoB;AAAsB;AACpG,MAAM,OAAO;AACb,MAAM,UAAU,IAAI,KAAK,SAAS,MAAM,EAAE,SAAS,KAAK,CAAC,CAAC,CAAC;;;;;;AAO3D,eAAsB,YAAY,MAAc,KAAgC;CAC9E,MAAM,EAAE,8BAA8B,SAAS,MAAM,WAAW,IAAI;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AO,OAAO,CAAC;CACvD,MAAM,MAAM,IAAI,IAAI,MAAM,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO,CAAC;CACtD,MAAM,QAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,QAAQ,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,QAAQ,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,IAAI,GAAG,CAAC;CACrI,OAAO,MAAM,SAAS,IAAI,MAAM,KAAK,GAAG,IAAI;AAC9C"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/plugins/tailwind/catalog.ts","../../src/plugins/tailwind/index.ts"],"sourcesContent":["/**\n * What the project's Tailwind knows, for the panel: every class it can make (to complete what's typed), what\n * each one sets (a colour to show, a value to hint), the classes of the same kind (to switch between), and a\n * class's CSS (to preview one no file uses yet).\n *\n * All of it comes from Tailwind's own design system, loaded from the project (v4, through `@tailwindcss/node`,\n * which every v4 integration brings), so the theme is the project's. Two classes are of a kind when they set the\n * same properties: `text-sm` and `text-lg`, `flex` and `grid`, but not `text-sm` and `text-red-500`.\n */\nimport { readFileSync, statSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\n/** A class as the panel shows it. */\nexport interface ClassInfo {\n name: string;\n /** Whether Tailwind makes anything of it: a class of the project's own isn't known. */\n known: boolean;\n /** The colour it sets, as CSS. */\n color?: string;\n /** What it sets its main property to, theme values resolved: `0.875rem`. */\n value?: string;\n /** A variant to go on typing after (`hover:`), not a class. */\n variant?: true;\n}\n\n/** The classes of one kind, and how to write one with a value of the user's own. */\nexport interface Alternatives {\n /** The property the kind sets: `font-size`. */\n label: string;\n /** Whether the kind is a colour's, shown as swatches. */\n colors: boolean;\n items: ClassInfo[];\n /** A custom value goes between these: `md:text-[` and `]`. None for a kind that takes no value (`flex`). */\n custom?: { before: string; after: string; value?: string };\n}\n\nexport interface Catalog {\n /** Classes for what's typed, the best first: those starting with it, variants, then those holding it. */\n complete(query: string, limit?: number): ClassInfo[];\n info(classes: string[]): ClassInfo[];\n alternatives(name: string): Alternatives | undefined;\n /** CSS for the classes, in Tailwind's order, theme values written out: for a page whose build hasn't seen them. */\n css(classes: string[]): string;\n}\n\n/** The part of Tailwind's design system used here. Unstable there, so everything read from it is checked. */\ninterface DesignSystem {\n getClassList(): [string, { modifiers?: string[] }][];\n getVariants(): { name: string; values: string[]; hasDash: boolean }[];\n candidatesToCss(classes: string[]): (string | null)[];\n parseCandidate(candidate: string): Iterable<{ kind: string; root?: string; value?: { kind: string; value: string } | null }>;\n resolveThemeValue(path: string): string | undefined;\n getClassOrder(classes: string[]): [string, bigint | null][];\n}\n\ninterface Entry {\n name: string;\n /** The kind: the properties it sets, sorted. */\n kind: string;\n color?: string;\n value?: string;\n}\n\n/** Packages that depend on `@tailwindcss/node`, where the project doesn't itself. */\nconst VIA = ['@tailwindcss/vite', '@tailwindcss/postcss', '@tailwindcss/cli', '@tailwindcss/webpack'];\nconst MOST = 400;\nconst natural = new Intl.Collator('en', { numeric: true }).compare;\n\n/**\n * The catalog of the project at `root`, from its stylesheet (`css`, from the root: the one that imports\n * Tailwind and holds the theme), or from Tailwind's defaults without one. Read again when that file changes.\n * Rejects where the project has no Tailwind v4.\n */\nexport async function loadCatalog(root: string, css?: string): Promise<Catalog> {\n const { __unstable__loadDesignSystem: load } = await tailwindOf(root);\n const file = css === undefined ? undefined : resolve(root, css);\n const build = async () =>\n catalogOf(\n file === undefined\n ? await load('@import \"tailwindcss\";', { base: root })\n : await load(readFileSync(file, 'utf8'), { base: dirname(file) }),\n );\n const stamp = () => (file === undefined ? 0 : statSync(file).mtimeMs);\n let built = stamp();\n let current = await build();\n // The latest build, rebuilt when the stylesheet changed since. One that fails (a file half-saved) keeps the last.\n const latest = (): Catalog => {\n const now = stamp();\n if (now !== built) {\n built = now;\n void build().then(\n (next) => (current = next),\n () => {},\n );\n }\n return current;\n };\n return {\n complete: (query, limit) => latest().complete(query, limit),\n info: (classes) => latest().info(classes),\n alternatives: (name) => latest().alternatives(name),\n css: (classes) => latest().css(classes),\n };\n}\n\ntype Loader = (css: string, options: { base: string }) => Promise<DesignSystem>;\n\nasync function tailwindOf(root: string): Promise<{ __unstable__loadDesignSystem: Loader }> {\n const from = createRequire(join(root, 'package.json'));\n const found = [\n () => from.resolve('@tailwindcss/node'),\n ...VIA.map((via) => () => createRequire(from.resolve(via)).resolve('@tailwindcss/node')),\n ];\n for (const find of found) {\n let path: string;\n try {\n path = find();\n } catch {\n continue;\n }\n const module = (await import(pathToFileURL(path).href)) as { __unstable__loadDesignSystem?: Loader };\n if (typeof module.__unstable__loadDesignSystem === 'function')\n return { __unstable__loadDesignSystem: module.__unstable__loadDesignSystem };\n }\n throw new Error(`no Tailwind v4 in ${root}: install @tailwindcss/node there (or one of ${VIA.join(', ')})`);\n}\n\nexport function catalogOf(design: DesignSystem): Catalog {\n /** A value with the theme's variables written out, and what arithmetic is left done: `calc(var(--spacing) * 4)` is `1rem`. */\n const resolved = (value: string): string => {\n let now = value;\n for (let i = 0; i < 4; i++) {\n const next = now.replace(/var\\((--[\\w-]+)\\)/g, (all, name: string) => themed(name) ?? all);\n if (next === now) break;\n now = next;\n }\n return now.replace(/calc\\(([^()]+)\\)/g, (all, sum: string) => computed(sum) ?? all);\n };\n const themed = (name: string): string | undefined => {\n try {\n return design.resolveThemeValue(name) ?? undefined;\n } catch {\n return undefined;\n }\n };\n\n const entryOf = (name: string, css: string): Entry => {\n const set = declarations(css);\n const kind = [...new Set(set.map(([property]) => property))].toSorted().join(',');\n const color = set.findLast(([property, value]) => COLOR.test(property) && !NO_COLOR.test(value))?.[1];\n const main = (set.find(([property]) => !property.startsWith('--')) ?? set[0])?.[1];\n return {\n name,\n kind,\n ...(color === undefined ? {} : { color: resolved(color) }),\n ...(main === undefined ? {} : { value: resolved(main) }),\n };\n };\n\n const names = design\n .getClassList()\n .map(([name]) => name)\n .toSorted(natural);\n const modifiers = new Map(design.getClassList().map(([name, { modifiers = [] }]) => [name, modifiers]));\n const sheets = design.candidatesToCss(names);\n const byName = new Map<string, Entry>();\n const kinds = new Map<string, Entry[]>();\n names.forEach((name, i) => {\n const css = sheets[i];\n if (css === null || css === undefined) return;\n const entry = entryOf(name, css);\n if (entry.kind === '') return;\n byName.set(name, entry);\n const kind = kinds.get(entry.kind);\n if (kind === undefined) kinds.set(entry.kind, [entry]);\n else kind.push(entry);\n });\n for (const kind of kinds.values()) kind.sort(byValue(kind));\n\n const variants = design\n .getVariants()\n .flatMap(({ name, values, hasDash }) => [name, ...values.map((value) => `${name}${hasDash ? '-' : ''}${value}`)])\n // `*` and `**` are variants too, and so are those that only take a value in brackets: neither completes a word.\n .filter((name) => /^[@\\w]/.test(name))\n .toSorted(natural);\n\n /** A class Tailwind makes on asking, not in its list: one with a value in brackets, a modifier, a fraction. */\n const made = new Map<string, Entry | undefined>();\n const make = (body: string): Entry | undefined => {\n if (made.has(body)) return made.get(body);\n const css = design.candidatesToCss([body])[0];\n const entry = css === null || css === undefined ? undefined : entryOf(body, css);\n made.set(body, entry?.kind === '' ? undefined : entry);\n return made.get(body);\n };\n const rootOf = (body: string): string | undefined => {\n for (const candidate of design.parseCandidate(body))\n if (candidate.kind === 'functional' && candidate.root !== undefined && candidate.value) return candidate.root;\n return undefined;\n };\n /** The entry of a class's own part (no variants, no `!`), and the kind it's of among the listed ones. */\n const find = (body: string): { entry: Entry; kind: string } | undefined => {\n const listed = byName.get(body);\n if (listed !== undefined) return { entry: listed, kind: listed.kind };\n const entry = make(body);\n if (entry === undefined) return undefined;\n if (kinds.has(entry.kind)) return { entry, kind: entry.kind };\n // `text-[13px]` sets the size alone, `text-sm` the line height too: the kind is the nearest one of its root's.\n const root = rootOf(body);\n if (root === undefined) return { entry, kind: entry.kind };\n const own = new Set(entry.kind.split(','));\n let best: { kind: string; shared: number } | undefined;\n for (const name of names) {\n if (!name.startsWith(`${root}-`)) continue;\n const kind = byName.get(name)?.kind;\n if (kind === undefined || kind === best?.kind) continue;\n const shared = kind.split(',').filter((property) => own.has(property)).length;\n if (shared > (best?.shared ?? 0)) best = { kind, shared };\n }\n return { entry, kind: best?.kind ?? entry.kind };\n };\n const shown = (name: string, entry: Entry): ClassInfo => ({\n name,\n known: true,\n ...(entry.color === undefined ? {} : { color: entry.color }),\n ...(entry.value === undefined ? {} : { value: entry.value }),\n });\n const info = (name: string): ClassInfo => {\n const found = find(parts(name).body);\n return found === undefined ? { name, known: false } : shown(name, found.entry);\n };\n\n return {\n complete(query, limit = 40) {\n const { before: variantsBefore, bang, body, after } = parts(query.trim());\n if (body === '' && variantsBefore === '') return [];\n const before = `${variantsBefore}${bang}`;\n const starts: ClassInfo[] = [];\n const holds: ClassInfo[] = [];\n const add = (to: ClassInfo[], name: string, entry: Entry) => {\n if (to.length < limit) to.push(shown(`${before}${name}${after}`, entry));\n };\n const exact = byName.get(body);\n if (exact !== undefined) add(starts, body, exact);\n for (const name of names) {\n if (starts.length >= limit) break;\n if (name === body) continue;\n const entry = byName.get(name);\n if (entry === undefined) continue;\n if (name.startsWith(body)) add(starts, name, entry);\n else if (body.length > 1 && name.includes(body)) add(holds, name, entry);\n }\n // `bg-red-500/`: the modifiers the class takes.\n const slash = body.lastIndexOf('/');\n const base = slash < 0 ? undefined : byName.get(body.slice(0, slash));\n const modified =\n base === undefined || starts.length > 0\n ? []\n : (modifiers.get(base.name) ?? [])\n .filter((modifier) => modifier.startsWith(body.slice(slash + 1)))\n .map((modifier) => shown(`${before}${base.name}/${modifier}${after}`, make(`${base.name}/${modifier}`) ?? base));\n const ahead =\n after !== '' || bang !== '' || body === ''\n ? []\n : variants\n .filter((name) => name.startsWith(body))\n .map((name): ClassInfo => ({ name: `${before}${name}:`, known: true, variant: true }));\n return [...starts, ...modified, ...ahead, ...holds].slice(0, limit);\n },\n info: (classes) => classes.map(info),\n alternatives(name) {\n const { before, bang, body, after } = parts(name);\n const found = find(body);\n if (found === undefined) return undefined;\n const { modifier, base } = modified(body, byName);\n const kind = kinds.get(found.kind) ?? [];\n const properties = found.kind.split(',');\n const root = rootOf(body);\n const value = [...design.parseCandidate(body)].find((candidate) => candidate.value?.kind === 'arbitrary')?.value?.value;\n const items = kind.slice(0, MOST).map((entry) => shown(`${before}${bang}${entry.name}${modifier}${after}`, entry));\n // The class itself where it isn't listed (its value is its own), so the panel has it to show as chosen.\n if (!kind.some((entry) => entry.name === base)) items.unshift(shown(name, found.entry));\n return {\n label: properties.find((property) => !property.startsWith('--')) ?? properties[0]!,\n colors: kind.filter((entry) => entry.color !== undefined).length * 2 > kind.length,\n items,\n ...(root === undefined\n ? {}\n : { custom: { before: `${before}${bang}${root}-[`, after: `]${modifier}${after}`, ...(value === undefined ? {} : { value }) } }),\n };\n },\n css(classes) {\n const bodies = [...new Set(classes)];\n const order = new Map(design.getClassOrder(bodies));\n bodies.sort((a, b) => {\n const [x, y] = [order.get(a) ?? null, order.get(b) ?? null];\n if (x === null || y === null) return x === y ? 0 : x === null ? 1 : -1;\n return x < y ? -1 : x > y ? 1 : 0;\n });\n const properties = new Set<string>();\n const rules = design\n .candidatesToCss(bodies)\n .filter((css) => css !== null && css !== undefined)\n // `@property` can't sit in a layer, so each is lifted out, once.\n .map((css) =>\n css.replace(PROPERTY, (rule) => {\n properties.add(rule.trim());\n return '';\n }),\n )\n .join('');\n if (rules.trim() === '') return '';\n // In the layer the page's own utilities are in, so what beats them there (the page's unlayered CSS) beats these.\n return `${[...properties].join('\\n')}\\n@layer utilities {\\n${rules.replace(/var\\((--[\\w-]+)\\)/g, (all, name: string) => themed(name) ?? all)}}\\n`;\n },\n };\n}\n\nconst COLOR = /(^|-)color$|^fill$|^stroke$|^--tw-gradient-(from|via|to)$/;\nconst NO_COLOR = /^(inherit|none|initial|unset)$/;\nconst PROPERTY = /@property [^{]+\\{[^}]*\\}\\n?/g;\n\n/** A rule's declarations, in order, from Tailwind's CSS for one class: one a line, `@property` rules after. */\nfunction declarations(css: string): [property: string, value: string][] {\n const rules = css.replace(PROPERTY, '');\n return [...rules.matchAll(/^\\s+(-{0,2}[\\w-]+):\\s*(.+?)(?:\\s*!important)?;$/gm)].map((match) => [match[1]!, match[2]!]);\n}\n\n/** `0.25rem * 4` as `1rem`: products and quotients of numbers with one unit between them. Anything else is left. */\nfunction computed(sum: string): string | undefined {\n const tokens = sum.trim().split(/\\s+/);\n let total = 1;\n let unit = '';\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i]!;\n if (i % 2 === 1) {\n if (token !== '*' && token !== '/') return undefined;\n continue;\n }\n const match = /^(-?(?:\\d+\\.?\\d*|\\.\\d+))(%|[a-z]+)?$/.exec(token);\n if (match === null) return undefined;\n const divides = tokens[i - 1] === '/';\n if (match[2] !== undefined && (unit !== '' || divides)) return undefined;\n unit = match[2] ?? unit;\n total = divides ? total / Number(match[1]) : total * Number(match[1]);\n }\n if (tokens.length % 2 === 0 || !Number.isFinite(total)) return undefined;\n return `${Number(total.toFixed(4))}${unit}`;\n}\n\n/** A length as a number to order by, where the value is one: `1rem` is 16. */\nfunction measure(value: string | undefined): number | undefined {\n const match = value === undefined ? null : /^(-?(?:\\d+\\.?\\d*|\\.\\d+))(px|rem|em|%)?$/.exec(value);\n if (match === null) return undefined;\n return Number(match[1]) * (match[2] === 'rem' || match[2] === 'em' ? 16 : 1);\n}\n\n/** A kind's order: by size where most of it has one (`text-xs` before `text-sm`), by name else, as it already is. */\nfunction byValue(kind: Entry[]): (a: Entry, b: Entry) => number {\n const sizes = new Map(kind.map((entry) => [entry, measure(entry.value)]));\n const sized = [...sizes.values()].filter((size) => size !== undefined).length;\n if (sized * 10 < kind.length * 7) return () => 0;\n return (a, b) => {\n const [x, y] = [sizes.get(a), sizes.get(b)];\n if (x === undefined || y === undefined) return x === y ? 0 : x === undefined ? 1 : -1;\n return x - y;\n };\n}\n\n/**\n * A class as written, apart: its variants (`md:hover:`), `!` where it leads, its own part, and `!` where it\n * trails. A `:` inside brackets or parentheses is the value's.\n */\nfunction parts(name: string): { before: string; bang: string; body: string; after: string } {\n let depth = 0;\n let cut = 0;\n for (let i = 0; i < name.length; i++) {\n const char = name[i]!;\n if (char === '[' || char === '(') depth++;\n else if (char === ']' || char === ')') depth--;\n else if (char === ':' && depth === 0) cut = i + 1;\n }\n const own = name.slice(cut);\n const bang = own.startsWith('!') ? '!' : '';\n const after = !bang && own.endsWith('!') ? '!' : '';\n return { before: name.slice(0, cut), bang, body: own.slice(bang.length, own.length - after.length), after };\n}\n\n/** A class's modifier (`/50`) and what it's on, where the whole isn't a class itself, as `w-1/2` is. */\nfunction modified(body: string, listed: Map<string, unknown>): { base: string; modifier: string } {\n const slash = body.lastIndexOf('/');\n if (listed.has(body) || slash < 0 || body.indexOf(']', slash) >= 0) return { base: body, modifier: '' };\n return { base: body.slice(0, slash), modifier: body.slice(slash) };\n}\n","/**\n * `deictic/tailwind`: open its tab on an element to edit its classes, written to its `className`.\n *\n * Only a list the source spells out can be edited: `className=\"…\"`, `className={'…'}`, a template\n * with no `${}`, or the first argument of a class helper (`cn('…', active && '…')`), whose other\n * arguments stay as they are. A list built any other way is shown, not edited, since there is no one\n * place for a class to go. An element without the attribute gets one.\n *\n * Its routes answer the panel from the project's own Tailwind (`catalog.ts`): what completes a word typed\n * (`complete`), what each class sets (`info`), the classes of a class's kind (`alternatives`) and the CSS of\n * classes the page's build hasn't seen (`css`). Without Tailwind v4 they answer nothing, and the panel is plain.\n */\nimport type { Argument, Expression, JSXAttribute, JSXOpeningElement, Program } from 'oxc-parser';\n\nimport { definePlugin, Refusal, type ServerContext, type Shortcut } from '#src/index.ts';\n\nimport { type Catalog, loadCatalog } from './catalog.ts';\n\nexport type { Alternatives, ClassInfo } from './catalog.ts';\n\nexport interface TailwindOptions {\n /** Calls whose first argument is a class list: `cn`, `clsx`, `cx`, `twMerge`, `classNames` by default. */\n helpers?: string[];\n /** The attribute an element without one gets: `className`, or `class` for Solid and Preact. */\n attribute?: 'className' | 'class';\n /**\n * The stylesheet that imports Tailwind and holds the theme, from the project's root: `src/index.css`. What\n * the panel completes and shows comes from it. Tailwind's default theme without one.\n */\n css?: string;\n /** What opens its tab directly, beside deictic's own shortcut, which opens any: none by default. */\n shortcut?: Shortcut;\n}\n\nexport type Model =\n | {\n editable: true;\n classes: string;\n /** The helper's other arguments, which add classes at runtime, each read as far as the source says. */\n others?: Extra[];\n }\n | { editable: false; source: string };\n\n/** Classes a helper's argument adds: `active && 'ring'` is `ring` when `active`. */\nexport interface Extra {\n /** The argument, or the part of it these classes come from, as written. */\n source: string;\n /** The classes, where the source spells them out: there, or in a `const` of the file it names. */\n classes?: string;\n /** What must hold for them to be added, as written: `active === 'h3'`. None where they always are. */\n when?: string;\n /** Set where the classes are a string in this file, which an op with `at` can write. */\n editable?: true;\n /** The `const` the string is in, where it isn't the argument itself: other elements may use it too. */\n shared?: string;\n}\n\nexport interface Op {\n classes: string;\n /** Which of the model's `others` the classes are for, by its place there. The element's own list without. */\n at?: number;\n}\n\n/** Where a class list sits in the source: the text between its quotes, or where a missing attribute goes. */\ntype List = { kind: 'list'; start: number; end: number; quote: string; others?: Argument[] };\ntype Spot = List | { kind: 'missing'; at: number } | { kind: 'fixed'; source: string };\n\nconst HELPERS = ['cn', 'clsx', 'cx', 'twMerge', 'classNames'];\n\nexport function tailwind(options: TailwindOptions = {}) {\n const helpers = new Set(options.helpers ?? HELPERS);\n const attribute = options.attribute ?? 'className';\n // Loaded on the first ask, as it takes a moment, and once: a project without Tailwind v4 has none.\n let loading: Promise<Catalog | undefined> | undefined;\n const catalog = ({ root }: ServerContext) =>\n (loading ??= loadCatalog(root, options.css).catch((problem: unknown) => {\n console.warn(`deictic/tailwind: no completions or class details, as ${problem instanceof Error ? problem.message : String(problem)}`);\n return undefined;\n }));\n const asked = async (request: Request): Promise<string[]> => {\n const body = (await request.json().catch(() => undefined)) as { classes?: unknown } | undefined;\n return Array.isArray(body?.classes) ? body.classes.filter((c): c is string => typeof c === 'string').slice(0, 500) : [];\n };\n return definePlugin<Model, Op>({\n name: 'tailwind',\n client: 'deictic/tailwind/client',\n shortcut: options.shortcut,\n routes: {\n // `complete?q=fle`: the classes for a word being typed.\n complete: async (request, context) => {\n const query = new URL(request.url).searchParams.get('q') ?? '';\n return Response.json({ items: (await catalog(context))?.complete(query) ?? [] });\n },\n // What each of `classes` sets. `available` is false where there's no catalog, so the panel stops asking.\n info: async (request, context) => {\n const known = await catalog(context);\n return Response.json({ available: known !== undefined, items: known?.info(await asked(request)) ?? [] });\n },\n // `alternatives?class=text-sm`: the classes of its kind, or nothing for one Tailwind doesn't know.\n alternatives: async (request, context) => {\n const name = new URL(request.url).searchParams.get('class') ?? '';\n return Response.json((await catalog(context))?.alternatives(name) ?? null);\n },\n css: async (request, context) => Response.json({ css: (await catalog(context))?.css(await asked(request)) ?? '' }),\n },\n read(source) {\n if (source instanceof Refusal) throw source;\n const { code, element, program } = source;\n const spot = spotOf(element, code, helpers);\n if (spot.kind === 'fixed') return { editable: false, source: spot.source };\n if (spot.kind === 'missing') return { editable: true, classes: '' };\n const others = spot.others?.flatMap((argument) => extrasOf(argument, code, program)).map(({ spot: _, ...extra }) => extra);\n return { editable: true, classes: code.slice(spot.start, spot.end), ...(others === undefined ? {} : { others }) };\n },\n apply(source, _target, { classes, at }) {\n if (source instanceof Refusal) throw source;\n const { file, code, element, program } = source;\n const list = classes.trim().split(/\\s+/).filter(Boolean).join(' ');\n const spot = spotOf(element, code, helpers);\n if (spot.kind === 'fixed') throw new Refusal('this class list is built at runtime: edit it in the editor');\n if (at !== undefined) {\n const others = spot.kind === 'list' ? (spot.others ?? []).flatMap((argument) => extrasOf(argument, code, program)) : [];\n const place = others[at]?.spot;\n if (place === undefined)\n throw new Refusal(\"these classes aren't a string in this file any more: reload, or edit them in the editor\");\n return [{ start: place.start, end: place.end, text: quoted(list, place.quote) }];\n }\n // An `.astro` component writes `class`, whatever the JSX beside it does.\n const name = file.endsWith('.astro') ? 'class' : attribute;\n if (spot.kind === 'missing') return list === '' ? [] : [{ start: spot.at, end: spot.at, text: ` ${name}=\"${quoted(list, '\"')}\"` }];\n return [{ start: spot.start, end: spot.end, text: quoted(list, spot.quote) }];\n },\n describe({ classes, at }, before) {\n if (!before.editable) return 'classes';\n if (at === undefined) return diff(before.classes, classes);\n const other = before.others?.[at];\n return `${diff(other?.classes ?? '', classes)}${other?.when === undefined ? '' : ` when ${other.when}`}`;\n },\n });\n}\n\nfunction spotOf(element: JSXOpeningElement, code: string, helpers: Set<string>): Spot {\n const attr = element.attributes.find(\n (a): a is JSXAttribute =>\n a.type === 'JSXAttribute' && a.name.type === 'JSXIdentifier' && (a.name.name === 'className' || a.name.name === 'class'),\n );\n if (attr === undefined) {\n // Astro's `class:list` is the element's class list too: a `class` beside it would be a second one.\n const listed = element.attributes.find(\n (a) => a.type === 'JSXAttribute' && a.name.type === 'JSXIdentifier' && a.name.name === 'class:list',\n );\n return listed === undefined\n ? { kind: 'missing', at: element.name.end }\n : { kind: 'fixed', source: code.slice(listed.start, listed.end) };\n }\n const { value } = attr;\n if (value?.type === 'Literal') return list(value, code);\n if (value?.type !== 'JSXExpressionContainer' || value.expression.type === 'JSXEmptyExpression')\n return { kind: 'fixed', source: code.slice(attr.start, attr.end) };\n const e = value.expression;\n const whole = listIn(e, code);\n if (whole !== undefined) return whole;\n if (e.type === 'CallExpression' && e.callee.type === 'Identifier' && helpers.has(e.callee.name)) {\n const [first, ...others] = e.arguments;\n const head = first === undefined || first.type === 'SpreadElement' ? undefined : listIn(first, code);\n if (head !== undefined) return others.length === 0 ? head : { ...head, others };\n }\n return { kind: 'fixed', source: code.slice(attr.start, attr.end) };\n}\n\n/**\n * What one of a helper's arguments adds, and when: `on && 'ring'`, `on ? 'a' : 'b'`, `{ ring: on }`, a string,\n * or a name for one. Anything else is only its source, as nothing says what it adds.\n */\nfunction extrasOf(argument: Argument, code: string, program: Program): (Extra & { spot?: List })[] {\n const source = (node: { start: number; end: number }) => code.slice(node.start, node.end);\n const added = (e: { type: string; start: number; end: number }, when?: string, key = false): Extra & { spot?: List } => {\n const found = stringOf(e, program, !key);\n if (found === undefined) return { source: source(e), ...(when === undefined ? {} : { when }) };\n return {\n source: source(e),\n classes: found.value,\n ...(when === undefined ? {} : { when }),\n editable: true,\n ...(found.shared === undefined ? {} : { shared: found.shared }),\n spot: list(found.node, code),\n };\n };\n const e = argument;\n if (e.type === 'SpreadElement') return [{ source: source(e) }];\n if (e.type === 'LogicalExpression' && e.operator === '&&') return [added(e.right, source(e.left))];\n if (e.type === 'ConditionalExpression') {\n const test = source(e.test);\n const not = e.test.type === 'Identifier' ? `!${test}` : `!(${test})`;\n // A branch that adds nothing (`on ? 'ring' : undefined`) isn't one to show.\n return [added(e.consequent, test), added(e.alternate, not)].filter(\n (extra) => extra.classes !== '' && !/^(undefined|null|false)$/.test(extra.source),\n );\n }\n if (e.type === 'ObjectExpression') {\n return e.properties.map((property): Extra & { spot?: List } => {\n if (property.type !== 'Property' || property.computed) return { source: source(property) };\n const always = property.value.type === 'Literal' && property.value.value === true;\n const when = always ? {} : { when: source(property.value) };\n // A bare key (`ring`) is a class, but not a string to write a list into.\n if (property.key.type === 'Identifier') return { source: source(property), classes: property.key.name, ...when };\n const { source: _, ...key } = added(property.key, undefined, true);\n return key.classes === undefined ? { source: source(property) } : { source: source(property), ...key, ...when };\n });\n }\n return [added(e)];\n}\n\n/**\n * A string the source spells out, and where: a literal, a template with nothing interpolated, or a top-level\n * `const` of one (`shared`, its name).\n */\nfunction stringOf(\n e: { type: string },\n program: Program,\n named = true,\n): { value: string; node: { start: number; end: number }; shared?: string } | undefined {\n const node = e as Expression;\n if (node.type === 'Literal') return typeof node.value === 'string' ? { value: node.value, node } : undefined;\n if (node.type === 'TemplateLiteral') {\n const value = node.expressions.length === 0 ? node.quasis[0]?.value.cooked : undefined;\n return value === undefined || value === null ? undefined : { value, node };\n }\n if (node.type !== 'Identifier' || !named) return undefined;\n for (const statement of program.body) {\n const declared = statement.type === 'ExportNamedDeclaration' ? statement.declaration : statement;\n if (declared?.type !== 'VariableDeclaration' || declared.kind !== 'const') continue;\n for (const { id, init } of declared.declarations) {\n if (id.type !== 'Identifier' || id.name !== node.name || !init) continue;\n const found = stringOf(init, program, false);\n return found === undefined ? undefined : { ...found, shared: node.name };\n }\n }\n return undefined;\n}\n\n/** A string literal or a template with nothing interpolated, as the text between its quotes. */\nfunction listIn(e: Expression, code: string): List | undefined {\n if (e.type === 'Literal' && typeof e.value === 'string') return list(e, code);\n if (e.type === 'TemplateLiteral' && e.expressions.length === 0) return list(e, code);\n return undefined;\n}\n\nconst list = (node: { start: number; end: number }, code: string): List => ({\n kind: 'list',\n start: node.start + 1,\n end: node.end - 1,\n quote: code[node.start]!,\n});\n\n/** The list as it may sit between `quote`s. A JSX attribute has no escapes, so a quote of its own kind can't. */\nfunction quoted(list: string, quote: string): string {\n if (quote === '`') return list.replaceAll('\\\\', '\\\\\\\\').replaceAll('`', '\\\\`').replaceAll('${', '\\\\${');\n if (!list.includes(quote)) return list;\n throw new Refusal(`a class can't hold ${quote} here: use the other quote inside arbitrary values, as in content-['…']`);\n}\n\n/** What changed between two lists: `+ring -px-2`. */\nfunction diff(before: string, after: string): string {\n const was = new Set(before.split(/\\s+/).filter(Boolean));\n const now = new Set(after.split(/\\s+/).filter(Boolean));\n const parts = [...[...now].filter((c) => !was.has(c)).map((c) => `+${c}`), ...[...was].filter((c) => !now.has(c)).map((c) => `-${c}`)];\n return parts.length > 0 ? parts.join(' ') : 'reordered classes';\n}\n\nexport default tailwind;\n"],"mappings":";;;;;;;;;;;;;;;;AAkEA,MAAM,MAAM;CAAC;CAAqB;CAAwB;CAAoB;AAAsB;AACpG,MAAM,OAAO;AACb,MAAM,UAAU,IAAI,KAAK,SAAS,MAAM,EAAE,SAAS,KAAK,CAAC,CAAC,CAAC;;;;;;AAO3D,eAAsB,YAAY,MAAc,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AG,OAAO;CAClC,MAAM,IAAI,QAAQ,sBAAsB,MAAM,wEAAwE;AACxH;;AAGA,SAAS,KAAK,QAAgB,OAAuB;CACnD,MAAM,MAAM,IAAI,IAAI,OAAO,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO,CAAC;CACvD,MAAM,MAAM,IAAI,IAAI,MAAM,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO,CAAC;CACtD,MAAM,QAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,QAAQ,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,QAAQ,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,IAAI,GAAG,CAAC;CACrI,OAAO,MAAM,SAAS,IAAI,MAAM,KAAK,GAAG,IAAI;AAC9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","names":[],"sources":["../../src/plugins/tasks/client.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"client.d.ts","names":[],"sources":["../../src/plugins/tasks/client.ts"],"mappings":";;qBAsTa;cAwBb,4B"}
|
package/dist/tasks/client.js
CHANGED
|
@@ -208,8 +208,8 @@ const OUTLINE = "#12b358";
|
|
|
208
208
|
/** CSS pixels between the element and its outline, so the dashes are on nothing of the element's. */
|
|
209
209
|
const ROOM = 3;
|
|
210
210
|
/**
|
|
211
|
-
* A shot's PNG with the element outlined in it: dashes around its box,
|
|
212
|
-
*
|
|
211
|
+
* A shot's PNG with the element outlined in it: dashes around its box, with nothing between them, as the overlay
|
|
212
|
+
* draws it. The shot may have more pixels than its size in CSS ones, which the box is in.
|
|
213
213
|
*/
|
|
214
214
|
async function outlined(png, { box, size }) {
|
|
215
215
|
const url = typeof png === "string" ? png : URL.createObjectURL(png);
|
|
@@ -231,9 +231,6 @@ async function outlined(png, { box, size }) {
|
|
|
231
231
|
(box.width + 6) * k,
|
|
232
232
|
(box.height + 6) * k
|
|
233
233
|
];
|
|
234
|
-
ctx.lineWidth = 4 * k;
|
|
235
|
-
ctx.strokeStyle = "#fff";
|
|
236
|
-
ctx.strokeRect(...rect);
|
|
237
234
|
ctx.lineWidth = 2 * k;
|
|
238
235
|
ctx.strokeStyle = OUTLINE;
|
|
239
236
|
ctx.setLineDash([6 * k, 4 * k]);
|
|
@@ -853,6 +850,8 @@ var client_default = defineClientPlugin({
|
|
|
853
850
|
announce(model, op, context.target);
|
|
854
851
|
text.value = "";
|
|
855
852
|
reset();
|
|
853
|
+
const dropped = model.tasks.at(-1)?.dropped;
|
|
854
|
+
if (dropped !== void 0) problem.textContent = `Sent without ${dropped}: it wasn't kept any more`;
|
|
856
855
|
} catch {}
|
|
857
856
|
sending = false;
|
|
858
857
|
able();
|