@vinena/knobs 0.6.5 → 0.7.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +11 -5
  3. package/THIRD_PARTY_NOTICES.md +3 -3
  4. package/dist/cli.d.ts +95 -0
  5. package/dist/cli.js +527 -0
  6. package/dist/{context-amfyasb5.js → context-eawqn680.js} +1 -1
  7. package/dist/{context-svtr7vwt.js → context-vd2xep5t.js} +1 -1
  8. package/dist/edit/keep.d.ts +1 -1
  9. package/dist/{elementsview-s5vj51vh.js → elementsview-jg4edt86.js} +7 -7
  10. package/dist/{elementsview-swft4xar.js → elementsview-m33ejs4r.js} +7 -7
  11. package/dist/engine/pageshot.d.ts +25 -0
  12. package/dist/{framekit-q97zeg1d.js → framekit-40pzennw.js} +48 -26
  13. package/dist/{framekit-rjk9fs3v.js → framekit-r16k97n7.js} +48 -26
  14. package/dist/grab/fiber.d.ts +2 -0
  15. package/dist/{index-s252g4k2.js → index-0qkj2mgb.js} +4 -4
  16. package/dist/{index-whehz74d.js → index-2jc9dnta.js} +21 -1
  17. package/dist/{index-whbpf3kg.js → index-3nwycv3p.js} +4 -4
  18. package/dist/{index-pwqfmbqm.js → index-8d1yk9d2.js} +8 -8
  19. package/dist/{index-ajs4na3f.js → index-cb91vcka.js} +1 -1
  20. package/dist/{index-20bc9yrj.js → index-fjrrgd9h.js} +1 -1
  21. package/dist/{index-df35z48z.js → index-q53j8wg5.js} +2 -2
  22. package/dist/{index-yc2m7nce.js → index-s6fya8pm.js} +4 -4
  23. package/dist/{index-dxga6h10.js → index-tqq2ygpj.js} +2 -2
  24. package/dist/{index-69fvtkcm.js → index-v2v4rmpe.js} +3 -3
  25. package/dist/{index-1mstjadm.js → index-xs29b55n.js} +4 -1
  26. package/dist/{index-sy63y6r7.js → index-xxbb8y41.js} +4 -4
  27. package/dist/index.global.js +135 -118
  28. package/dist/index.js +63 -23
  29. package/dist/{react-msn10fjb.js → react-0gxs9aef.js} +3 -3
  30. package/dist/{react-2b7725je.js → react-3ev6rwqz.js} +2 -2
  31. package/dist/{react-k4pkm1p5.js → react-6ngtb6p9.js} +1 -1
  32. package/dist/{react-5ekfj7g3.js → react-8nmtt0ge.js} +2 -2
  33. package/dist/{react-y9gr8yt2.js → react-actmnkwp.js} +1 -1
  34. package/dist/{react-p1m2eadn.js → react-fq4551ks.js} +4 -4
  35. package/dist/{react-vbk58f9m.js → react-meve34wp.js} +21 -1
  36. package/dist/{react-nc8fzgmc.js → react-vvc4x9kq.js} +4 -4
  37. package/dist/{react-3mfz1x2a.js → react-yx3g9k55.js} +4 -1
  38. package/dist/{react-smtqyzx0.js → react-zp7fdw8e.js} +8 -8
  39. package/dist/react.js +63 -23
  40. package/dist/{replay-461gcdh1.js → replay-m5g8km9y.js} +4 -4
  41. package/dist/{replay-ehgxp9py.js → replay-pmesjfa3.js} +4 -4
  42. package/dist/{storageview-vtvt76ze.js → storageview-9a6zm47z.js} +8 -8
  43. package/dist/{storageview-yyd57vzw.js → storageview-x62v1c3j.js} +8 -8
  44. package/dist/ui/icons.d.ts +5 -2
  45. package/dist/ui/panel.d.ts +2 -0
  46. package/dist/ui/settings.d.ts +11 -1
  47. package/package.json +5 -2
  48. package/skills/{devknobs → knobs}/SKILL.md +18 -18
package/dist/cli.js ADDED
@@ -0,0 +1,527 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/cli.ts
4
+ import { existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, statSync, writeFileSync } from "node:fs";
5
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
6
+ import process from "node:process";
7
+ import { fileURLToPath } from "node:url";
8
+ var MESSAGES = {
9
+ install: {
10
+ npm: "npm i -D @vinena/knobs",
11
+ pnpm: "pnpm add -D @vinena/knobs",
12
+ yarn: "yarn add -D @vinena/knobs",
13
+ bun: "bun add -d @vinena/knobs"
14
+ },
15
+ next: "Render that component once in app/layout (App Router) or pages/_app (Pages Router).",
16
+ entry: 'call if (import.meta.env.DEV) import("@vinena/knobs").then(({ mount }) => mount()); in the client entry, or in a mount effect of the root component in an SSR app.',
17
+ plain: 'add <script src="//unpkg.com/@vinena/knobs/dist/index.global.js"></script> to the page. It mounts itself. Keep it out of the deployed page.',
18
+ production: "Keep knobs out of production builds. A static import stays in the bundle even behind a dev check, so gate the import itself as above. If the project has a build script, run it and check that the output has no knobs.",
19
+ early: 'If the app reads media queries, the time or the user agent while it boots, or renders with React, add the early script as the first element in <head>, in development only: <script src="//unpkg.com/@vinena/knobs/dist/early.global.js"></script>',
20
+ open: "press ⇧K, or click the handle on the right edge of the window, to open the panel.",
21
+ reference: "the full reference, every detail in one file, is at https://knobs.dev/llms-full.txt",
22
+ created: (path) => `created ${path}`,
23
+ changed: (path) => `changed ${path}`,
24
+ unchanged: (path) => `no change: ${path}`,
25
+ unknown: "not found",
26
+ dryRun: "dry run",
27
+ usage: "usage: knobs init [--dry-run]",
28
+ packageJson: "error: package.json",
29
+ writeFailed: (path, code) => `error: ${path} ${code}`
30
+ };
31
+ var MOUNTS = /(?:\bfrom\s*|\bimport\s*\(\s*)(["'])@vinena\/knobs(?:\/react)?\1/;
32
+ function scan(text) {
33
+ const cuts = [];
34
+ const holes = [];
35
+ let inTemplate = false;
36
+ let last = "";
37
+ let lastAt = -1;
38
+ let plainUntil = -1;
39
+ let i = 0;
40
+ while (i < text.length) {
41
+ if (inTemplate) {
42
+ const start = i;
43
+ while (i < text.length && text[i] !== "`" && !(text[i] === "$" && text[i + 1] === "{"))
44
+ i += text[i] === "\\" ? 2 : 1;
45
+ cuts.push({ start, end: Math.min(i, text.length), comment: false });
46
+ if (i >= text.length)
47
+ break;
48
+ if (text[i] === "`") {
49
+ inTemplate = false;
50
+ last = "`";
51
+ i += 1;
52
+ } else {
53
+ holes.push(0);
54
+ inTemplate = false;
55
+ last = "{";
56
+ i += 2;
57
+ }
58
+ continue;
59
+ }
60
+ const c = text[i] ?? "";
61
+ const next = text[i + 1];
62
+ if (c === "/" && next === "/") {
63
+ let end = text.indexOf(`
64
+ `, i);
65
+ if (end < 0)
66
+ end = text.length;
67
+ else if (text[end - 1] === "\r")
68
+ end -= 1;
69
+ cuts.push({ start: i, end, comment: true });
70
+ i = end;
71
+ } else if (c === "/" && next === "*") {
72
+ const close = text.indexOf("*/", i + 2);
73
+ const end = close < 0 ? text.length : close + 2;
74
+ cuts.push({ start: i, end, comment: true });
75
+ i = end;
76
+ } else if (c === "/" && i > plainUntil && (last === "" || "(,=:[!&|?{;".includes(last) || last === ">" && text[lastAt - 1] === "=" || /(?:^|[^\w$.])(?:return|typeof|case|do|else|in|of|new|delete|void|throw|yield|await|instanceof)$/.test(text.slice(Math.max(0, lastAt - 10), lastAt + 1)))) {
77
+ let j = i + 1;
78
+ let inClass = false;
79
+ while (j < text.length && text[j] !== `
80
+ ` && (inClass || text[j] !== "/")) {
81
+ if (text[j] === "\\")
82
+ j += 1;
83
+ else if (text[j] === "[")
84
+ inClass = true;
85
+ else if (text[j] === "]")
86
+ inClass = false;
87
+ j += 1;
88
+ }
89
+ if (text[j] === "/") {
90
+ cuts.push({ start: i + 1, end: j, comment: false });
91
+ i = j + 1;
92
+ } else {
93
+ plainUntil = j;
94
+ i += 1;
95
+ }
96
+ last = "/";
97
+ } else if (c === '"' || c === "'") {
98
+ let j = i + 1;
99
+ while (j < text.length && text[j] !== c && text[j] !== `
100
+ `)
101
+ j += text[j] === "\\" ? 2 : 1;
102
+ cuts.push({ start: i + 1, end: Math.min(j, text.length), comment: false });
103
+ i = text[j] === c ? j + 1 : j;
104
+ last = c;
105
+ } else if (c === "`") {
106
+ inTemplate = true;
107
+ i += 1;
108
+ } else {
109
+ const top = holes.length - 1;
110
+ const open = holes[top];
111
+ if (open !== undefined && c === "{")
112
+ holes[top] = open + 1;
113
+ if (open !== undefined && c === "}") {
114
+ if (open === 0) {
115
+ holes.pop();
116
+ inTemplate = true;
117
+ i += 1;
118
+ continue;
119
+ }
120
+ holes[top] = open - 1;
121
+ }
122
+ if (!/\s/.test(c)) {
123
+ last = c;
124
+ lastAt = i;
125
+ }
126
+ i += 1;
127
+ }
128
+ }
129
+ const blank = (all) => {
130
+ const parts = [];
131
+ let at = 0;
132
+ for (const cut of cuts) {
133
+ if (!all && !cut.comment)
134
+ continue;
135
+ parts.push(text.slice(at, cut.start), " ".repeat(cut.end - cut.start));
136
+ at = cut.end;
137
+ }
138
+ parts.push(text.slice(at));
139
+ return parts.join("");
140
+ };
141
+ return { code: blank(false), bare: blank(true) };
142
+ }
143
+ function lastImportEnd(text, bare) {
144
+ let found = null;
145
+ let from = 0;
146
+ for (;; ) {
147
+ const at = bare.indexOf("import", from);
148
+ if (at < 0)
149
+ return found;
150
+ from = at + 6;
151
+ if (at > 0 && bare[at - 1] !== `
152
+ ` || /[\w$]/.test(bare[at + 6] ?? ""))
153
+ continue;
154
+ let quote = from;
155
+ while (quote < bare.length && !"\"';`".includes(bare[quote] ?? "") && !bare.startsWith(`
156
+ import`, quote))
157
+ quote += 1;
158
+ from = quote;
159
+ const q = bare[quote];
160
+ if (q !== '"' && q !== "'")
161
+ continue;
162
+ const clause = bare.slice(at + 6, quote).trimEnd();
163
+ if (clause !== "" && !(clause.endsWith("from") && !/[\w$]/.test(clause.at(-5) ?? "")))
164
+ continue;
165
+ const close = bare.indexOf(q, quote + 1);
166
+ if (close < 0 || !/^ +$/.test(bare.slice(quote + 1, close)))
167
+ continue;
168
+ let end = close + 1;
169
+ if (bare[end] === ";")
170
+ end += 1;
171
+ while (bare[end] === " " || bare[end] === "\t")
172
+ end += 1;
173
+ from = end;
174
+ if (end === text.length || text[end] === `
175
+ `)
176
+ found = text[end - 1] === "\r" ? end - 1 : end;
177
+ else if (text[end] === "\r" && text[end + 1] === `
178
+ `)
179
+ found = end;
180
+ }
181
+ }
182
+ function directiveEnd(text, bare) {
183
+ let end = 0;
184
+ let at = 0;
185
+ for (;; ) {
186
+ while (at < bare.length && /\s/.test(bare[at] ?? ""))
187
+ at += 1;
188
+ const directive = /(["'])use \w+\1/y;
189
+ directive.lastIndex = at;
190
+ if (!directive.test(text))
191
+ return end;
192
+ const line = /;?[ \t]*(?:\/\/[^\r\n]*)?\r?\n/y;
193
+ line.lastIndex = directive.lastIndex;
194
+ if (!line.test(text))
195
+ return null;
196
+ end = line.lastIndex;
197
+ at = end;
198
+ }
199
+ }
200
+ var RELATIVE_IMPORTS = /(?:\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(["'])(\.\.?\/[^"']+)\1/g;
201
+ function eolOf(text) {
202
+ return text.includes(`\r
203
+ `) ? `\r
204
+ ` : `
205
+ `;
206
+ }
207
+ var MOUNT_LINE = 'if (import.meta.env.DEV) import("@vinena/knobs").then(({ mount }) => mount());';
208
+ var COMPONENT_NAME = "dev-knobs";
209
+ var COMPONENT = [
210
+ '"use client";',
211
+ "",
212
+ 'import dynamic from "next/dynamic";',
213
+ "",
214
+ 'const DevKnobs = process.env.NODE_ENV === "development" ? dynamic(() => import("@vinena/knobs/react").then((m) => m.DevKnobs), { ssr: false }) : null;',
215
+ "",
216
+ "export function DevPanel() {",
217
+ " return <>{DevKnobs && <DevKnobs />}</>;",
218
+ "}",
219
+ ""
220
+ ].join(`
221
+ `);
222
+ var COMPONENT_IMPORT = `import { DevPanel } from "./${COMPONENT_NAME}";`;
223
+ var COMPONENT_RENDER = "<DevPanel />";
224
+ function packageManager(files) {
225
+ if (files("pnpm-lock.yaml"))
226
+ return "pnpm";
227
+ if (files("yarn.lock"))
228
+ return "yarn";
229
+ if (files("bun.lock") || files("bun.lockb"))
230
+ return "bun";
231
+ return "npm";
232
+ }
233
+ var SCRIPT_EXTENSIONS = ["tsx", "jsx", "ts", "js"];
234
+ function firstOf(files, stems) {
235
+ for (const stem of stems) {
236
+ for (const extension of SCRIPT_EXTENSIONS) {
237
+ if (files(`${stem}.${extension}`))
238
+ return `${stem}.${extension}`;
239
+ }
240
+ }
241
+ return null;
242
+ }
243
+ function moduleEntry(html, files = () => true) {
244
+ for (const tag of html.replace(/<!--[\s\S]*?-->/g, "").match(/<script\b[^>]*>/gi) ?? []) {
245
+ if (!/\btype\s*=\s*["']module["']/i.test(tag))
246
+ continue;
247
+ const src = /\bsrc\s*=\s*["']([^"']+)["']/i.exec(tag)?.[1];
248
+ if (!src || /^([a-z]+:)?\/\//i.test(src))
249
+ continue;
250
+ const path = src.replace(/^\.?\//, "");
251
+ if (files(path))
252
+ return path;
253
+ }
254
+ return null;
255
+ }
256
+ function depends(pkg, name) {
257
+ return ["dependencies", "devDependencies"].some((field) => {
258
+ const listed = typeof pkg === "object" && pkg !== null ? Reflect.get(pkg, field) : null;
259
+ return typeof listed === "object" && listed !== null && name in listed;
260
+ });
261
+ }
262
+ function framework(pkg, files, read = () => "") {
263
+ if (pkg === null)
264
+ return { kind: "plain" };
265
+ const has = (name) => depends(pkg, name);
266
+ if (has("next")) {
267
+ const layout = firstOf(files, ["app/layout", "src/app/layout"]);
268
+ if (layout)
269
+ return { kind: "next-app", layout };
270
+ const app = firstOf(files, ["pages/_app", "src/pages/_app"]);
271
+ return app ? { kind: "next-pages", app } : { kind: "unknown" };
272
+ }
273
+ if (has("vite") && files("index.html")) {
274
+ const entry2 = moduleEntry(read("index.html"), files);
275
+ if (entry2)
276
+ return { kind: "entry", entry: entry2, make: false };
277
+ }
278
+ if (has("@sveltejs/kit")) {
279
+ const entry2 = ["src/hooks.client.ts", "src/hooks.client.js"].find(files);
280
+ return { kind: "entry", entry: entry2 ?? "src/hooks.client.ts", make: !entry2 };
281
+ }
282
+ const entry = ["app/entry.client.tsx", "app/entry.client.jsx", "src/client.tsx", "src/client.jsx"].find(files);
283
+ return entry ? { kind: "entry", entry, make: false } : { kind: "unknown" };
284
+ }
285
+ function withPanel(layout) {
286
+ const close = layout.indexOf("</body>");
287
+ if (close < 0 || close !== layout.lastIndexOf("</body>"))
288
+ return null;
289
+ const eol = eolOf(layout);
290
+ const lineStart = layout.lastIndexOf(`
291
+ `, close) + 1;
292
+ const indent = layout.slice(lineStart, close);
293
+ const rendered = /^[ \t]*$/.test(indent) ? `${layout.slice(0, lineStart)}${indent}${indent.includes("\t") ? "\t" : " "}${COMPONENT_RENDER}${eol}${layout.slice(lineStart)}` : `${layout.slice(0, close)}${COMPONENT_RENDER}${layout.slice(close)}`;
294
+ const { bare } = scan(rendered);
295
+ const last = lastImportEnd(rendered, bare);
296
+ if (last !== null)
297
+ return `${rendered.slice(0, last)}${eol}${COMPONENT_IMPORT}${rendered.slice(last)}`;
298
+ const at = directiveEnd(rendered, bare);
299
+ if (at === null)
300
+ return null;
301
+ return `${rendered.slice(0, at)}${COMPONENT_IMPORT}${eol}${rendered.slice(at)}`;
302
+ }
303
+ function inside(dir, path) {
304
+ try {
305
+ const root = realpathSync(dir);
306
+ let at = resolve(dir, path);
307
+ const rest = [];
308
+ while (!existsSync(at)) {
309
+ if (lstatSync(at, { throwIfNoEntry: false }))
310
+ return false;
311
+ const up = dirname(at);
312
+ if (up === at)
313
+ return false;
314
+ rest.unshift(basename(at));
315
+ at = up;
316
+ }
317
+ const from = relative(root, join(realpathSync(at), ...rest));
318
+ return from !== "" && from !== ".." && !from.startsWith(`..${sep}`) && !isAbsolute(from);
319
+ } catch {
320
+ return false;
321
+ }
322
+ }
323
+ function mountsKnobs(path, source, look) {
324
+ const live = scan(source).code;
325
+ if (MOUNTS.test(live))
326
+ return true;
327
+ for (const [, , spec = ""] of live.matchAll(RELATIVE_IMPORTS)) {
328
+ const base = join(dirname(path), spec);
329
+ const candidates = [
330
+ base,
331
+ ...SCRIPT_EXTENSIONS.map((extension) => `${base}.${extension}`),
332
+ ...SCRIPT_EXTENSIONS.map((extension) => join(base, `index.${extension}`))
333
+ ];
334
+ for (const candidate of candidates) {
335
+ const text = look(candidate);
336
+ if (text === null)
337
+ continue;
338
+ if (MOUNTS.test(scan(text).code))
339
+ return true;
340
+ break;
341
+ }
342
+ }
343
+ return false;
344
+ }
345
+
346
+ class ReadFailed extends Error {
347
+ path;
348
+ code;
349
+ constructor(path, code) {
350
+ super(`${path} ${code}`);
351
+ this.path = path;
352
+ this.code = code;
353
+ }
354
+ }
355
+ function plan(dir) {
356
+ const files = (path) => existsSync(join(dir, path));
357
+ const read = (path) => {
358
+ try {
359
+ return readFileSync(join(dir, path), "utf8");
360
+ } catch (error) {
361
+ throw new ReadFailed(path, errorCode(error));
362
+ }
363
+ };
364
+ const look = (path) => {
365
+ try {
366
+ return inside(dir, path) && statSync(join(dir, path)).isFile() ? read(path) : null;
367
+ } catch {
368
+ return null;
369
+ }
370
+ };
371
+ let pkg = null;
372
+ if (files("package.json")) {
373
+ try {
374
+ pkg = JSON.parse(read("package.json").replace(/^/, ""));
375
+ } catch {
376
+ return { dir, edits: [], lines: [MESSAGES.packageJson], code: 1 };
377
+ }
378
+ }
379
+ const found = framework(pkg, files, read);
380
+ const edits = [];
381
+ const lines = [];
382
+ let code = 0;
383
+ const byHand = (step, missing) => {
384
+ if (missing)
385
+ lines.push(MESSAGES.unknown);
386
+ lines.push(step);
387
+ code = 1;
388
+ };
389
+ const edit = (path, kind, content) => {
390
+ edits.push({ path, kind, content });
391
+ lines.push(kind === "create" ? MESSAGES.created(path) : MESSAGES.changed(path));
392
+ };
393
+ if (found.kind !== "plain")
394
+ lines.push(MESSAGES.install[packageManager(files)]);
395
+ if (found.kind === "next-app" || found.kind === "next-pages") {
396
+ const beside = found.kind === "next-app" ? found.layout : found.app;
397
+ const typed = /\.tsx?$/.test(beside);
398
+ const folder = found.kind === "next-app" ? dirname(beside) : dirname(dirname(beside));
399
+ const component = join(folder, `${COMPONENT_NAME}.${typed ? "tsx" : "jsx"}`);
400
+ if (!inside(dir, beside) || !inside(dir, component))
401
+ byHand(MESSAGES.next, false);
402
+ else {
403
+ const source = read(beside);
404
+ const eol = eolOf(source);
405
+ const ours = source.includes(COMPONENT_IMPORT);
406
+ const makeComponent = () => {
407
+ if (files(component))
408
+ lines.push(MESSAGES.unchanged(component));
409
+ else
410
+ edit(component, "create", COMPONENT.replaceAll(`
411
+ `, eol));
412
+ };
413
+ if (ours || mountsKnobs(beside, source, look)) {
414
+ if (ours)
415
+ makeComponent();
416
+ lines.push(MESSAGES.unchanged(beside));
417
+ } else if (found.kind === "next-pages") {
418
+ makeComponent();
419
+ byHand(MESSAGES.next, false);
420
+ } else {
421
+ const next = withPanel(source);
422
+ makeComponent();
423
+ if (next === null)
424
+ byHand(MESSAGES.next, false);
425
+ else
426
+ edit(beside, "change", next);
427
+ }
428
+ }
429
+ } else if (found.kind === "entry") {
430
+ if (!inside(dir, found.entry))
431
+ byHand(MESSAGES.entry, false);
432
+ else if (found.make)
433
+ edit(found.entry, "create", `${MOUNT_LINE}
434
+ `);
435
+ else {
436
+ const source = read(found.entry);
437
+ const eol = eolOf(source);
438
+ if (MOUNTS.test(scan(source).code))
439
+ lines.push(MESSAGES.unchanged(found.entry));
440
+ else
441
+ edit(found.entry, "change", `${source}${source === "" || source.endsWith(`
442
+ `) ? "" : eol}${MOUNT_LINE}${eol}`);
443
+ }
444
+ } else if (found.kind === "plain")
445
+ byHand(MESSAGES.plain, false);
446
+ else
447
+ byHand(depends(pkg, "next") ? MESSAGES.next : MESSAGES.entry, true);
448
+ lines.push(MESSAGES.production, MESSAGES.early, MESSAGES.open, MESSAGES.reference);
449
+ return { dir, edits, lines, code };
450
+ }
451
+ function apply(planned) {
452
+ const ordered = [...planned.edits].sort((a, b) => Number(a.kind === "create") - Number(b.kind === "create"));
453
+ const changed = [];
454
+ for (const { path, kind, content } of ordered) {
455
+ const file = join(planned.dir, path);
456
+ try {
457
+ const before = kind === "change" ? readFileSync(file, "utf8") : null;
458
+ mkdirSync(dirname(file), { recursive: true });
459
+ writeFileSync(file, content, { flag: kind === "create" ? "wx" : "w" });
460
+ if (before !== null)
461
+ changed.push({ file, before });
462
+ } catch (error) {
463
+ for (const { file: back, before } of changed) {
464
+ try {
465
+ writeFileSync(back, before);
466
+ } catch {}
467
+ }
468
+ return MESSAGES.writeFailed(path, errorCode(error));
469
+ }
470
+ }
471
+ return null;
472
+ }
473
+ function errorCode(error) {
474
+ const code = error instanceof Error ? Reflect.get(error, "code") : undefined;
475
+ return typeof code === "string" ? code : String(error);
476
+ }
477
+ function run(args, dir, print = console.log) {
478
+ const [command, ...flags] = args;
479
+ if (command !== "init" || flags.some((flag) => flag !== "--dry-run")) {
480
+ print(MESSAGES.usage);
481
+ return 1;
482
+ }
483
+ const dry = flags.includes("--dry-run");
484
+ let planned;
485
+ try {
486
+ planned = plan(dir);
487
+ } catch (error) {
488
+ if (!(error instanceof ReadFailed))
489
+ throw error;
490
+ print(MESSAGES.writeFailed(error.path, error.code));
491
+ return 1;
492
+ }
493
+ if (dry)
494
+ print(MESSAGES.dryRun);
495
+ else {
496
+ const failed = apply(planned);
497
+ if (failed !== null) {
498
+ print(failed);
499
+ return 1;
500
+ }
501
+ }
502
+ for (const line of planned.lines)
503
+ print(line);
504
+ return planned.code;
505
+ }
506
+ function isMain() {
507
+ try {
508
+ return realpathSync(process.argv[1] ?? "") === realpathSync(fileURLToPath(import.meta.url));
509
+ } catch {
510
+ return false;
511
+ }
512
+ }
513
+ if (isMain())
514
+ process.exitCode = run(process.argv.slice(2), process.cwd());
515
+ export {
516
+ withPanel,
517
+ run,
518
+ plan,
519
+ packageManager,
520
+ moduleEntry,
521
+ framework,
522
+ apply,
523
+ ReadFailed,
524
+ MOUNT_LINE,
525
+ MESSAGES,
526
+ COMPONENT
527
+ };
@@ -7,7 +7,7 @@ import {
7
7
  grabEntry,
8
8
  joinEntries,
9
9
  quickEntry
10
- } from "./react-3mfz1x2a.js";
10
+ } from "./react-yx3g9k55.js";
11
11
  import"./react-1gqwa2yw.js";
12
12
  import"./react-5rq7bnsy.js";
13
13
  import"./react-fp73vhyd.js";
@@ -6,7 +6,7 @@ import {
6
6
  grabEntry,
7
7
  joinEntries,
8
8
  quickEntry
9
- } from "./index-1mstjadm.js";
9
+ } from "./index-xs29b55n.js";
10
10
  import"./index-aymfvd8s.js";
11
11
  import"./index-t4kssacm.js";
12
12
  import"./index-a974q3aa.js";
@@ -52,7 +52,7 @@ export declare const MAX_BYTES: number;
52
52
  export declare const MAX_PAGES = 20;
53
53
  /** Why an edit was not made again. */
54
54
  export declare const REASONS: {
55
- readonly invalid: "not an edit devknobs reads";
55
+ readonly invalid: "not an edit knobs reads";
56
56
  readonly missing: "not found on the page";
57
57
  readonly rule: "its rule is not on the page";
58
58
  readonly changed: "the page has another value now";
@@ -4,7 +4,7 @@ import {
4
4
  HTML_MIN,
5
5
  forcedSelector,
6
6
  forcing
7
- } from "./index-dxga6h10.js";
7
+ } from "./index-tqq2ygpj.js";
8
8
  import"./index-58jdczmj.js";
9
9
  import {
10
10
  HIDE_ATTRIBUTE,
@@ -29,7 +29,7 @@ import {
29
29
  rulesOf,
30
30
  successor,
31
31
  textEdit
32
- } from "./index-69fvtkcm.js";
32
+ } from "./index-v2v4rmpe.js";
33
33
  import {
34
34
  compareSpecificity,
35
35
  edits,
@@ -38,7 +38,7 @@ import {
38
38
  readSavedEdit,
39
39
  specificity,
40
40
  splitList
41
- } from "./index-df35z48z.js";
41
+ } from "./index-q53j8wg5.js";
42
42
  import {
43
43
  boxValue,
44
44
  sizeText
@@ -93,11 +93,11 @@ import {
93
93
  segments,
94
94
  toolToggle,
95
95
  toolbar
96
- } from "./index-20bc9yrj.js";
96
+ } from "./index-fjrrgd9h.js";
97
97
  import {
98
98
  getState,
99
99
  subscribe
100
- } from "./index-pwqfmbqm.js";
100
+ } from "./index-8d1yk9d2.js";
101
101
  import {
102
102
  isMac
103
103
  } from "./index-s6yzsvs4.js";
@@ -107,7 +107,7 @@ import {
107
107
  letterMatches,
108
108
  typesInField,
109
109
  withShift
110
- } from "./index-whehz74d.js";
110
+ } from "./index-2jc9dnta.js";
111
111
  import {
112
112
  SIDES,
113
113
  boxModel,
@@ -479,7 +479,7 @@ var found = new WeakMap;
479
479
  var locateSource = (element) => {
480
480
  let pending = found.get(element);
481
481
  if (!pending) {
482
- pending = import("./context-svtr7vwt.js").then(({ grabEntry }) => grabEntry(element)).then(({ source }) => {
482
+ pending = import("./context-vd2xep5t.js").then(({ grabEntry }) => grabEntry(element)).then(({ source }) => {
483
483
  if (!source || source.origin !== "app")
484
484
  return null;
485
485
  return source.lineNumber ? `${source.filePath}:${source.lineNumber}` : source.filePath;
@@ -5,7 +5,7 @@ import {
5
5
  HTML_MIN,
6
6
  forcedSelector,
7
7
  forcing
8
- } from "./react-2b7725je.js";
8
+ } from "./react-3ev6rwqz.js";
9
9
  import"./react-97b5b8j4.js";
10
10
  import {
11
11
  HIDE_ATTRIBUTE,
@@ -30,7 +30,7 @@ import {
30
30
  rulesOf,
31
31
  successor,
32
32
  textEdit
33
- } from "./react-msn10fjb.js";
33
+ } from "./react-0gxs9aef.js";
34
34
  import {
35
35
  compareSpecificity,
36
36
  edits,
@@ -39,7 +39,7 @@ import {
39
39
  readSavedEdit,
40
40
  specificity,
41
41
  splitList
42
- } from "./react-5ekfj7g3.js";
42
+ } from "./react-8nmtt0ge.js";
43
43
  import {
44
44
  boxValue,
45
45
  sizeText
@@ -94,11 +94,11 @@ import {
94
94
  segments,
95
95
  toolToggle,
96
96
  toolbar
97
- } from "./react-y9gr8yt2.js";
97
+ } from "./react-actmnkwp.js";
98
98
  import {
99
99
  getState,
100
100
  subscribe
101
- } from "./react-smtqyzx0.js";
101
+ } from "./react-zp7fdw8e.js";
102
102
  import {
103
103
  isMac
104
104
  } from "./react-5h7pxnax.js";
@@ -108,7 +108,7 @@ import {
108
108
  letterMatches,
109
109
  typesInField,
110
110
  withShift
111
- } from "./react-vbk58f9m.js";
111
+ } from "./react-meve34wp.js";
112
112
  import {
113
113
  SIDES,
114
114
  boxModel,
@@ -480,7 +480,7 @@ var found = new WeakMap;
480
480
  var locateSource = (element) => {
481
481
  let pending = found.get(element);
482
482
  if (!pending) {
483
- pending = import("./context-amfyasb5.js").then(({ grabEntry }) => grabEntry(element)).then(({ source }) => {
483
+ pending = import("./context-eawqn680.js").then(({ grabEntry }) => grabEntry(element)).then(({ source }) => {
484
484
  if (!source || source.origin !== "app")
485
485
  return null;
486
486
  return source.lineNumber ? `${source.filePath}:${source.lineNumber}` : source.filePath;