@ytspar/devbar 0.0.1 → 1.0.0-canary.92db425
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 +21 -0
- package/README.md +173 -28
- package/dist/GlobalDevBar.d.ts +201 -0
- package/dist/GlobalDevBar.js +1979 -0
- package/dist/constants.d.ts +202 -0
- package/dist/constants.js +535 -0
- package/dist/earlyConsoleCapture.d.ts +34 -0
- package/dist/earlyConsoleCapture.js +77 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +13 -0
- package/dist/outline.d.ts +14 -0
- package/dist/outline.js +215 -0
- package/dist/schema.d.ts +14 -0
- package/dist/schema.js +113 -0
- package/dist/types.d.ts +50 -0
- package/dist/types.js +8 -0
- package/dist/ui/buttons.d.ts +21 -0
- package/dist/ui/buttons.js +55 -0
- package/dist/ui/icons.d.ts +13 -0
- package/dist/ui/icons.js +25 -0
- package/dist/ui/index.d.ts +8 -0
- package/dist/ui/index.js +8 -0
- package/dist/ui/modals.d.ts +40 -0
- package/dist/ui/modals.js +144 -0
- package/dist/utils.d.ts +11 -0
- package/dist/utils.js +13 -0
- package/package.json +58 -6
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DevBar Modals
|
|
3
|
+
*
|
|
4
|
+
* Modal creation utilities for the DevBar UI.
|
|
5
|
+
*/
|
|
6
|
+
import { MODAL_OVERLAY_STYLES, MODAL_BOX_BASE_STYLES } from '../constants.js';
|
|
7
|
+
import { createStyledButton } from './buttons.js';
|
|
8
|
+
/**
|
|
9
|
+
* Create modal overlay with click-outside-to-close behavior
|
|
10
|
+
*/
|
|
11
|
+
export function createModalOverlay(onClose) {
|
|
12
|
+
const overlay = document.createElement('div');
|
|
13
|
+
overlay.setAttribute('data-devbar', 'true');
|
|
14
|
+
Object.assign(overlay.style, MODAL_OVERLAY_STYLES);
|
|
15
|
+
overlay.onclick = (e) => {
|
|
16
|
+
if (e.target === overlay)
|
|
17
|
+
onClose();
|
|
18
|
+
};
|
|
19
|
+
return overlay;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create modal box with border and shadow
|
|
23
|
+
*/
|
|
24
|
+
export function createModalBox(color) {
|
|
25
|
+
const modal = document.createElement('div');
|
|
26
|
+
Object.assign(modal.style, {
|
|
27
|
+
...MODAL_BOX_BASE_STYLES,
|
|
28
|
+
border: `1px solid ${color}`,
|
|
29
|
+
boxShadow: `0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px ${color}33`,
|
|
30
|
+
});
|
|
31
|
+
return modal;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create modal header with title, copy/save/close buttons
|
|
35
|
+
*/
|
|
36
|
+
export function createModalHeader(config) {
|
|
37
|
+
const { color, title, onClose, onCopyMd, onSave, sweetlinkConnected } = config;
|
|
38
|
+
const header = document.createElement('div');
|
|
39
|
+
Object.assign(header.style, {
|
|
40
|
+
display: 'flex',
|
|
41
|
+
alignItems: 'center',
|
|
42
|
+
justifyContent: 'space-between',
|
|
43
|
+
padding: '16px 20px',
|
|
44
|
+
borderBottom: `1px solid ${color}40`,
|
|
45
|
+
});
|
|
46
|
+
const titleEl = document.createElement('h2');
|
|
47
|
+
Object.assign(titleEl.style, {
|
|
48
|
+
color,
|
|
49
|
+
fontSize: '1rem',
|
|
50
|
+
fontWeight: '600',
|
|
51
|
+
margin: '0',
|
|
52
|
+
});
|
|
53
|
+
titleEl.textContent = title;
|
|
54
|
+
header.appendChild(titleEl);
|
|
55
|
+
const headerButtons = document.createElement('div');
|
|
56
|
+
Object.assign(headerButtons.style, { display: 'flex', gap: '10px' });
|
|
57
|
+
// Copy MD button
|
|
58
|
+
const copyBtn = createStyledButton({ color, text: 'Copy MD' });
|
|
59
|
+
copyBtn.onclick = async () => {
|
|
60
|
+
try {
|
|
61
|
+
await onCopyMd();
|
|
62
|
+
copyBtn.textContent = 'Copied!';
|
|
63
|
+
setTimeout(() => { copyBtn.textContent = 'Copy MD'; }, 1500);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
console.error('[GlobalDevBar] Failed to copy to clipboard');
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
headerButtons.appendChild(copyBtn);
|
|
70
|
+
// Save button (if Sweetlink connected)
|
|
71
|
+
if (sweetlinkConnected && onSave) {
|
|
72
|
+
const saveBtn = createStyledButton({ color, text: 'Save' });
|
|
73
|
+
saveBtn.onclick = onSave;
|
|
74
|
+
headerButtons.appendChild(saveBtn);
|
|
75
|
+
}
|
|
76
|
+
// Close button - use same padding as other buttons for consistent height
|
|
77
|
+
const closeBtn = createStyledButton({
|
|
78
|
+
color,
|
|
79
|
+
text: '×',
|
|
80
|
+
padding: '6px 10px',
|
|
81
|
+
fontSize: '0.875rem',
|
|
82
|
+
});
|
|
83
|
+
closeBtn.onclick = onClose;
|
|
84
|
+
headerButtons.appendChild(closeBtn);
|
|
85
|
+
header.appendChild(headerButtons);
|
|
86
|
+
return header;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Create modal content container
|
|
90
|
+
*/
|
|
91
|
+
export function createModalContent() {
|
|
92
|
+
const content = document.createElement('div');
|
|
93
|
+
Object.assign(content.style, {
|
|
94
|
+
flex: '1',
|
|
95
|
+
overflow: 'auto',
|
|
96
|
+
padding: '16px 20px',
|
|
97
|
+
});
|
|
98
|
+
return content;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Create empty state message for modals
|
|
102
|
+
*/
|
|
103
|
+
export function createEmptyMessage(text) {
|
|
104
|
+
const emptyMsg = document.createElement('div');
|
|
105
|
+
Object.assign(emptyMsg.style, {
|
|
106
|
+
textAlign: 'center',
|
|
107
|
+
color: '#6b7280',
|
|
108
|
+
fontSize: '0.875rem',
|
|
109
|
+
padding: '40px',
|
|
110
|
+
});
|
|
111
|
+
emptyMsg.textContent = text;
|
|
112
|
+
return emptyMsg;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Create a colored info box (for error states, cost estimates, etc.)
|
|
116
|
+
*/
|
|
117
|
+
export function createInfoBox(color, title, content) {
|
|
118
|
+
const box = document.createElement('div');
|
|
119
|
+
Object.assign(box.style, {
|
|
120
|
+
backgroundColor: `${color}15`,
|
|
121
|
+
border: `1px solid ${color}40`,
|
|
122
|
+
borderRadius: '8px',
|
|
123
|
+
padding: '14px',
|
|
124
|
+
marginBottom: '16px',
|
|
125
|
+
});
|
|
126
|
+
const titleEl = document.createElement('div');
|
|
127
|
+
Object.assign(titleEl.style, {
|
|
128
|
+
color,
|
|
129
|
+
fontWeight: '600',
|
|
130
|
+
marginBottom: '8px',
|
|
131
|
+
});
|
|
132
|
+
titleEl.textContent = title;
|
|
133
|
+
box.appendChild(titleEl);
|
|
134
|
+
if (typeof content === 'string') {
|
|
135
|
+
const textEl = document.createElement('div');
|
|
136
|
+
Object.assign(textEl.style, { color: '#94a3b8' });
|
|
137
|
+
textEl.textContent = content;
|
|
138
|
+
box.appendChild(textEl);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
content.forEach(el => box.appendChild(el));
|
|
142
|
+
}
|
|
143
|
+
return box;
|
|
144
|
+
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DevBar Utility Functions
|
|
3
|
+
*
|
|
4
|
+
* Re-exports shared utilities from @ytspar/sweetlink for use by DevBar components.
|
|
5
|
+
* This avoids code duplication between packages.
|
|
6
|
+
*
|
|
7
|
+
* NOTE: We import from specific sub-paths to avoid pulling in Node.js-only modules
|
|
8
|
+
* that would break browser/test environments.
|
|
9
|
+
*/
|
|
10
|
+
export { formatArg, formatArgs } from '@ytspar/sweetlink/browser/consoleCapture';
|
|
11
|
+
export { canvasToDataUrl, prepareForCapture, delay, copyCanvasToClipboard, } from '@ytspar/sweetlink/browser/screenshotUtils';
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DevBar Utility Functions
|
|
3
|
+
*
|
|
4
|
+
* Re-exports shared utilities from @ytspar/sweetlink for use by DevBar components.
|
|
5
|
+
* This avoids code duplication between packages.
|
|
6
|
+
*
|
|
7
|
+
* NOTE: We import from specific sub-paths to avoid pulling in Node.js-only modules
|
|
8
|
+
* that would break browser/test environments.
|
|
9
|
+
*/
|
|
10
|
+
// Re-export console formatting utilities from sweetlink's browser module
|
|
11
|
+
export { formatArg, formatArgs } from '@ytspar/sweetlink/browser/consoleCapture';
|
|
12
|
+
// Re-export screenshot utilities from sweetlink's browser module
|
|
13
|
+
export { canvasToDataUrl, prepareForCapture, delay, copyCanvasToClipboard, } from '@ytspar/sweetlink/browser/screenshotUtils';
|
package/package.json
CHANGED
|
@@ -1,10 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ytspar/devbar",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
3
|
+
"version": "1.0.0-canary.92db425",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"private": false,
|
|
6
|
+
"description": "Development toolbar and utilities with Sweetlink integration - pure vanilla JS, no framework dependencies",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/ytspar/devtools.git",
|
|
10
|
+
"directory": "packages/devbar"
|
|
11
|
+
},
|
|
5
12
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
13
|
+
"development",
|
|
14
|
+
"debug",
|
|
15
|
+
"devtools",
|
|
16
|
+
"sweetlink",
|
|
17
|
+
"vanilla-js"
|
|
18
|
+
],
|
|
19
|
+
"author": "ytspar",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./GlobalDevBar": {
|
|
30
|
+
"types": "./dist/GlobalDevBar.d.ts",
|
|
31
|
+
"import": "./dist/GlobalDevBar.js",
|
|
32
|
+
"default": "./dist/GlobalDevBar.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"README.md",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsc",
|
|
42
|
+
"typecheck": "tsc --noEmit",
|
|
43
|
+
"clean": "rm -rf dist"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@ytspar/sweetlink": "^1.0.0 || ^2.0.0"
|
|
47
|
+
},
|
|
48
|
+
"peerDependenciesMeta": {
|
|
49
|
+
"@ytspar/sweetlink": {
|
|
50
|
+
"optional": true
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"axe-core": "^4.10.2",
|
|
55
|
+
"html2canvas-pro": "^1.5.8"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@ytspar/sweetlink": "workspace:*",
|
|
59
|
+
"@types/node": "^22.0.0",
|
|
60
|
+
"typescript": "^5.0.0"
|
|
61
|
+
}
|
|
10
62
|
}
|