uilint-react 0.2.1 → 0.2.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.
Files changed (120) hide show
  1. package/dist/DevTool.d.ts +11 -0
  2. package/dist/DevTool.d.ts.map +1 -0
  3. package/dist/ElementBadges-BNRIjtRW.js +672 -0
  4. package/dist/ElementBadges-BNRIjtRW.js.map +1 -0
  5. package/dist/VisionIssueBadge-C6vfwtec.js +154 -0
  6. package/dist/VisionIssueBadge-C6vfwtec.js.map +1 -0
  7. package/dist/components/Highlighter.d.ts +6 -0
  8. package/dist/components/Highlighter.d.ts.map +1 -0
  9. package/dist/components/ui-lint/ElementBadges.d.ts +6 -0
  10. package/dist/components/ui-lint/ElementBadges.d.ts.map +1 -0
  11. package/dist/components/ui-lint/InspectionPanel.d.ts +6 -0
  12. package/dist/components/ui-lint/InspectionPanel.d.ts.map +1 -0
  13. package/dist/components/ui-lint/LocatorOverlay.d.ts +14 -0
  14. package/dist/components/ui-lint/LocatorOverlay.d.ts.map +1 -0
  15. package/dist/components/ui-lint/RegionSelector.d.ts +18 -0
  16. package/dist/components/ui-lint/RegionSelector.d.ts.map +1 -0
  17. package/dist/components/ui-lint/ScanResultsPopover.d.ts +6 -0
  18. package/dist/components/ui-lint/ScanResultsPopover.d.ts.map +1 -0
  19. package/dist/components/ui-lint/ScreenshotViewer.d.ts +11 -0
  20. package/dist/components/ui-lint/ScreenshotViewer.d.ts.map +1 -0
  21. package/dist/components/ui-lint/UILintProvider.d.ts +11 -0
  22. package/dist/components/ui-lint/UILintProvider.d.ts.map +1 -0
  23. package/dist/components/ui-lint/VisionIssueBadge.d.ts +6 -0
  24. package/dist/components/ui-lint/VisionIssueBadge.d.ts.map +1 -0
  25. package/dist/components/ui-lint/VisionIssuesPanel.d.ts +12 -0
  26. package/dist/components/ui-lint/VisionIssuesPanel.d.ts.map +1 -0
  27. package/dist/components/ui-lint/badge-layout.d.ts +91 -0
  28. package/dist/components/ui-lint/badge-layout.d.ts.map +1 -0
  29. package/dist/components/ui-lint/code-formatting.d.ts +14 -0
  30. package/dist/components/ui-lint/code-formatting.d.ts.map +1 -0
  31. package/dist/components/ui-lint/dom-utils.d.ts +43 -0
  32. package/dist/components/ui-lint/dom-utils.d.ts.map +1 -0
  33. package/dist/components/ui-lint/index.d.ts +22 -0
  34. package/dist/components/ui-lint/index.d.ts.map +1 -0
  35. package/dist/components/ui-lint/inspection-panel-positioning.d.ts +41 -0
  36. package/dist/components/ui-lint/inspection-panel-positioning.d.ts.map +1 -0
  37. package/dist/components/ui-lint/portal-host.d.ts +3 -0
  38. package/dist/components/ui-lint/portal-host.d.ts.map +1 -0
  39. package/dist/components/ui-lint/scan-results/FileTree.d.ts +25 -0
  40. package/dist/components/ui-lint/scan-results/FileTree.d.ts.map +1 -0
  41. package/dist/components/ui-lint/scan-results/IssueRow.d.ts +16 -0
  42. package/dist/components/ui-lint/scan-results/IssueRow.d.ts.map +1 -0
  43. package/dist/components/ui-lint/scan-results/SearchFilter.d.ts +8 -0
  44. package/dist/components/ui-lint/scan-results/SearchFilter.d.ts.map +1 -0
  45. package/dist/components/ui-lint/source-fetcher.d.ts +40 -0
  46. package/dist/components/ui-lint/source-fetcher.d.ts.map +1 -0
  47. package/dist/components/ui-lint/store.d.ts +194 -0
  48. package/dist/components/ui-lint/store.d.ts.map +1 -0
  49. package/dist/components/ui-lint/toolbar/TabbedToolbar.d.ts +2 -0
  50. package/dist/components/ui-lint/toolbar/TabbedToolbar.d.ts.map +1 -0
  51. package/dist/components/ui-lint/toolbar/icons.d.ts +29 -0
  52. package/dist/components/ui-lint/toolbar/icons.d.ts.map +1 -0
  53. package/dist/components/ui-lint/toolbar/index.d.ts +3 -0
  54. package/dist/components/ui-lint/toolbar/index.d.ts.map +1 -0
  55. package/dist/components/ui-lint/toolbar/tabs/ConfigureTab.d.ts +2 -0
  56. package/dist/components/ui-lint/toolbar/tabs/ConfigureTab.d.ts.map +1 -0
  57. package/dist/components/ui-lint/toolbar/tabs/ESLintTab.d.ts +2 -0
  58. package/dist/components/ui-lint/toolbar/tabs/ESLintTab.d.ts.map +1 -0
  59. package/dist/components/ui-lint/toolbar/tabs/VisionTab.d.ts +2 -0
  60. package/dist/components/ui-lint/toolbar/tabs/VisionTab.d.ts.map +1 -0
  61. package/dist/components/ui-lint/toolbar/tokens.d.ts +45 -0
  62. package/dist/components/ui-lint/toolbar/tokens.d.ts.map +1 -0
  63. package/dist/components/ui-lint/types.d.ts +170 -0
  64. package/dist/components/ui-lint/types.d.ts.map +1 -0
  65. package/dist/components/ui-lint/useDOMObserver.d.ts +11 -0
  66. package/dist/components/ui-lint/useDOMObserver.d.ts.map +1 -0
  67. package/dist/components/ui-lint/visibility-utils.d.ts +41 -0
  68. package/dist/components/ui-lint/visibility-utils.d.ts.map +1 -0
  69. package/dist/consistency/highlights.d.ts +14 -0
  70. package/dist/consistency/highlights.d.ts.map +1 -0
  71. package/dist/consistency/index.d.ts +7 -0
  72. package/dist/consistency/index.d.ts.map +1 -0
  73. package/dist/consistency/snapshot.d.ts +14 -0
  74. package/dist/consistency/snapshot.d.ts.map +1 -0
  75. package/dist/consistency/types.d.ts +5 -0
  76. package/dist/consistency/types.d.ts.map +1 -0
  77. package/dist/devtools.d.ts +8 -0
  78. package/dist/devtools.d.ts.map +1 -0
  79. package/dist/devtools.js +259 -0
  80. package/dist/devtools.js.map +1 -0
  81. package/dist/environment-DVxa60C6.js +26 -0
  82. package/dist/environment-DVxa60C6.js.map +1 -0
  83. package/dist/index-BGzkrD0y.js +12304 -0
  84. package/dist/index-BGzkrD0y.js.map +1 -0
  85. package/dist/index-L3Zm-CoX.js +513 -0
  86. package/dist/index-L3Zm-CoX.js.map +1 -0
  87. package/dist/index.d.ts +13 -339
  88. package/dist/index.d.ts.map +1 -0
  89. package/dist/index.js +43 -482
  90. package/dist/index.js.map +1 -0
  91. package/dist/lib/utils.d.ts +11 -0
  92. package/dist/lib/utils.d.ts.map +1 -0
  93. package/dist/node.d.ts +7 -38
  94. package/dist/node.d.ts.map +1 -0
  95. package/dist/node.js +32 -79
  96. package/dist/node.js.map +1 -0
  97. package/dist/scanner/dom-scanner.d.ts +7 -0
  98. package/dist/scanner/dom-scanner.d.ts.map +1 -0
  99. package/dist/scanner/environment.d.ts +16 -0
  100. package/dist/scanner/environment.d.ts.map +1 -0
  101. package/dist/scanner/jsdom-adapter.d.ts +30 -0
  102. package/dist/scanner/jsdom-adapter.d.ts.map +1 -0
  103. package/dist/scanner/vision-capture.d.ts +131 -0
  104. package/dist/scanner/vision-capture.d.ts.map +1 -0
  105. package/dist/styles/inject-styles.d.ts +2 -0
  106. package/dist/styles/inject-styles.d.ts.map +1 -0
  107. package/dist/vision-capture-EIrYA_XF.js +216 -0
  108. package/dist/vision-capture-EIrYA_XF.js.map +1 -0
  109. package/dist/web-component.d.ts +2 -0
  110. package/dist/web-component.d.ts.map +1 -0
  111. package/package.json +36 -7
  112. package/dist/ElementBadges-2CTPMJ6L.js +0 -825
  113. package/dist/InspectionPanel-NXSE7CMH.js +0 -10
  114. package/dist/LocatorOverlay-3TKK74BD.js +0 -11
  115. package/dist/UILintToolbar-CLVXQHCZ.js +0 -10
  116. package/dist/chunk-552GIJIQ.js +0 -1109
  117. package/dist/chunk-K46BWHFU.js +0 -271
  118. package/dist/chunk-KKNPFLL2.js +0 -1853
  119. package/dist/chunk-S4IWHBOQ.js +0 -178
  120. package/dist/chunk-Z4AAGFIN.js +0 -933
package/dist/index.js CHANGED
@@ -1,484 +1,45 @@
1
- "use client";
2
- import {
3
- UILintToolbar
4
- } from "./chunk-KKNPFLL2.js";
5
- import {
6
- InspectionPanel
7
- } from "./chunk-Z4AAGFIN.js";
8
- import {
9
- clearSourceCache,
10
- fetchSource,
11
- fetchSourceWithContext,
12
- getCachedSource,
13
- prefetchSources
14
- } from "./chunk-S4IWHBOQ.js";
15
- import {
16
- LocatorOverlay
17
- } from "./chunk-K46BWHFU.js";
18
- import {
19
- DATA_UILINT_ID,
20
- DEFAULT_SETTINGS,
21
- FILE_COLORS,
22
- UILintProvider,
23
- buildEditorUrl,
24
- cleanupDataAttributes,
25
- getDisplayName,
26
- getElementById,
27
- getSourceFromDataLoc,
28
- groupBySourceFile,
29
- isNodeModulesPath,
30
- scanDOMForSources,
31
- updateElementRects,
32
- useUILintContext
33
- } from "./chunk-552GIJIQ.js";
34
-
35
- // src/consistency/snapshot.ts
36
- var DATA_ELEMENTS_ATTR = "data-elements";
37
- var SKIP_TAGS = /* @__PURE__ */ new Set(["SCRIPT", "STYLE", "SVG", "NOSCRIPT", "TEMPLATE"]);
38
- var CONTEXT_ELEMENTS = /* @__PURE__ */ new Set([
39
- "HEADER",
40
- "NAV",
41
- "MAIN",
42
- "FOOTER",
43
- "SECTION",
44
- "ARTICLE",
45
- "ASIDE"
46
- ]);
47
- var CLASS_PATTERNS = {
48
- button: /\b(btn|button)\b/i,
49
- card: /\b(card)\b/i,
50
- input: /\b(input|field|form-control)\b/i,
51
- link: /\b(link)\b/i
52
- };
53
- var elementCounter = 0;
54
- function cleanupDataElements() {
55
- const elements = document.querySelectorAll(`[${DATA_ELEMENTS_ATTR}]`);
56
- elements.forEach((el) => el.removeAttribute(DATA_ELEMENTS_ATTR));
57
- elementCounter = 0;
58
- }
59
- function generateElementId() {
60
- return `el-${++elementCounter}`;
61
- }
62
- function truncateText(text, maxLen = 50) {
63
- const cleaned = text.trim().replace(/\s+/g, " ");
64
- if (cleaned.length <= maxLen) return cleaned;
65
- return cleaned.slice(0, maxLen - 3) + "...";
66
- }
67
- function inferRole(el, styles) {
68
- const ariaRole = el.getAttribute("role");
69
- if (ariaRole) {
70
- if (ariaRole === "button") return "button";
71
- if (ariaRole === "link") return "link";
72
- if (ariaRole === "textbox" || ariaRole === "searchbox") return "input";
73
- if (ariaRole === "heading") return "heading";
74
- }
75
- const tag = el.tagName.toUpperCase();
76
- if (tag === "BUTTON") return "button";
77
- if (tag === "A") return "link";
78
- if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") return "input";
79
- if (/^H[1-6]$/.test(tag)) return "heading";
80
- const component = el.getAttribute("data-ui-component");
81
- if (component) {
82
- const lower = component.toLowerCase();
83
- if (lower.includes("button")) return "button";
84
- if (lower.includes("card")) return "card";
85
- if (lower.includes("input") || lower.includes("field")) return "input";
86
- if (lower.includes("link")) return "link";
87
- }
88
- const className = el.className;
89
- if (typeof className === "string") {
90
- if (CLASS_PATTERNS.button.test(className)) return "button";
91
- if (CLASS_PATTERNS.card.test(className)) return "card";
92
- if (CLASS_PATTERNS.input.test(className)) return "input";
93
- if (CLASS_PATTERNS.link.test(className)) return "link";
94
- }
95
- if (isCard(el, styles)) return "card";
96
- if (isContainer(styles)) return "container";
97
- const text = el.textContent?.trim() || "";
98
- if (text.length > 0 && text.length < 200) return "text";
99
- return "other";
100
- }
101
- function isCard(el, styles) {
102
- if (el.children.length === 0) return false;
103
- const hasBoxShadow = styles.boxShadow && styles.boxShadow !== "none";
104
- const hasBg = styles.backgroundColor && styles.backgroundColor !== "transparent" && styles.backgroundColor !== "rgba(0, 0, 0, 0)";
105
- const hasBorder = styles.border && styles.border !== "none" && !styles.border.includes("0px");
106
- const hasRadius = styles.borderRadius && styles.borderRadius !== "0px";
107
- return Boolean(hasBoxShadow || (hasBg || hasBorder) && hasRadius);
108
- }
109
- function isContainer(styles) {
110
- const display = styles.display;
111
- if (display !== "flex" && display !== "grid") return false;
112
- const gap = styles.gap;
113
- if (gap && gap !== "normal" && gap !== "0px") return true;
114
- const padding = styles.padding;
115
- if (padding && padding !== "0px") {
116
- const match = padding.match(/(\d+)px/);
117
- if (match && parseInt(match[1], 10) > 8) return true;
118
- }
119
- return false;
120
- }
121
- function buildContext(el) {
122
- const parts = [];
123
- let current = el.parentElement;
124
- while (current && parts.length < 3) {
125
- const tag = current.tagName.toUpperCase();
126
- if (CONTEXT_ELEMENTS.has(tag)) {
127
- parts.unshift(tag.toLowerCase());
128
- }
129
- current = current.parentElement;
130
- }
131
- return parts.join(" > ") || "root";
132
- }
133
- function extractStyles(styles) {
134
- return {
135
- fontSize: styles.fontSize || void 0,
136
- fontWeight: styles.fontWeight || void 0,
137
- color: styles.color || void 0,
138
- backgroundColor: styles.backgroundColor === "rgba(0, 0, 0, 0)" ? void 0 : styles.backgroundColor || void 0,
139
- padding: styles.padding === "0px" ? void 0 : styles.padding || void 0,
140
- borderRadius: styles.borderRadius === "0px" ? void 0 : styles.borderRadius || void 0,
141
- border: styles.border === "none" || styles.border?.includes("0px") ? void 0 : styles.border || void 0,
142
- boxShadow: styles.boxShadow === "none" ? void 0 : styles.boxShadow || void 0,
143
- gap: styles.gap === "normal" || styles.gap === "0px" ? void 0 : styles.gap || void 0
144
- };
145
- }
146
- function shouldSkip(el) {
147
- if (SKIP_TAGS.has(el.tagName.toUpperCase())) return true;
148
- if (el.hasAttribute("data-ui-lint-ignore")) return true;
149
- if (el.getAttribute("aria-hidden") === "true") return true;
150
- const styles = window.getComputedStyle(el);
151
- if (styles.display === "none" || styles.visibility === "hidden") return true;
152
- return false;
153
- }
154
- function snapshotElement(el) {
155
- if (shouldSkip(el)) return null;
156
- const styles = window.getComputedStyle(el);
157
- const role = inferRole(el, styles);
158
- if (role === "other") return null;
159
- const id = generateElementId();
160
- el.setAttribute(DATA_ELEMENTS_ATTR, id);
161
- const rect = el.getBoundingClientRect();
162
- const text = el.textContent?.trim().slice(0, 100) || el.getAttribute("aria-label") || "";
163
- return {
164
- id,
165
- tag: el.tagName.toLowerCase(),
166
- role,
167
- text: truncateText(text),
168
- component: el.getAttribute("data-ui-component") || void 0,
169
- context: buildContext(el),
170
- styles: extractStyles(styles),
171
- rect: {
172
- width: Math.round(rect.width),
173
- height: Math.round(rect.height)
174
- }
175
- };
176
- }
177
- function createSnapshot(root) {
178
- cleanupDataElements();
179
- const targetRoot = root || document.body;
180
- const snapshot = {
181
- buttons: [],
182
- headings: [],
183
- cards: [],
184
- links: [],
185
- inputs: [],
186
- containers: []
187
- };
188
- const walker = document.createTreeWalker(
189
- targetRoot,
190
- NodeFilter.SHOW_ELEMENT,
191
- {
192
- acceptNode: (node2) => {
193
- const el = node2;
194
- if (shouldSkip(el)) return NodeFilter.FILTER_REJECT;
195
- return NodeFilter.FILTER_ACCEPT;
196
- }
197
- }
198
- );
199
- let node = walker.currentNode;
200
- while (node) {
201
- if (node instanceof Element) {
202
- const elementSnapshot = snapshotElement(node);
203
- if (elementSnapshot) {
204
- switch (elementSnapshot.role) {
205
- case "button":
206
- snapshot.buttons.push(elementSnapshot);
207
- break;
208
- case "heading":
209
- snapshot.headings.push(elementSnapshot);
210
- break;
211
- case "card":
212
- snapshot.cards.push(elementSnapshot);
213
- break;
214
- case "link":
215
- snapshot.links.push(elementSnapshot);
216
- break;
217
- case "input":
218
- snapshot.inputs.push(elementSnapshot);
219
- break;
220
- case "container":
221
- snapshot.containers.push(elementSnapshot);
222
- break;
223
- }
224
- }
225
- }
226
- node = walker.nextNode();
227
- }
228
- return snapshot;
229
- }
230
- function getElementBySnapshotId(id) {
231
- return document.querySelector(`[${DATA_ELEMENTS_ATTR}="${id}"]`);
232
- }
233
-
234
- // src/consistency/highlights.tsx
235
- import { useEffect, useState, useCallback } from "react";
236
- import { createPortal } from "react-dom";
237
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
238
- var HIGHLIGHT_COLOR = "#3b82f6";
239
- var DOT_SIZE = 8;
240
- var BORDER_WIDTH = 2;
241
- function calculateHighlights(elementIds, withBadges = false) {
242
- const highlights = [];
243
- elementIds.forEach((id, index) => {
244
- const el = getElementBySnapshotId(id);
245
- if (!el) return;
246
- const rect = el.getBoundingClientRect();
247
- highlights.push({
248
- id,
249
- rect: {
250
- top: rect.top,
251
- left: rect.left,
252
- width: rect.width,
253
- height: rect.height
254
- },
255
- badgeNumber: withBadges && elementIds.length > 1 ? index + 1 : void 0
256
- });
257
- });
258
- return highlights;
259
- }
260
- function getAllViolatingIds(violations) {
261
- const ids = /* @__PURE__ */ new Set();
262
- violations.forEach((v) => {
263
- v.elementIds.forEach((id) => ids.add(id));
264
- });
265
- return ids;
266
- }
267
- function OverviewDot({ rect }) {
268
- return /* @__PURE__ */ jsx(
269
- "div",
270
- {
271
- style: {
272
- position: "fixed",
273
- top: rect.top - DOT_SIZE / 2,
274
- left: rect.left + rect.width - DOT_SIZE / 2,
275
- width: DOT_SIZE,
276
- height: DOT_SIZE,
277
- borderRadius: "50%",
278
- backgroundColor: HIGHLIGHT_COLOR,
279
- pointerEvents: "none",
280
- zIndex: 99997,
281
- boxShadow: "0 0 4px rgba(59, 130, 246, 0.5)"
282
- }
283
- }
284
- );
285
- }
286
- function HighlightRect({
287
- rect,
288
- badgeNumber
289
- }) {
290
- return /* @__PURE__ */ jsxs(Fragment, { children: [
291
- /* @__PURE__ */ jsx(
292
- "div",
293
- {
294
- style: {
295
- position: "fixed",
296
- top: rect.top - BORDER_WIDTH,
297
- left: rect.left - BORDER_WIDTH,
298
- width: rect.width + BORDER_WIDTH * 2,
299
- height: rect.height + BORDER_WIDTH * 2,
300
- border: `${BORDER_WIDTH}px solid ${HIGHLIGHT_COLOR}`,
301
- borderRadius: 4,
302
- backgroundColor: `${HIGHLIGHT_COLOR}10`,
303
- pointerEvents: "none",
304
- zIndex: 99998,
305
- transition: "all 0.15s ease-out"
306
- }
307
- }
308
- ),
309
- badgeNumber !== void 0 && /* @__PURE__ */ jsx(
310
- "div",
311
- {
312
- style: {
313
- position: "fixed",
314
- top: rect.top - 12,
315
- left: rect.left - 4,
316
- minWidth: 20,
317
- height: 20,
318
- borderRadius: 10,
319
- backgroundColor: HIGHLIGHT_COLOR,
320
- color: "white",
321
- fontSize: 11,
322
- fontWeight: 600,
323
- display: "flex",
324
- alignItems: "center",
325
- justifyContent: "center",
326
- padding: "0 6px",
327
- pointerEvents: "none",
328
- zIndex: 99999,
329
- fontFamily: "system-ui, -apple-system, sans-serif"
330
- },
331
- children: badgeNumber
332
- }
333
- )
334
- ] });
335
- }
336
- function ConsistencyHighlighter({
337
- violations,
338
- selectedViolation,
339
- lockedViolation
340
- }) {
341
- const [overviewHighlights, setOverviewHighlights] = useState([]);
342
- const [activeHighlights, setActiveHighlights] = useState(
343
- []
344
- );
345
- const [mounted, setMounted] = useState(false);
346
- const activeViolation = lockedViolation || selectedViolation;
347
- const updateOverviewHighlights = useCallback(() => {
348
- if (activeViolation) {
349
- setOverviewHighlights([]);
350
- return;
351
- }
352
- const allIds = getAllViolatingIds(violations);
353
- const highlights = [];
354
- allIds.forEach((id) => {
355
- const el = getElementBySnapshotId(id);
356
- if (!el) return;
357
- const rect = el.getBoundingClientRect();
358
- highlights.push({
359
- id,
360
- rect: {
361
- top: rect.top,
362
- left: rect.left,
363
- width: rect.width,
364
- height: rect.height
365
- }
366
- });
367
- });
368
- setOverviewHighlights(highlights);
369
- }, [violations, activeViolation]);
370
- const updateActiveHighlights = useCallback(() => {
371
- if (!activeViolation) {
372
- setActiveHighlights([]);
373
- return;
374
- }
375
- const highlights = calculateHighlights(activeViolation.elementIds, true);
376
- setActiveHighlights(highlights);
377
- }, [activeViolation]);
378
- useEffect(() => {
379
- setMounted(true);
380
- return () => setMounted(false);
381
- }, []);
382
- useEffect(() => {
383
- updateOverviewHighlights();
384
- updateActiveHighlights();
385
- const handleUpdate = () => {
386
- updateOverviewHighlights();
387
- updateActiveHighlights();
388
- };
389
- window.addEventListener("scroll", handleUpdate, true);
390
- window.addEventListener("resize", handleUpdate);
391
- return () => {
392
- window.removeEventListener("scroll", handleUpdate, true);
393
- window.removeEventListener("resize", handleUpdate);
394
- };
395
- }, [updateOverviewHighlights, updateActiveHighlights]);
396
- if (!mounted) return null;
397
- if (violations.length === 0) return null;
398
- const content = /* @__PURE__ */ jsxs(Fragment, { children: [
399
- !activeViolation && overviewHighlights.map((h) => /* @__PURE__ */ jsx(OverviewDot, { rect: h.rect }, h.id)),
400
- activeViolation && activeHighlights.map((h) => /* @__PURE__ */ jsx(HighlightRect, { rect: h.rect, badgeNumber: h.badgeNumber }, h.id))
401
- ] });
402
- return createPortal(content, document.body);
403
- }
404
-
405
- // src/scanner/dom-scanner.ts
406
- import {
407
- extractStylesFromDOM,
408
- createStyleSummary,
409
- serializeStyles,
410
- truncateHTML
411
- } from "uilint-core";
412
- function scanDOM(root) {
413
- const targetRoot = root || document.body;
414
- const styles = extractStylesFromDOM(targetRoot);
415
- const html = targetRoot instanceof Element ? targetRoot.outerHTML : targetRoot.body?.outerHTML || "";
416
- return {
417
- html: truncateHTML(html, 5e4),
418
- styles,
419
- elementCount: targetRoot.querySelectorAll("*").length,
420
- timestamp: Date.now()
421
- };
422
- }
423
-
424
- // src/scanner/environment.ts
425
- function isBrowser() {
426
- return typeof window !== "undefined" && typeof window.document !== "undefined";
427
- }
428
- function isJSDOM() {
429
- if (!isBrowser()) return false;
430
- const userAgent = window.navigator?.userAgent || "";
431
- return userAgent.includes("jsdom");
432
- }
433
- function isNode() {
434
- return typeof process !== "undefined" && process.versions != null && process.versions.node != null;
435
- }
436
-
437
- // src/index.ts
438
- import {
439
- extractStylesFromDOM as extractStylesFromDOM2,
440
- serializeStyles as serializeStyles2,
441
- createStyleSummary as createStyleSummary2
442
- } from "uilint-core";
443
- import { parseStyleGuide } from "uilint-core";
444
- import { generateStyleGuideFromStyles } from "uilint-core";
445
- import { createEmptyStyleGuide, mergeStyleGuides } from "uilint-core";
1
+ import { C as r, r as o, D as i, F as c, I as l, L as S, U as n, b as u, h as m, d as p, v as y, o as d, t as h, m as D, n as I, p as g, k as L, e as E, w as F, l as f, c as C, i as O, q as U, s as x, f as G, u as T } from "./index-BGzkrD0y.js";
2
+ import "react";
3
+ import "react-dom";
4
+ import { i as M, a as N, b as A, s as B } from "./environment-DVxa60C6.js";
5
+ import { createEmptyStyleGuide as v, createStyleSummary as P, extractStylesFromDOM as w, generateStyleGuideFromStyles as R, mergeStyleGuides as k, parseStyleGuide as q, serializeStyles as z } from "uilint-core";
446
6
  export {
447
- ConsistencyHighlighter,
448
- DATA_UILINT_ID,
449
- DEFAULT_SETTINGS,
450
- FILE_COLORS,
451
- InspectionPanel,
452
- LocatorOverlay,
453
- UILintProvider,
454
- UILintToolbar,
455
- buildEditorUrl,
456
- cleanupDataAttributes,
457
- cleanupDataElements,
458
- clearSourceCache,
459
- createEmptyStyleGuide,
460
- createSnapshot,
461
- createStyleSummary2 as createStyleSummary,
462
- extractStylesFromDOM2 as extractStylesFromDOM,
463
- fetchSource,
464
- fetchSourceWithContext,
465
- generateStyleGuideFromStyles as generateStyleGuide,
466
- getCachedSource,
467
- getDisplayName,
468
- getElementById,
469
- getElementBySnapshotId,
470
- getSourceFromDataLoc,
471
- groupBySourceFile,
472
- isBrowser,
473
- isJSDOM,
474
- isNode,
475
- isNodeModulesPath,
476
- mergeStyleGuides,
477
- parseStyleGuide,
478
- prefetchSources,
479
- scanDOM,
480
- scanDOMForSources,
481
- serializeStyles2 as serializeStyles,
482
- updateElementRects,
483
- useUILintContext
7
+ r as ConsistencyHighlighter,
8
+ o as DATA_UILINT_ID,
9
+ i as DEFAULT_SETTINGS,
10
+ c as FILE_COLORS,
11
+ l as InspectionPanel,
12
+ S as LocatorOverlay,
13
+ n as UILintProvider,
14
+ u as UILintToolbar,
15
+ m as buildEditorUrl,
16
+ p as cleanupDataAttributes,
17
+ y as cleanupDataElements,
18
+ d as clearSourceCache,
19
+ v as createEmptyStyleGuide,
20
+ h as createSnapshot,
21
+ P as createStyleSummary,
22
+ w as extractStylesFromDOM,
23
+ D as fetchSource,
24
+ I as fetchSourceWithContext,
25
+ R as generateStyleGuide,
26
+ g as getCachedSource,
27
+ L as getDisplayName,
28
+ E as getElementById,
29
+ F as getElementBySnapshotId,
30
+ f as getSourceFromDataLoc,
31
+ C as groupBySourceFile,
32
+ M as isBrowser,
33
+ N as isJSDOM,
34
+ A as isNode,
35
+ O as isNodeModulesPath,
36
+ k as mergeStyleGuides,
37
+ q as parseStyleGuide,
38
+ U as prefetchSources,
39
+ B as scanDOM,
40
+ x as scanDOMForSources,
41
+ z as serializeStyles,
42
+ G as updateElementRects,
43
+ T as useUILintContext
484
44
  };
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -0,0 +1,11 @@
1
+ import { ClassValue } from 'clsx';
2
+ /**
3
+ * `cn()` helper used across shadcn/cult components.
4
+ *
5
+ * Note: We scope Tailwind utilities to the devtool container via
6
+ * `tailwind.config.ts` (`important: ".dev-tool-root"`), so we do NOT need a
7
+ * custom class prefix. Keeping classnames standard also ensures Tailwind JIT
8
+ * can see them and emit the right utilities into the injected CSS bundle.
9
+ */
10
+ export declare function cn(...inputs: ClassValue[]): string;
11
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAG7C;;;;;;;GAOG;AACH,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
package/dist/node.d.ts CHANGED
@@ -1,40 +1,9 @@
1
- import { AnalysisResult, UILintIssue } from 'uilint-core';
2
-
3
1
  /**
4
- * Checks if we're running in a JSDOM environment (tests)
2
+ * Node.js-specific exports for uilint-react
3
+ *
4
+ * This entry point includes features that require Node.js APIs (fs, path, etc.)
5
+ * Use this in Node.js/test environments, not in browser bundles.
5
6
  */
6
- declare function isJSDOM(): boolean;
7
-
8
- /**
9
- * Adapter for running UILint in JSDOM/Node.js test environments
10
- * Uses uilint-core for analysis
11
- */
12
-
13
- /**
14
- * Adapter for running UILint in JSDOM/Node.js test environments
15
- * Calls Ollama directly and outputs to console.warn()
16
- */
17
- declare class JSDOMAdapter {
18
- private styleGuideContent;
19
- private styleGuidePath;
20
- private client;
21
- constructor(styleGuidePath?: string);
22
- /**
23
- * Loads the style guide from the filesystem (Node.js only)
24
- */
25
- loadStyleGuide(): Promise<string | null>;
26
- /**
27
- * Analyzes the current DOM and returns issues
28
- */
29
- analyze(root?: Element | Document): Promise<AnalysisResult>;
30
- /**
31
- * Outputs issues to console.warn (for test visibility)
32
- */
33
- outputWarnings(issues: UILintIssue[]): void;
34
- }
35
- /**
36
- * Convenience function for running UILint in tests
37
- */
38
- declare function runUILintInTest(root?: Element | Document): Promise<UILintIssue[]>;
39
-
40
- export { JSDOMAdapter, isJSDOM, runUILintInTest };
7
+ export { JSDOMAdapter, runUILintInTest } from './scanner/jsdom-adapter.js';
8
+ export { isJSDOM } from './scanner/environment.js';
9
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG3E,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC"}