@ytspar/devbar 1.0.0-canary.c37df82 → 1.0.0-canary.cdf7fa2
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/dist/GlobalDevBar.d.ts +89 -2
- package/dist/GlobalDevBar.js +1090 -102
- package/dist/accessibility.d.ts +84 -0
- package/dist/accessibility.js +155 -0
- package/dist/constants.d.ts +91 -0
- package/dist/constants.js +102 -12
- package/dist/debug.d.ts +39 -0
- package/dist/debug.js +92 -0
- package/dist/index.d.ts +11 -5
- package/dist/index.js +19 -7
- package/dist/lazy/index.d.ts +6 -0
- package/dist/lazy/index.js +6 -0
- package/dist/lazy/lazyHtml2Canvas.d.ts +29 -0
- package/dist/lazy/lazyHtml2Canvas.js +37 -0
- package/dist/network.d.ts +92 -0
- package/dist/network.js +176 -0
- package/dist/outline.js +43 -10
- package/dist/presets.d.ts +57 -0
- package/dist/presets.js +133 -0
- package/dist/schema.js +4 -3
- package/dist/settings.d.ts +150 -0
- package/dist/settings.js +292 -0
- package/dist/storage.d.ts +83 -0
- package/dist/storage.js +182 -0
- package/dist/types.d.ts +26 -1
- package/dist/ui/index.d.ts +2 -2
- package/dist/ui/index.js +2 -2
- package/dist/ui/modals.js +5 -3
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accessibility Audit Utilities
|
|
3
|
+
*
|
|
4
|
+
* Lazy-loads axe-core and provides accessibility auditing capabilities.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Axe-core result types (simplified)
|
|
8
|
+
*/
|
|
9
|
+
export interface AxeViolation {
|
|
10
|
+
id: string;
|
|
11
|
+
impact: 'critical' | 'serious' | 'moderate' | 'minor';
|
|
12
|
+
description: string;
|
|
13
|
+
help: string;
|
|
14
|
+
helpUrl: string;
|
|
15
|
+
tags: string[];
|
|
16
|
+
nodes: Array<{
|
|
17
|
+
html: string;
|
|
18
|
+
target: string[];
|
|
19
|
+
failureSummary?: string;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
export interface AxeResult {
|
|
23
|
+
violations: AxeViolation[];
|
|
24
|
+
passes: Array<{
|
|
25
|
+
id: string;
|
|
26
|
+
description: string;
|
|
27
|
+
}>;
|
|
28
|
+
incomplete: AxeViolation[];
|
|
29
|
+
inapplicable: Array<{
|
|
30
|
+
id: string;
|
|
31
|
+
}>;
|
|
32
|
+
timestamp: string;
|
|
33
|
+
url: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Accessibility audit state
|
|
37
|
+
*/
|
|
38
|
+
export interface A11yState {
|
|
39
|
+
isLoading: boolean;
|
|
40
|
+
lastRun: number | null;
|
|
41
|
+
result: AxeResult | null;
|
|
42
|
+
error: string | null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Check if axe-core is loaded
|
|
46
|
+
*/
|
|
47
|
+
export declare function isAxeLoaded(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Preload axe-core without waiting
|
|
50
|
+
*/
|
|
51
|
+
export declare function preloadAxe(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Run accessibility audit on the page
|
|
54
|
+
* Returns cached result if within cache duration
|
|
55
|
+
*/
|
|
56
|
+
export declare function runA11yAudit(forceRefresh?: boolean): Promise<AxeResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Get violation count by impact level
|
|
59
|
+
*/
|
|
60
|
+
export declare function getViolationCounts(violations: AxeViolation[]): Record<string, number>;
|
|
61
|
+
/**
|
|
62
|
+
* Group violations by impact level
|
|
63
|
+
*/
|
|
64
|
+
export declare function groupViolationsByImpact(violations: AxeViolation[]): Map<string, AxeViolation[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Get color for impact level
|
|
67
|
+
*/
|
|
68
|
+
export declare function getImpactColor(impact: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* Get badge color based on worst violation impact
|
|
71
|
+
*/
|
|
72
|
+
export declare function getBadgeColor(violations: AxeViolation[]): string;
|
|
73
|
+
/**
|
|
74
|
+
* Clear cached result
|
|
75
|
+
*/
|
|
76
|
+
export declare function clearA11yCache(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Get cached result without running audit
|
|
79
|
+
*/
|
|
80
|
+
export declare function getCachedResult(): AxeResult | null;
|
|
81
|
+
/**
|
|
82
|
+
* Format violation for display
|
|
83
|
+
*/
|
|
84
|
+
export declare function formatViolation(violation: AxeViolation): string;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accessibility Audit Utilities
|
|
3
|
+
*
|
|
4
|
+
* Lazy-loads axe-core and provides accessibility auditing capabilities.
|
|
5
|
+
*/
|
|
6
|
+
// Cache duration in milliseconds (30 seconds)
|
|
7
|
+
const CACHE_DURATION_MS = 30000;
|
|
8
|
+
// Module-level state
|
|
9
|
+
let axePromise = null;
|
|
10
|
+
let cachedResult = null;
|
|
11
|
+
let cacheTimestamp = null;
|
|
12
|
+
/**
|
|
13
|
+
* Lazy load axe-core
|
|
14
|
+
*/
|
|
15
|
+
async function loadAxe() {
|
|
16
|
+
if (!axePromise) {
|
|
17
|
+
axePromise = import('axe-core');
|
|
18
|
+
}
|
|
19
|
+
return axePromise;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Check if axe-core is loaded
|
|
23
|
+
*/
|
|
24
|
+
export function isAxeLoaded() {
|
|
25
|
+
return axePromise !== null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Preload axe-core without waiting
|
|
29
|
+
*/
|
|
30
|
+
export function preloadAxe() {
|
|
31
|
+
loadAxe().catch(() => {
|
|
32
|
+
// Silently ignore preload errors
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Run accessibility audit on the page
|
|
37
|
+
* Returns cached result if within cache duration
|
|
38
|
+
*/
|
|
39
|
+
export async function runA11yAudit(forceRefresh = false) {
|
|
40
|
+
// Return cached result if valid
|
|
41
|
+
if (!forceRefresh &&
|
|
42
|
+
cachedResult &&
|
|
43
|
+
cacheTimestamp &&
|
|
44
|
+
Date.now() - cacheTimestamp < CACHE_DURATION_MS) {
|
|
45
|
+
return cachedResult;
|
|
46
|
+
}
|
|
47
|
+
const axeModule = await loadAxe();
|
|
48
|
+
// Handle ESM/CJS interop
|
|
49
|
+
const axe = axeModule.default ?? axeModule;
|
|
50
|
+
// Run axe analysis
|
|
51
|
+
const result = await axe.run(document, {
|
|
52
|
+
runOnly: {
|
|
53
|
+
type: 'tag',
|
|
54
|
+
values: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'best-practice'],
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
// Transform to our format
|
|
58
|
+
const auditResult = {
|
|
59
|
+
violations: result.violations,
|
|
60
|
+
passes: result.passes.map((p) => ({
|
|
61
|
+
id: p.id,
|
|
62
|
+
description: p.description,
|
|
63
|
+
})),
|
|
64
|
+
incomplete: result.incomplete,
|
|
65
|
+
inapplicable: result.inapplicable.map((i) => ({ id: i.id })),
|
|
66
|
+
timestamp: new Date().toISOString(),
|
|
67
|
+
url: window.location.href,
|
|
68
|
+
};
|
|
69
|
+
// Cache the result
|
|
70
|
+
cachedResult = auditResult;
|
|
71
|
+
cacheTimestamp = Date.now();
|
|
72
|
+
return auditResult;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get violation count by impact level
|
|
76
|
+
*/
|
|
77
|
+
export function getViolationCounts(violations) {
|
|
78
|
+
const counts = {
|
|
79
|
+
critical: 0,
|
|
80
|
+
serious: 0,
|
|
81
|
+
moderate: 0,
|
|
82
|
+
minor: 0,
|
|
83
|
+
total: 0,
|
|
84
|
+
};
|
|
85
|
+
for (const violation of violations) {
|
|
86
|
+
counts[violation.impact] = (counts[violation.impact] || 0) + 1;
|
|
87
|
+
counts.total++;
|
|
88
|
+
}
|
|
89
|
+
return counts;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Group violations by impact level
|
|
93
|
+
*/
|
|
94
|
+
export function groupViolationsByImpact(violations) {
|
|
95
|
+
const groups = new Map();
|
|
96
|
+
const impactOrder = ['critical', 'serious', 'moderate', 'minor'];
|
|
97
|
+
for (const impact of impactOrder) {
|
|
98
|
+
groups.set(impact, []);
|
|
99
|
+
}
|
|
100
|
+
for (const violation of violations) {
|
|
101
|
+
const group = groups.get(violation.impact);
|
|
102
|
+
if (group) {
|
|
103
|
+
group.push(violation);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return groups;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get color for impact level
|
|
110
|
+
*/
|
|
111
|
+
export function getImpactColor(impact) {
|
|
112
|
+
const colors = {
|
|
113
|
+
critical: '#ef4444', // red
|
|
114
|
+
serious: '#f97316', // orange
|
|
115
|
+
moderate: '#f59e0b', // amber
|
|
116
|
+
minor: '#84cc16', // lime
|
|
117
|
+
};
|
|
118
|
+
return colors[impact] || '#6b7280';
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get badge color based on worst violation impact
|
|
122
|
+
*/
|
|
123
|
+
export function getBadgeColor(violations) {
|
|
124
|
+
if (violations.some((v) => v.impact === 'critical'))
|
|
125
|
+
return getImpactColor('critical');
|
|
126
|
+
if (violations.some((v) => v.impact === 'serious'))
|
|
127
|
+
return getImpactColor('serious');
|
|
128
|
+
if (violations.some((v) => v.impact === 'moderate'))
|
|
129
|
+
return getImpactColor('moderate');
|
|
130
|
+
if (violations.some((v) => v.impact === 'minor'))
|
|
131
|
+
return getImpactColor('minor');
|
|
132
|
+
return '#10b981'; // green - no violations
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Clear cached result
|
|
136
|
+
*/
|
|
137
|
+
export function clearA11yCache() {
|
|
138
|
+
cachedResult = null;
|
|
139
|
+
cacheTimestamp = null;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Get cached result without running audit
|
|
143
|
+
*/
|
|
144
|
+
export function getCachedResult() {
|
|
145
|
+
if (cachedResult && cacheTimestamp && Date.now() - cacheTimestamp < CACHE_DURATION_MS) {
|
|
146
|
+
return cachedResult;
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Format violation for display
|
|
152
|
+
*/
|
|
153
|
+
export function formatViolation(violation) {
|
|
154
|
+
return `[${violation.impact.toUpperCase()}] ${violation.help}\n${violation.description}\n${violation.nodes.length} element(s) affected`;
|
|
155
|
+
}
|
package/dist/constants.d.ts
CHANGED
|
@@ -62,6 +62,13 @@ export declare const BUTTON_COLORS: {
|
|
|
62
62
|
};
|
|
63
63
|
/** Category colors for outline display */
|
|
64
64
|
export declare const CATEGORY_COLORS: Record<string, string>;
|
|
65
|
+
/** LocalStorage keys for DevBar persistence */
|
|
66
|
+
export declare const STORAGE_KEYS: {
|
|
67
|
+
/** Theme mode preference: 'dark' | 'light' | 'system' */
|
|
68
|
+
readonly themeMode: "devbar-theme-mode";
|
|
69
|
+
/** Compact mode preference: 'true' | 'false' */
|
|
70
|
+
readonly compactMode: "devbar-compact-mode";
|
|
71
|
+
};
|
|
65
72
|
/** Complete DevBar design system theme */
|
|
66
73
|
export declare const DEVBAR_THEME: {
|
|
67
74
|
readonly colors: {
|
|
@@ -123,6 +130,67 @@ export declare const DEVBAR_THEME: {
|
|
|
123
130
|
};
|
|
124
131
|
};
|
|
125
132
|
export type DevBarTheme = typeof DEVBAR_THEME;
|
|
133
|
+
/** Light theme variant - terminal aesthetic with light green tones */
|
|
134
|
+
export declare const DEVBAR_THEME_LIGHT: {
|
|
135
|
+
readonly colors: {
|
|
136
|
+
readonly primary: "#047857";
|
|
137
|
+
readonly primaryHover: "#065f46";
|
|
138
|
+
readonly primaryGlow: "rgba(4, 120, 87, 0.25)";
|
|
139
|
+
readonly error: "#dc2626";
|
|
140
|
+
readonly warning: "#d97706";
|
|
141
|
+
readonly info: "#2563eb";
|
|
142
|
+
readonly purple: "#7c3aed";
|
|
143
|
+
readonly cyan: "#0891b2";
|
|
144
|
+
readonly pink: "#db2777";
|
|
145
|
+
readonly lime: "#65a30d";
|
|
146
|
+
readonly bg: "#ecfdf5";
|
|
147
|
+
readonly bgCard: "rgba(255, 255, 255, 0.85)";
|
|
148
|
+
readonly bgElevated: "rgba(255, 255, 255, 0.95)";
|
|
149
|
+
readonly bgInput: "rgba(236, 253, 245, 0.9)";
|
|
150
|
+
readonly text: "#064e3b";
|
|
151
|
+
readonly textSecondary: "#065f46";
|
|
152
|
+
readonly textMuted: "#047857";
|
|
153
|
+
readonly border: "rgba(4, 120, 87, 0.3)";
|
|
154
|
+
readonly borderSubtle: "rgba(4, 120, 87, 0.1)";
|
|
155
|
+
};
|
|
156
|
+
readonly fonts: {
|
|
157
|
+
readonly mono: "'Departure Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace";
|
|
158
|
+
};
|
|
159
|
+
readonly typography: {
|
|
160
|
+
readonly sizeXs: "0.625rem";
|
|
161
|
+
readonly sizeSm: "0.6875rem";
|
|
162
|
+
readonly sizeBase: "0.75rem";
|
|
163
|
+
readonly sizeMd: "0.8125rem";
|
|
164
|
+
readonly sizeLg: "0.875rem";
|
|
165
|
+
readonly sizeXl: "1rem";
|
|
166
|
+
readonly size2xl: "1.5rem";
|
|
167
|
+
readonly leadingTight: "1rem";
|
|
168
|
+
readonly leadingNormal: "1.5";
|
|
169
|
+
readonly leadingRelaxed: "1.6";
|
|
170
|
+
readonly weightNormal: "400";
|
|
171
|
+
readonly weightMedium: "500";
|
|
172
|
+
readonly weightSemibold: "600";
|
|
173
|
+
readonly trackingTight: "-0.02em";
|
|
174
|
+
readonly trackingNormal: "0";
|
|
175
|
+
readonly trackingWide: "0.05em";
|
|
176
|
+
readonly trackingWider: "0.1em";
|
|
177
|
+
};
|
|
178
|
+
readonly radius: {
|
|
179
|
+
readonly sm: "4px";
|
|
180
|
+
readonly md: "6px";
|
|
181
|
+
readonly lg: "12px";
|
|
182
|
+
};
|
|
183
|
+
readonly shadows: {
|
|
184
|
+
readonly sm: "0 1px 2px rgba(4, 120, 87, 0.1)";
|
|
185
|
+
readonly md: "0 4px 12px rgba(4, 120, 87, 0.12), 0 0 0 1px rgba(4, 120, 87, 0.15)";
|
|
186
|
+
readonly lg: "0 8px 32px rgba(4, 120, 87, 0.15), 0 0 0 1px rgba(4, 120, 87, 0.2)";
|
|
187
|
+
readonly glow: "0 0 20px rgba(4, 120, 87, 0.15)";
|
|
188
|
+
};
|
|
189
|
+
readonly transitions: {
|
|
190
|
+
readonly fast: "150ms";
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
export type DevBarThemeLight = typeof DEVBAR_THEME_LIGHT;
|
|
126
194
|
/** Shorthand for common colors */
|
|
127
195
|
export declare const COLORS: {
|
|
128
196
|
readonly primary: "#10b981";
|
|
@@ -168,6 +236,29 @@ export type DevBarThemeInput = {
|
|
|
168
236
|
[K in keyof DevBarTheme['transitions']]: string;
|
|
169
237
|
};
|
|
170
238
|
};
|
|
239
|
+
import type { ThemeMode } from './types.js';
|
|
240
|
+
/**
|
|
241
|
+
* Get the stored theme mode preference
|
|
242
|
+
*/
|
|
243
|
+
export declare function getStoredThemeMode(): ThemeMode;
|
|
244
|
+
/**
|
|
245
|
+
* Store the theme mode preference
|
|
246
|
+
*/
|
|
247
|
+
export declare function setStoredThemeMode(mode: ThemeMode): void;
|
|
248
|
+
/**
|
|
249
|
+
* Get the effective theme (resolves 'system' to 'dark' or 'light')
|
|
250
|
+
*/
|
|
251
|
+
export declare function getEffectiveTheme(mode: ThemeMode): 'dark' | 'light';
|
|
252
|
+
/** Union type for both theme color variants */
|
|
253
|
+
export type ThemeColors = DevBarTheme['colors'] | DevBarThemeLight['colors'];
|
|
254
|
+
/**
|
|
255
|
+
* Get theme colors based on the current effective theme
|
|
256
|
+
*/
|
|
257
|
+
export declare function getThemeColors(mode: ThemeMode): ThemeColors;
|
|
258
|
+
/**
|
|
259
|
+
* Get full theme based on the current effective theme
|
|
260
|
+
*/
|
|
261
|
+
export declare function getTheme(mode: ThemeMode): typeof DEVBAR_THEME | typeof DEVBAR_THEME_LIGHT;
|
|
171
262
|
/**
|
|
172
263
|
* Generate CSS custom properties from the theme
|
|
173
264
|
*/
|
package/dist/constants.js
CHANGED
|
@@ -41,11 +41,11 @@ export const SCREENSHOT_SCALE = 0.75;
|
|
|
41
41
|
// ============================================================================
|
|
42
42
|
/** Tailwind CSS breakpoint definitions */
|
|
43
43
|
export const TAILWIND_BREAKPOINTS = {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
base: { min: 0, label: 'Tailwind base: <640px' },
|
|
45
|
+
sm: { min: 640, label: 'Tailwind sm: >=640px' },
|
|
46
|
+
md: { min: 768, label: 'Tailwind md: >=768px' },
|
|
47
|
+
lg: { min: 1024, label: 'Tailwind lg: >=1024px' },
|
|
48
|
+
xl: { min: 1280, label: 'Tailwind xl: >=1280px' },
|
|
49
49
|
'2xl': { min: 1536, label: 'Tailwind 2xl: >=1536px' },
|
|
50
50
|
};
|
|
51
51
|
// ============================================================================
|
|
@@ -89,6 +89,16 @@ export const CATEGORY_COLORS = {
|
|
|
89
89
|
other: PALETTE.gray,
|
|
90
90
|
};
|
|
91
91
|
// ============================================================================
|
|
92
|
+
// Storage Keys
|
|
93
|
+
// ============================================================================
|
|
94
|
+
/** LocalStorage keys for DevBar persistence */
|
|
95
|
+
export const STORAGE_KEYS = {
|
|
96
|
+
/** Theme mode preference: 'dark' | 'light' | 'system' */
|
|
97
|
+
themeMode: 'devbar-theme-mode',
|
|
98
|
+
/** Compact mode preference: 'true' | 'false' */
|
|
99
|
+
compactMode: 'devbar-compact-mode',
|
|
100
|
+
};
|
|
101
|
+
// ============================================================================
|
|
92
102
|
// Design System Theme
|
|
93
103
|
// ============================================================================
|
|
94
104
|
/** Complete DevBar design system theme */
|
|
@@ -164,6 +174,47 @@ export const DEVBAR_THEME = {
|
|
|
164
174
|
fast: '150ms',
|
|
165
175
|
},
|
|
166
176
|
};
|
|
177
|
+
/** Light theme variant - terminal aesthetic with light green tones */
|
|
178
|
+
export const DEVBAR_THEME_LIGHT = {
|
|
179
|
+
colors: {
|
|
180
|
+
// Primary accent (darker emerald for contrast)
|
|
181
|
+
primary: '#047857', // darker emerald for better contrast
|
|
182
|
+
primaryHover: '#065f46',
|
|
183
|
+
primaryGlow: 'rgba(4, 120, 87, 0.25)',
|
|
184
|
+
// Semantic colors (adjusted for light bg)
|
|
185
|
+
error: '#dc2626',
|
|
186
|
+
warning: '#d97706',
|
|
187
|
+
info: '#2563eb',
|
|
188
|
+
// Extended palette (darker for light mode)
|
|
189
|
+
purple: '#7c3aed',
|
|
190
|
+
cyan: '#0891b2',
|
|
191
|
+
pink: '#db2777',
|
|
192
|
+
lime: '#65a30d',
|
|
193
|
+
// Backgrounds - terminal light green aesthetic
|
|
194
|
+
bg: '#ecfdf5', // very light mint/green
|
|
195
|
+
bgCard: 'rgba(255, 255, 255, 0.85)',
|
|
196
|
+
bgElevated: 'rgba(255, 255, 255, 0.95)',
|
|
197
|
+
bgInput: 'rgba(236, 253, 245, 0.9)', // light mint input
|
|
198
|
+
// Text (dark on light)
|
|
199
|
+
text: '#064e3b', // dark emerald text
|
|
200
|
+
textSecondary: '#065f46',
|
|
201
|
+
textMuted: '#047857',
|
|
202
|
+
// Borders (emerald-tinted)
|
|
203
|
+
border: 'rgba(4, 120, 87, 0.3)',
|
|
204
|
+
borderSubtle: 'rgba(4, 120, 87, 0.1)',
|
|
205
|
+
},
|
|
206
|
+
// Other properties same as dark theme
|
|
207
|
+
fonts: DEVBAR_THEME.fonts,
|
|
208
|
+
typography: DEVBAR_THEME.typography,
|
|
209
|
+
radius: DEVBAR_THEME.radius,
|
|
210
|
+
shadows: {
|
|
211
|
+
sm: '0 1px 2px rgba(4, 120, 87, 0.1)',
|
|
212
|
+
md: '0 4px 12px rgba(4, 120, 87, 0.12), 0 0 0 1px rgba(4, 120, 87, 0.15)',
|
|
213
|
+
lg: '0 8px 32px rgba(4, 120, 87, 0.15), 0 0 0 1px rgba(4, 120, 87, 0.2)',
|
|
214
|
+
glow: '0 0 20px rgba(4, 120, 87, 0.15)',
|
|
215
|
+
},
|
|
216
|
+
transitions: DEVBAR_THEME.transitions,
|
|
217
|
+
};
|
|
167
218
|
// ============================================================================
|
|
168
219
|
// Shorthand Exports (for cleaner imports)
|
|
169
220
|
// ============================================================================
|
|
@@ -171,6 +222,51 @@ export const DEVBAR_THEME = {
|
|
|
171
222
|
export const COLORS = DEVBAR_THEME.colors;
|
|
172
223
|
/** Shorthand for font stack */
|
|
173
224
|
export const FONT_MONO = DEVBAR_THEME.fonts.mono;
|
|
225
|
+
/**
|
|
226
|
+
* Get the stored theme mode preference
|
|
227
|
+
*/
|
|
228
|
+
export function getStoredThemeMode() {
|
|
229
|
+
if (typeof localStorage === 'undefined')
|
|
230
|
+
return 'system';
|
|
231
|
+
const stored = localStorage.getItem(STORAGE_KEYS.themeMode);
|
|
232
|
+
if (stored === 'dark' || stored === 'light' || stored === 'system') {
|
|
233
|
+
return stored;
|
|
234
|
+
}
|
|
235
|
+
return 'system';
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Store the theme mode preference
|
|
239
|
+
*/
|
|
240
|
+
export function setStoredThemeMode(mode) {
|
|
241
|
+
if (typeof localStorage === 'undefined')
|
|
242
|
+
return;
|
|
243
|
+
localStorage.setItem(STORAGE_KEYS.themeMode, mode);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Get the effective theme (resolves 'system' to 'dark' or 'light')
|
|
247
|
+
*/
|
|
248
|
+
export function getEffectiveTheme(mode) {
|
|
249
|
+
if (mode === 'system') {
|
|
250
|
+
if (typeof window === 'undefined')
|
|
251
|
+
return 'dark';
|
|
252
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
253
|
+
}
|
|
254
|
+
return mode;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Get theme colors based on the current effective theme
|
|
258
|
+
*/
|
|
259
|
+
export function getThemeColors(mode) {
|
|
260
|
+
const effectiveTheme = getEffectiveTheme(mode);
|
|
261
|
+
return effectiveTheme === 'light' ? DEVBAR_THEME_LIGHT.colors : DEVBAR_THEME.colors;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Get full theme based on the current effective theme
|
|
265
|
+
*/
|
|
266
|
+
export function getTheme(mode) {
|
|
267
|
+
const effectiveTheme = getEffectiveTheme(mode);
|
|
268
|
+
return effectiveTheme === 'light' ? DEVBAR_THEME_LIGHT : DEVBAR_THEME;
|
|
269
|
+
}
|
|
174
270
|
/**
|
|
175
271
|
* Generate CSS custom properties from the theme
|
|
176
272
|
*/
|
|
@@ -498,13 +594,7 @@ export const TOOLTIP_STYLES = `
|
|
|
498
594
|
right: auto !important;
|
|
499
595
|
transform: translateX(-50%) !important;
|
|
500
596
|
}
|
|
501
|
-
/* Collapsed state:
|
|
502
|
-
[data-devbar].devbar-collapse {
|
|
503
|
-
left: 50% !important;
|
|
504
|
-
right: auto !important;
|
|
505
|
-
transform: translateX(-50%) !important;
|
|
506
|
-
bottom: 20px !important;
|
|
507
|
-
}
|
|
597
|
+
/* Collapsed state: JS handles positioning based on captured dot location */
|
|
508
598
|
.devbar-main {
|
|
509
599
|
flex-wrap: wrap;
|
|
510
600
|
justify-content: center;
|
package/dist/debug.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DevBar Debug Utilities
|
|
3
|
+
*
|
|
4
|
+
* Debug logging system for DevBar lifecycle, state, and events.
|
|
5
|
+
*/
|
|
6
|
+
import type { DebugConfig } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Normalize debug option to DebugConfig
|
|
9
|
+
*/
|
|
10
|
+
export declare function normalizeDebugConfig(debug: boolean | DebugConfig | undefined): DebugConfig;
|
|
11
|
+
/**
|
|
12
|
+
* Debug logger for DevBar
|
|
13
|
+
*/
|
|
14
|
+
export declare class DebugLogger {
|
|
15
|
+
private config;
|
|
16
|
+
private prefix;
|
|
17
|
+
constructor(config: DebugConfig);
|
|
18
|
+
/**
|
|
19
|
+
* Update debug configuration
|
|
20
|
+
*/
|
|
21
|
+
setConfig(config: DebugConfig): void;
|
|
22
|
+
/**
|
|
23
|
+
* Log lifecycle events (init, destroy, etc.)
|
|
24
|
+
*/
|
|
25
|
+
lifecycle(message: string, data?: unknown): void;
|
|
26
|
+
/**
|
|
27
|
+
* Log state changes (collapse, modal open/close, etc.)
|
|
28
|
+
*/
|
|
29
|
+
state(message: string, data?: unknown): void;
|
|
30
|
+
/**
|
|
31
|
+
* Log WebSocket events (connect, disconnect, messages)
|
|
32
|
+
*/
|
|
33
|
+
ws(message: string, data?: unknown): void;
|
|
34
|
+
/**
|
|
35
|
+
* Log performance measurements (FCP, LCP, CLS, INP)
|
|
36
|
+
*/
|
|
37
|
+
perf(message: string, data?: unknown): void;
|
|
38
|
+
private log;
|
|
39
|
+
}
|
package/dist/debug.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DevBar Debug Utilities
|
|
3
|
+
*
|
|
4
|
+
* Debug logging system for DevBar lifecycle, state, and events.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Normalize debug option to DebugConfig
|
|
8
|
+
*/
|
|
9
|
+
export function normalizeDebugConfig(debug) {
|
|
10
|
+
if (!debug) {
|
|
11
|
+
return { enabled: false };
|
|
12
|
+
}
|
|
13
|
+
if (debug === true) {
|
|
14
|
+
return {
|
|
15
|
+
enabled: true,
|
|
16
|
+
logLifecycle: true,
|
|
17
|
+
logStateChanges: true,
|
|
18
|
+
logWebSocket: true,
|
|
19
|
+
logPerformance: true,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
enabled: debug.enabled,
|
|
24
|
+
logLifecycle: debug.logLifecycle ?? true,
|
|
25
|
+
logStateChanges: debug.logStateChanges ?? true,
|
|
26
|
+
logWebSocket: debug.logWebSocket ?? true,
|
|
27
|
+
logPerformance: debug.logPerformance ?? true,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Debug logger for DevBar
|
|
32
|
+
*/
|
|
33
|
+
export class DebugLogger {
|
|
34
|
+
constructor(config) {
|
|
35
|
+
this.prefix = '[DevBar]';
|
|
36
|
+
this.config = config;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Update debug configuration
|
|
40
|
+
*/
|
|
41
|
+
setConfig(config) {
|
|
42
|
+
this.config = config;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Log lifecycle events (init, destroy, etc.)
|
|
46
|
+
*/
|
|
47
|
+
lifecycle(message, data) {
|
|
48
|
+
if (this.config.enabled && this.config.logLifecycle) {
|
|
49
|
+
this.log('lifecycle', message, data);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Log state changes (collapse, modal open/close, etc.)
|
|
54
|
+
*/
|
|
55
|
+
state(message, data) {
|
|
56
|
+
if (this.config.enabled && this.config.logStateChanges) {
|
|
57
|
+
this.log('state', message, data);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Log WebSocket events (connect, disconnect, messages)
|
|
62
|
+
*/
|
|
63
|
+
ws(message, data) {
|
|
64
|
+
if (this.config.enabled && this.config.logWebSocket) {
|
|
65
|
+
this.log('ws', message, data);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Log performance measurements (FCP, LCP, CLS, INP)
|
|
70
|
+
*/
|
|
71
|
+
perf(message, data) {
|
|
72
|
+
if (this.config.enabled && this.config.logPerformance) {
|
|
73
|
+
this.log('perf', message, data);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
log(category, message, data) {
|
|
77
|
+
const timestamp = new Date().toISOString().split('T')[1].slice(0, -1);
|
|
78
|
+
const categoryColors = {
|
|
79
|
+
lifecycle: '#10b981', // emerald
|
|
80
|
+
state: '#3b82f6', // blue
|
|
81
|
+
ws: '#a855f7', // purple
|
|
82
|
+
perf: '#f59e0b', // amber
|
|
83
|
+
};
|
|
84
|
+
const color = categoryColors[category] || '#6b7280';
|
|
85
|
+
if (data !== undefined) {
|
|
86
|
+
console.log(`%c${this.prefix}%c [${category}] %c${timestamp}%c ${message}`, 'color: #10b981; font-weight: bold', `color: ${color}`, 'color: #6b7280', 'color: inherit', data);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
console.log(`%c${this.prefix}%c [${category}] %c${timestamp}%c ${message}`, 'color: #10b981; font-weight: bold', `color: ${color}`, 'color: #6b7280', 'color: inherit');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type
|
|
3
|
-
export {
|
|
1
|
+
export { type A11yState, type AxeResult, type AxeViolation, clearA11yCache, formatViolation, getBadgeColor, getCachedResult, getImpactColor, getViolationCounts, groupViolationsByImpact, isAxeLoaded, preloadAxe, runA11yAudit, } from './accessibility.js';
|
|
2
|
+
export { BUTTON_COLORS, CATEGORY_COLORS, COLORS, DEVBAR_THEME, DEVBAR_THEME_LIGHT, type DevBarTheme, type DevBarThemeInput, FONT_MONO, generateBreakpointCSS, generateThemeCSSVars, getEffectiveTheme, getStoredThemeMode, getTheme, getThemeColors, injectThemeCSS, STORAGE_KEYS, setStoredThemeMode, TAILWIND_BREAKPOINTS, type TailwindBreakpoint, type ThemeColors, } from './constants.js';
|
|
3
|
+
export { DebugLogger, normalizeDebugConfig } from './debug.js';
|
|
4
|
+
export { EARLY_CONSOLE_CAPTURE_SCRIPT } from './earlyConsoleCapture.js';
|
|
5
|
+
export { destroyGlobalDevBar, earlyConsoleCapture, GlobalDevBar, getGlobalDevBar, initGlobalDevBar, } from './GlobalDevBar.js';
|
|
6
|
+
export { getHtml2Canvas, isHtml2CanvasLoaded, preloadHtml2Canvas } from './lazy/index.js';
|
|
7
|
+
export { formatBytes as formatNetworkBytes, formatDuration, getInitiatorColor, type NetworkEntry, NetworkMonitor, type NetworkState, } from './network.js';
|
|
4
8
|
export { extractDocumentOutline, outlineToMarkdown } from './outline.js';
|
|
9
|
+
export { initDebug, initFull, initMinimal, initPerformance, initResponsive, PRESET_DEBUG, PRESET_FULL, PRESET_MINIMAL, PRESET_PERFORMANCE, PRESET_RESPONSIVE, } from './presets.js';
|
|
5
10
|
export { extractPageSchema, schemaToMarkdown } from './schema.js';
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
11
|
+
export { beautifyJson, type CookieItem, clearLocalStorage, clearSessionStorage, deleteCookie, deleteLocalStorageItem, deleteSessionStorageItem, formatStorageSummary, getCookies, getLocalStorage, getSessionStorage, getStorageData, type StorageData, type StorageItem, setLocalStorageItem, setSessionStorageItem, } from './storage.js';
|
|
12
|
+
export type { ConsoleLog, DebugConfig, DevBarControl, GlobalDevBarOptions, OutlineNode, PageSchema, SweetlinkCommand, ThemeMode, } from './types.js';
|
|
13
|
+
export { canvasToDataUrl, copyCanvasToClipboard, delay, formatArg, formatArgs, prepareForCapture, } from './utils.js';
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
// DevBar - Development toolbar and utilities
|
|
2
2
|
// Pure vanilla JavaScript - no framework dependencies
|
|
3
|
+
// Accessibility audit utilities
|
|
4
|
+
export { clearA11yCache, formatViolation, getBadgeColor, getCachedResult, getImpactColor, getViolationCounts, groupViolationsByImpact, isAxeLoaded, preloadAxe, runA11yAudit, } from './accessibility.js';
|
|
5
|
+
// Re-export constants and theme utilities
|
|
6
|
+
export { BUTTON_COLORS, CATEGORY_COLORS, COLORS, DEVBAR_THEME, DEVBAR_THEME_LIGHT, FONT_MONO, generateBreakpointCSS, generateThemeCSSVars, getEffectiveTheme, getStoredThemeMode, getTheme, getThemeColors, injectThemeCSS, STORAGE_KEYS, setStoredThemeMode, TAILWIND_BREAKPOINTS, } from './constants.js';
|
|
7
|
+
// Debug utilities
|
|
8
|
+
export { DebugLogger, normalizeDebugConfig } from './debug.js';
|
|
9
|
+
// Early console capture script for injection
|
|
10
|
+
export { EARLY_CONSOLE_CAPTURE_SCRIPT } from './earlyConsoleCapture.js';
|
|
3
11
|
// Main vanilla JS devbar
|
|
4
|
-
export {
|
|
5
|
-
//
|
|
6
|
-
export {
|
|
12
|
+
export { destroyGlobalDevBar, earlyConsoleCapture, GlobalDevBar, getGlobalDevBar, initGlobalDevBar, } from './GlobalDevBar.js';
|
|
13
|
+
// Lazy loading utilities
|
|
14
|
+
export { getHtml2Canvas, isHtml2CanvasLoaded, preloadHtml2Canvas } from './lazy/index.js';
|
|
15
|
+
// Network monitoring utilities
|
|
16
|
+
export { formatBytes as formatNetworkBytes, formatDuration, getInitiatorColor, NetworkMonitor, } from './network.js';
|
|
7
17
|
// Re-export outline/schema functions
|
|
8
18
|
export { extractDocumentOutline, outlineToMarkdown } from './outline.js';
|
|
19
|
+
// Configuration presets
|
|
20
|
+
export { initDebug, initFull, initMinimal, initPerformance, initResponsive, PRESET_DEBUG, PRESET_FULL, PRESET_MINIMAL, PRESET_PERFORMANCE, PRESET_RESPONSIVE, } from './presets.js';
|
|
9
21
|
export { extractPageSchema, schemaToMarkdown } from './schema.js';
|
|
10
|
-
//
|
|
11
|
-
export {
|
|
12
|
-
//
|
|
13
|
-
export {
|
|
22
|
+
// Storage inspection utilities
|
|
23
|
+
export { beautifyJson, clearLocalStorage, clearSessionStorage, deleteCookie, deleteLocalStorageItem, deleteSessionStorageItem, formatStorageSummary, getCookies, getLocalStorage, getSessionStorage, getStorageData, setLocalStorageItem, setSessionStorageItem, } from './storage.js';
|
|
24
|
+
// Re-export utilities for external use
|
|
25
|
+
export { canvasToDataUrl, copyCanvasToClipboard, delay, formatArg, formatArgs, prepareForCapture, } from './utils.js';
|