@style-capture/core 0.0.1
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/LICENSE.md +21 -0
- package/README.md +100 -0
- package/dist/claude-export.d.ts +25 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1308 -0
- package/dist/index.js.map +1 -0
- package/dist/messages.d.ts +18 -0
- package/dist/tailwind-mapper.d.ts +59 -0
- package/dist/types.d.ts +53 -0
- package/package.json +65 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matthew Blode
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
<h3 align="center">@style-capture/core</h3>
|
|
2
|
+
<p align="center">Tailwind mapping, capture contracts, and Claude-ready serializers extracted from Style Capture.</p>
|
|
3
|
+
|
|
4
|
+
## Highlights
|
|
5
|
+
|
|
6
|
+
- Shared capture types and message contracts for Style Capture tooling
|
|
7
|
+
- Tailwind utility mapping with confidence, unsupported-property, and review metadata
|
|
8
|
+
- Compact Claude-friendly HTML and CSS serializers for captured DOM snapshots
|
|
9
|
+
|
|
10
|
+
## Quick Start
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @style-capture/core
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import {
|
|
18
|
+
createDefaultSettings,
|
|
19
|
+
formatCaptureForClaudeMarkdown,
|
|
20
|
+
mapCaptureToTailwind,
|
|
21
|
+
type CaptureResult,
|
|
22
|
+
} from "@style-capture/core";
|
|
23
|
+
|
|
24
|
+
const capture: CaptureResult = {
|
|
25
|
+
elements: {
|
|
26
|
+
"node-0": {
|
|
27
|
+
attributes: {},
|
|
28
|
+
boundingBox: {
|
|
29
|
+
bottom: 48,
|
|
30
|
+
height: 48,
|
|
31
|
+
left: 0,
|
|
32
|
+
right: 160,
|
|
33
|
+
top: 0,
|
|
34
|
+
width: 160,
|
|
35
|
+
x: 0,
|
|
36
|
+
y: 0,
|
|
37
|
+
},
|
|
38
|
+
children: [],
|
|
39
|
+
classList: [],
|
|
40
|
+
id: "node-0",
|
|
41
|
+
parentId: null,
|
|
42
|
+
pseudo: {},
|
|
43
|
+
selector: ".hero-card",
|
|
44
|
+
styles: {
|
|
45
|
+
"background-color": "rgb(255, 255, 255)",
|
|
46
|
+
display: "flex",
|
|
47
|
+
"justify-content": "space-between",
|
|
48
|
+
padding: "16px",
|
|
49
|
+
},
|
|
50
|
+
tagName: "div",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
metadata: {
|
|
54
|
+
url: "https://example.com/card",
|
|
55
|
+
},
|
|
56
|
+
order: ["node-0"],
|
|
57
|
+
rootElementId: "node-0",
|
|
58
|
+
rootOuterHtml: '<div class="hero-card">Hello</div>',
|
|
59
|
+
settings: createDefaultSettings(),
|
|
60
|
+
summary: {
|
|
61
|
+
elementCount: 1,
|
|
62
|
+
pseudoElementCount: 0,
|
|
63
|
+
},
|
|
64
|
+
version: 1,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const mapping = mapCaptureToTailwind(capture);
|
|
68
|
+
const prompt = formatCaptureForClaudeMarkdown(capture, mapping);
|
|
69
|
+
|
|
70
|
+
console.log(mapping.elements["node-0"]?.suggestedClassName);
|
|
71
|
+
console.log(prompt);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Usage
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import {
|
|
78
|
+
buildClaudeCapturePrompt,
|
|
79
|
+
createDefaultSettings,
|
|
80
|
+
mapCaptureToTailwind,
|
|
81
|
+
} from "@style-capture/core";
|
|
82
|
+
|
|
83
|
+
const settings = createDefaultSettings();
|
|
84
|
+
const mapping = mapCaptureToTailwind(capture);
|
|
85
|
+
const prompt = buildClaudeCapturePrompt(capture, mapping);
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Public exports:
|
|
89
|
+
|
|
90
|
+
- `createDefaultSettings`
|
|
91
|
+
- `mapCaptureToTailwind`
|
|
92
|
+
- `buildClaudeCapturePrompt`
|
|
93
|
+
- `formatCaptureForClaudeMarkdown`
|
|
94
|
+
- Capture result, mapping, and message types from the package root
|
|
95
|
+
|
|
96
|
+
Requires a runtime with standard DOM globals if you want annotated HTML output. When `DOMParser` is unavailable, the serializer falls back to compact raw HTML and selector-based CSS output.
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
[MIT](LICENSE.md)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TailwindMappingResult } from "./tailwind-mapper.ts";
|
|
2
|
+
import type { CaptureResult } from "./types.ts";
|
|
3
|
+
interface ClaudePromptEntry {
|
|
4
|
+
key: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
interface ClaudePromptMetadata {
|
|
8
|
+
elementCount: number;
|
|
9
|
+
mode: CaptureResult["settings"]["captureMode"];
|
|
10
|
+
pseudoCount: number;
|
|
11
|
+
rootRef: string;
|
|
12
|
+
rootSelector: string;
|
|
13
|
+
url: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ClaudeCapturePrompt {
|
|
16
|
+
cssCapture: string;
|
|
17
|
+
htmlCapture: string;
|
|
18
|
+
instruction: string;
|
|
19
|
+
metadata: ClaudePromptMetadata;
|
|
20
|
+
openQuestions: ClaudePromptEntry[];
|
|
21
|
+
tailwindHints: ClaudePromptEntry[];
|
|
22
|
+
}
|
|
23
|
+
export declare const buildClaudeCapturePrompt: (capture: CaptureResult, mapping: TailwindMappingResult | null) => ClaudeCapturePrompt;
|
|
24
|
+
export declare const formatCaptureForClaudeMarkdown: (capture: CaptureResult, mapping: TailwindMappingResult | null) => string;
|
|
25
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { buildClaudeCapturePrompt, type ClaudeCapturePrompt, formatCaptureForClaudeMarkdown, } from "./claude-export.ts";
|
|
2
|
+
export type { CaptureCancelledMessage, CaptureCompletedMessage, CaptureFailedMessage, ExtensionMessage, } from "./messages.ts";
|
|
3
|
+
export { createDefaultSettings, MESSAGE_TYPE_CAPTURE_CANCELLED, MESSAGE_TYPE_CAPTURE_COMPLETED, MESSAGE_TYPE_CAPTURE_FAILED, } from "./messages.ts";
|
|
4
|
+
export { mapCaptureToTailwind, type TailwindElementMapping, type TailwindMappingResult, type TailwindMappingSummary, type TailwindReviewItem, } from "./tailwind-mapper.ts";
|
|
5
|
+
export type { BoundingBox, CaptureMetadata, CaptureMode, CaptureResult, CaptureSettings, CaptureSummary, ElementSnapshot, PseudoElementKind, PseudoElementSnapshot, } from "./types.ts";
|