style-capture 0.0.1 → 0.0.3

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/src/run.ts DELETED
@@ -1,106 +0,0 @@
1
- import type { CaptureSettings } from "@style-capture/core";
2
- import {
3
- createDefaultSettings,
4
- formatCaptureForClaudeMarkdown,
5
- mapCaptureToTailwind,
6
- } from "@style-capture/core";
7
- import { chromium } from "playwright";
8
-
9
- import { captureElement } from "./capture.ts";
10
-
11
- export interface RunOptions {
12
- mode?: "curated" | "full";
13
- selector: string;
14
- url: string;
15
- }
16
-
17
- /**
18
- * Non-interactive capture — designed for agent/skill usage.
19
- * Returns the formatted style_capture prompt as a string.
20
- */
21
- export async function run(options: RunOptions): Promise<string> {
22
- const settings: CaptureSettings = {
23
- ...createDefaultSettings(),
24
- captureMode: options.mode ?? "curated",
25
- };
26
-
27
- const browser = await chromium.launch({ headless: true });
28
- try {
29
- const page = await browser.newPage();
30
- await page.goto(options.url, { waitUntil: "networkidle" });
31
-
32
- const count = await page.locator(options.selector).count();
33
- if (count === 0) {
34
- throw new Error(
35
- `Selector "${options.selector}" matched 0 elements on ${options.url}`
36
- );
37
- }
38
-
39
- if (count > 1) {
40
- process.stderr.write(
41
- `Warning: selector matched ${count} elements, capturing the first\n`
42
- );
43
- }
44
-
45
- const capture = await captureElement(page, options.selector, settings);
46
- const mapping = mapCaptureToTailwind(capture);
47
- const output = formatCaptureForClaudeMarkdown(capture, mapping);
48
-
49
- process.stderr.write(
50
- `Captured ${capture.summary.elementCount} elements, ${mapping.summary.utilityCount} Tailwind utilities mapped\n`
51
- );
52
-
53
- return output;
54
- } finally {
55
- await browser.close();
56
- }
57
- }
58
-
59
- function parseArgs(argv: string[]): RunOptions {
60
- const args = argv.slice(2);
61
-
62
- // Support both positional and flag-based args
63
- let url: string | undefined;
64
- let selector: string | undefined;
65
- let mode: "curated" | "full" = "curated";
66
-
67
- for (let i = 0; i < args.length; i++) {
68
- const arg = args[i];
69
- if (arg === "--mode" && args[i + 1]) {
70
- mode = args[i + 1] as "curated" | "full";
71
- i++;
72
- } else if (arg === "--url" && args[i + 1]) {
73
- url = args[i + 1];
74
- i++;
75
- } else if (arg === "--selector" && args[i + 1]) {
76
- selector = args[i + 1];
77
- i++;
78
- } else if (!url) {
79
- url = arg;
80
- } else if (!selector) {
81
- selector = arg;
82
- }
83
- }
84
-
85
- if (!(url && selector)) {
86
- process.stderr.write(
87
- "Usage: style-capture <url> <selector> [--mode curated|full]\n"
88
- );
89
- process.stderr.write(
90
- " style-capture --url <url> --selector <selector>\n"
91
- );
92
- process.exit(1);
93
- }
94
-
95
- return { url, selector, mode };
96
- }
97
-
98
- const options = parseArgs(process.argv);
99
- run(options)
100
- .then((result) => {
101
- process.stdout.write(result);
102
- })
103
- .catch((error) => {
104
- process.stderr.write(`Error: ${String(error)}\n`);
105
- process.exit(1);
106
- });
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
4
- "target": "ES2023",
5
- "module": "ESNext",
6
- "moduleResolution": "bundler",
7
- "allowImportingTsExtensions": true,
8
- "verbatimModuleSyntax": true,
9
- "moduleDetection": "force",
10
- "noEmit": true,
11
- "strict": true,
12
- "skipLibCheck": true,
13
- "noUnusedLocals": true,
14
- "noUnusedParameters": true,
15
- "erasableSyntaxOnly": true,
16
- "noFallthroughCasesInSwitch": true,
17
- "types": ["node"]
18
- },
19
- "include": ["src"]
20
- }