vatts 2.0.2 → 2.0.3-canary.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.
@@ -1,317 +1,317 @@
1
- <!--
2
- This file is part of the Vatts.js Project.
3
- Copyright (c) 2026 mfraz
4
-
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
- -->
17
- <template>
18
- <Teleport to="body">
19
- <!-- Overlay -->
20
- <div v-if="shouldRender" :style="overlayStyle" @mousedown="close">
21
- <!-- Modal Card -->
22
- <div :style="cardStyle" @mousedown.stop>
23
-
24
- <!-- Neon Line -->
25
- <div :style="neonLineStyle"></div>
26
-
27
- <!-- Header -->
28
- <div :style="headerStyle">
29
- <div style="display: flex; align-items: center; gap: 12px">
30
- <span :style="errorBadgeStyle">ERROR</span>
31
- <span v-if="error?.plugin" :style="pluginBadgeStyle">{{ error.plugin }}</span>
32
- </div>
33
-
34
- <div style="display: flex; gap: 8px">
35
- <button
36
- v-if="hasCopyListener"
37
- @click="copy"
38
- @mouseenter="isHoveringCopy = true"
39
- @mouseleave="isHoveringCopy = false"
40
- :style="copyButtonStyle"
41
- >
42
- Copy Log
43
- </button>
44
- <button
45
- @click="close"
46
- @mouseenter="isHoveringClose = true"
47
- @mouseleave="isHoveringClose = false"
48
- :style="closeButtonStyle"
49
- >
50
- Close
51
- </button>
52
- </div>
53
- </div>
54
-
55
- <!-- Terminal Content -->
56
- <div :style="terminalContentStyle">
57
- <span v-for="(part, i) in parsedMessage" :key="'msg-'+i" :style="{ color: part.color || 'inherit' }">
58
- {{ part.text }}
59
- </span>
60
- <div v-if="parsedStack.length" :style="stackContainerStyle">
61
- <span v-for="(part, i) in parsedStack" :key="'stack-'+i" :style="{ color: part.color || 'inherit' }">
62
- {{ part.text }}
63
- </span>
64
- </div>
65
- </div>
66
-
67
- <!-- Footer -->
68
- <div :style="footerStyle">
69
- <span>vatts-cli</span>
70
- <span style="color: #64748b; fontWeight: 500">Watching for changes...</span>
71
- </div>
72
- </div>
73
- </div>
74
- </Teleport>
75
- </template>
76
-
77
- <script setup>
78
- import { ref, computed, watch, onMounted, onUnmounted, useAttrs } from 'vue';
79
-
80
- // --- Props e Emits ---
81
- const props = defineProps({
82
- error: Object,
83
- isOpen: Boolean
84
- });
85
-
86
- const emit = defineEmits(['close', 'copy']);
87
-
88
- // Verifica se o pai (App.vue) passou um listener para @copy
89
- const attrs = useAttrs();
90
- const hasCopyListener = computed(() => !!attrs.onCopy);
91
-
92
- // --- Estado ---
93
- const visible = ref(false);
94
- const shouldRender = ref(false); // Controla a montagem/desmontagem do DOM
95
- const isHoveringClose = ref(false);
96
- const isHoveringCopy = ref(false);
97
-
98
- // --- Lógica de Parser ANSI ---
99
- const ANSI_COLORS = {
100
- '30': '#475569',
101
- '31': '#ef4444',
102
- '32': '#ffffff',
103
- '33': '#94a3b8',
104
- '34': '#cbd5e1',
105
- '35': '#e2e8f0',
106
- '36': '#ffffff',
107
- '37': '#ffffff',
108
- '90': '#64748b',
109
- };
110
-
111
- function parseAnsi(text) {
112
- if (!text) return [];
113
- const regex = /\u001b\[(\d+)(?:;\d+)*m/g;
114
- const result = [];
115
- let lastIndex = 0;
116
- let match;
117
- let currentColor = null;
118
-
119
- while ((match = regex.exec(text)) !== null) {
120
- const rawText = text.slice(lastIndex, match.index);
121
- if (rawText) {
122
- result.push({ text: rawText, color: currentColor });
123
- }
124
-
125
- const code = match[1];
126
- if (code === '39' || code === '0') {
127
- currentColor = null;
128
- } else if (ANSI_COLORS[code]) {
129
- currentColor = ANSI_COLORS[code];
130
- }
131
-
132
- lastIndex = regex.lastIndex;
133
- }
134
-
135
- const remaining = text.slice(lastIndex);
136
- if (remaining) {
137
- result.push({ text: remaining, color: currentColor });
138
- }
139
-
140
- return result;
141
- }
142
-
143
- const parsedMessage = computed(() => parseAnsi(props.error?.message || ''));
144
- const parsedStack = computed(() => {
145
- if (!props.error?.stack) return [];
146
- return parseAnsi(`\n\nStack Trace:\n${props.error.stack}`);
147
- });
148
-
149
- // --- Lifecycle e Watchers (Animações) ---
150
- watch(() => props.isOpen, (newVal) => {
151
- if (newVal) {
152
- document.body.style.overflow = 'hidden';
153
- shouldRender.value = true;
154
- // Pequeno delay para garantir que o elemento exista antes da transição de opacidade
155
- setTimeout(() => { visible.value = true; }, 10);
156
- } else {
157
- document.body.style.overflow = '';
158
- visible.value = false;
159
- // Aguarda a transição de saída (300ms) para desmontar do DOM
160
- setTimeout(() => { shouldRender.value = false; }, 300);
161
- }
162
- }, { immediate: true });
163
-
164
- // Listener para tecla ESC
165
- const onKey = (e) => {
166
- if (e.key === 'Escape' && props.isOpen) emit('close');
167
- };
168
-
169
- onMounted(() => {
170
- if (props.isOpen) document.body.style.overflow = 'hidden';
171
- window.addEventListener('keydown', onKey);
172
- });
173
-
174
- onUnmounted(() => {
175
- document.body.style.overflow = '';
176
- window.removeEventListener('keydown', onKey);
177
- });
178
-
179
- // --- Ações ---
180
- const close = () => emit('close');
181
- const copy = () => emit('copy');
182
-
183
- // --- Estilos ---
184
- const overlayStyle = computed(() => ({
185
- position: 'fixed',
186
- top: 0,
187
- left: 0,
188
- width: '100vw',
189
- height: '100vh',
190
- zIndex: 2147483647,
191
- background: visible.value ? 'rgba(0, 0, 0, 0.95)' : 'rgba(0, 0, 0, 0)',
192
- backdropFilter: 'blur(12px)',
193
- WebkitBackdropFilter: 'blur(12px)',
194
- display: 'flex',
195
- alignItems: 'center',
196
- justifyContent: 'center',
197
- padding: '24px',
198
- transition: 'all 0.3s ease',
199
- opacity: visible.value ? 1 : 0,
200
- boxSizing: 'border-box',
201
- }));
202
-
203
- const cardStyle = computed(() => ({
204
- width: '100%',
205
- maxWidth: '1080px',
206
- maxHeight: '90vh',
207
- display: 'flex',
208
- flexDirection: 'column',
209
- background: '#0a0a0a',
210
- boxShadow: `0 0 0 1px rgba(255, 255, 255, 0.1), 0 50px 100px -20px rgba(0, 0, 0, 1)`,
211
- borderRadius: '16px',
212
- overflow: 'hidden',
213
- transform: visible.value ? 'scale(1) translateY(0)' : 'scale(0.98) translateY(10px)',
214
- transition: 'transform 0.4s cubic-bezier(0.16, 1, 0.3, 1)',
215
- position: 'relative',
216
- }));
217
-
218
- const neonLineStyle = {
219
- height: '1px',
220
- width: '100%',
221
- background: `linear-gradient(90deg, transparent, #334155, #ffffff, #334155, transparent)`,
222
- boxShadow: `0 0 15px rgba(255, 255, 255, 0.05)`,
223
- };
224
-
225
- const headerStyle = {
226
- padding: '16px 24px',
227
- display: 'flex',
228
- justifyContent: 'space-between',
229
- alignItems: 'center',
230
- borderBottom: '1px solid rgba(255,255,255,0.06)',
231
- background: 'rgba(255,255,255,0.01)'
232
- };
233
-
234
- const errorBadgeStyle = {
235
- fontSize: '11px',
236
- fontWeight: 900,
237
- color: '#ffffff',
238
- background: '#ef4444',
239
- padding: '2px 8px',
240
- borderRadius: '4px',
241
- letterSpacing: '0.05em'
242
- };
243
-
244
- const pluginBadgeStyle = {
245
- fontSize: '11px',
246
- color: '#64748b',
247
- background: 'rgba(255, 255, 255, 0.03)',
248
- padding: '2px 8px',
249
- borderRadius: '4px',
250
- fontFamily: 'monospace',
251
- border: '1px solid rgba(255, 255, 255, 0.05)'
252
- };
253
-
254
- const terminalContentStyle = {
255
- padding: '24px',
256
- overflow: 'auto',
257
- flex: 1,
258
- fontFamily: '"JetBrains Mono", monospace',
259
- fontSize: '13px',
260
- lineHeight: 1.6,
261
- color: '#e2e8f0',
262
- whiteSpace: 'pre-wrap',
263
- wordBreak: 'break-word',
264
- };
265
-
266
- const stackContainerStyle = {
267
- marginTop: '24px',
268
- opacity: 0.4,
269
- borderTop: '1px dashed rgba(255,255,255,0.1)',
270
- paddingTop: '16px'
271
- };
272
-
273
- const footerStyle = {
274
- padding: '10px 24px',
275
- background: 'rgba(255,255,255,0.01)',
276
- borderTop: '1px solid rgba(255,255,255,0.03)',
277
- display: 'flex',
278
- justifyContent: 'space-between',
279
- fontSize: '11px',
280
- color: 'rgba(255,255,255,0.3)',
281
- fontFamily: 'Inter, sans-serif'
282
- };
283
-
284
- const getBtnStyle = (kind, hovering) => {
285
- const base = {
286
- padding: '8px 16px',
287
- borderRadius: '8px',
288
- fontSize: '11px',
289
- fontWeight: 700,
290
- cursor: 'pointer',
291
- transition: 'all 0.2s ease',
292
- textTransform: 'uppercase',
293
- letterSpacing: '0.05em',
294
- border: 'none',
295
- outline: 'none',
296
- fontFamily: 'Inter, system-ui, sans-serif'
297
- };
298
- if (kind === 'primary') {
299
- return {
300
- ...base,
301
- background: hovering ? '#ffffff' : '#f1f5f9',
302
- color: '#000000',
303
- boxShadow: hovering ? `0 0 15px rgba(255, 255, 255, 0.2)` : 'none',
304
- };
305
- }
306
- return {
307
- ...base,
308
- background: hovering ? 'rgba(255, 255, 255, 0.08)' : 'transparent',
309
- color: hovering ? '#fff' : 'rgba(255, 255, 255, 0.4)',
310
- border: '1px solid transparent',
311
- borderColor: hovering ? 'rgba(255, 255, 255, 0.1)' : 'transparent',
312
- };
313
- };
314
-
315
- const copyButtonStyle = computed(() => getBtnStyle('secondary', isHoveringCopy.value));
316
- const closeButtonStyle = computed(() => getBtnStyle('primary', isHoveringClose.value));
1
+ <!--
2
+ This file is part of the Vatts.js Project.
3
+ Copyright (c) 2026 mfraz
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ -->
17
+ <template>
18
+ <Teleport to="body">
19
+ <!-- Overlay -->
20
+ <div v-if="shouldRender" :style="overlayStyle" @mousedown="close">
21
+ <!-- Modal Card -->
22
+ <div :style="cardStyle" @mousedown.stop>
23
+
24
+ <!-- Neon Line -->
25
+ <div :style="neonLineStyle"></div>
26
+
27
+ <!-- Header -->
28
+ <div :style="headerStyle">
29
+ <div style="display: flex; align-items: center; gap: 12px">
30
+ <span :style="errorBadgeStyle">ERROR</span>
31
+ <span v-if="error?.plugin" :style="pluginBadgeStyle">{{ error.plugin }}</span>
32
+ </div>
33
+
34
+ <div style="display: flex; gap: 8px">
35
+ <button
36
+ v-if="hasCopyListener"
37
+ @click="copy"
38
+ @mouseenter="isHoveringCopy = true"
39
+ @mouseleave="isHoveringCopy = false"
40
+ :style="copyButtonStyle"
41
+ >
42
+ Copy Log
43
+ </button>
44
+ <button
45
+ @click="close"
46
+ @mouseenter="isHoveringClose = true"
47
+ @mouseleave="isHoveringClose = false"
48
+ :style="closeButtonStyle"
49
+ >
50
+ Close
51
+ </button>
52
+ </div>
53
+ </div>
54
+
55
+ <!-- Terminal Content -->
56
+ <div :style="terminalContentStyle">
57
+ <span v-for="(part, i) in parsedMessage" :key="'msg-'+i" :style="{ color: part.color || 'inherit' }">
58
+ {{ part.text }}
59
+ </span>
60
+ <div v-if="parsedStack.length" :style="stackContainerStyle">
61
+ <span v-for="(part, i) in parsedStack" :key="'stack-'+i" :style="{ color: part.color || 'inherit' }">
62
+ {{ part.text }}
63
+ </span>
64
+ </div>
65
+ </div>
66
+
67
+ <!-- Footer -->
68
+ <div :style="footerStyle">
69
+ <span>vatts-cli</span>
70
+ <span style="color: #64748b; fontWeight: 500">Watching for changes...</span>
71
+ </div>
72
+ </div>
73
+ </div>
74
+ </Teleport>
75
+ </template>
76
+
77
+ <script setup>
78
+ import { ref, computed, watch, onMounted, onUnmounted, useAttrs } from 'vue';
79
+
80
+ // --- Props e Emits ---
81
+ const props = defineProps({
82
+ error: Object,
83
+ isOpen: Boolean
84
+ });
85
+
86
+ const emit = defineEmits(['close', 'copy']);
87
+
88
+ // Verifica se o pai (App.vue) passou um listener para @copy
89
+ const attrs = useAttrs();
90
+ const hasCopyListener = computed(() => !!attrs.onCopy);
91
+
92
+ // --- Estado ---
93
+ const visible = ref(false);
94
+ const shouldRender = ref(false); // Controla a montagem/desmontagem do DOM
95
+ const isHoveringClose = ref(false);
96
+ const isHoveringCopy = ref(false);
97
+
98
+ // --- Lógica de Parser ANSI ---
99
+ const ANSI_COLORS = {
100
+ '30': '#475569',
101
+ '31': '#ef4444',
102
+ '32': '#ffffff',
103
+ '33': '#94a3b8',
104
+ '34': '#cbd5e1',
105
+ '35': '#e2e8f0',
106
+ '36': '#ffffff',
107
+ '37': '#ffffff',
108
+ '90': '#64748b',
109
+ };
110
+
111
+ function parseAnsi(text) {
112
+ if (!text) return [];
113
+ const regex = /\u001b\[(\d+)(?:;\d+)*m/g;
114
+ const result = [];
115
+ let lastIndex = 0;
116
+ let match;
117
+ let currentColor = null;
118
+
119
+ while ((match = regex.exec(text)) !== null) {
120
+ const rawText = text.slice(lastIndex, match.index);
121
+ if (rawText) {
122
+ result.push({ text: rawText, color: currentColor });
123
+ }
124
+
125
+ const code = match[1];
126
+ if (code === '39' || code === '0') {
127
+ currentColor = null;
128
+ } else if (ANSI_COLORS[code]) {
129
+ currentColor = ANSI_COLORS[code];
130
+ }
131
+
132
+ lastIndex = regex.lastIndex;
133
+ }
134
+
135
+ const remaining = text.slice(lastIndex);
136
+ if (remaining) {
137
+ result.push({ text: remaining, color: currentColor });
138
+ }
139
+
140
+ return result;
141
+ }
142
+
143
+ const parsedMessage = computed(() => parseAnsi(props.error?.message || ''));
144
+ const parsedStack = computed(() => {
145
+ if (!props.error?.stack) return [];
146
+ return parseAnsi(`\n\nStack Trace:\n${props.error.stack}`);
147
+ });
148
+
149
+ // --- Lifecycle e Watchers (Animações) ---
150
+ watch(() => props.isOpen, (newVal) => {
151
+ if (newVal) {
152
+ document.body.style.overflow = 'hidden';
153
+ shouldRender.value = true;
154
+ // Pequeno delay para garantir que o elemento exista antes da transição de opacidade
155
+ setTimeout(() => { visible.value = true; }, 10);
156
+ } else {
157
+ document.body.style.overflow = '';
158
+ visible.value = false;
159
+ // Aguarda a transição de saída (300ms) para desmontar do DOM
160
+ setTimeout(() => { shouldRender.value = false; }, 300);
161
+ }
162
+ }, { immediate: true });
163
+
164
+ // Listener para tecla ESC
165
+ const onKey = (e) => {
166
+ if (e.key === 'Escape' && props.isOpen) emit('close');
167
+ };
168
+
169
+ onMounted(() => {
170
+ if (props.isOpen) document.body.style.overflow = 'hidden';
171
+ window.addEventListener('keydown', onKey);
172
+ });
173
+
174
+ onUnmounted(() => {
175
+ document.body.style.overflow = '';
176
+ window.removeEventListener('keydown', onKey);
177
+ });
178
+
179
+ // --- Ações ---
180
+ const close = () => emit('close');
181
+ const copy = () => emit('copy');
182
+
183
+ // --- Estilos ---
184
+ const overlayStyle = computed(() => ({
185
+ position: 'fixed',
186
+ top: 0,
187
+ left: 0,
188
+ width: '100vw',
189
+ height: '100vh',
190
+ zIndex: 2147483647,
191
+ background: visible.value ? 'rgba(0, 0, 0, 0.95)' : 'rgba(0, 0, 0, 0)',
192
+ backdropFilter: 'blur(12px)',
193
+ WebkitBackdropFilter: 'blur(12px)',
194
+ display: 'flex',
195
+ alignItems: 'center',
196
+ justifyContent: 'center',
197
+ padding: '24px',
198
+ transition: 'all 0.3s ease',
199
+ opacity: visible.value ? 1 : 0,
200
+ boxSizing: 'border-box',
201
+ }));
202
+
203
+ const cardStyle = computed(() => ({
204
+ width: '100%',
205
+ maxWidth: '1080px',
206
+ maxHeight: '90vh',
207
+ display: 'flex',
208
+ flexDirection: 'column',
209
+ background: '#0a0a0a',
210
+ boxShadow: `0 0 0 1px rgba(255, 255, 255, 0.1), 0 50px 100px -20px rgba(0, 0, 0, 1)`,
211
+ borderRadius: '16px',
212
+ overflow: 'hidden',
213
+ transform: visible.value ? 'scale(1) translateY(0)' : 'scale(0.98) translateY(10px)',
214
+ transition: 'transform 0.4s cubic-bezier(0.16, 1, 0.3, 1)',
215
+ position: 'relative',
216
+ }));
217
+
218
+ const neonLineStyle = {
219
+ height: '1px',
220
+ width: '100%',
221
+ background: `linear-gradient(90deg, transparent, #334155, #ffffff, #334155, transparent)`,
222
+ boxShadow: `0 0 15px rgba(255, 255, 255, 0.05)`,
223
+ };
224
+
225
+ const headerStyle = {
226
+ padding: '16px 24px',
227
+ display: 'flex',
228
+ justifyContent: 'space-between',
229
+ alignItems: 'center',
230
+ borderBottom: '1px solid rgba(255,255,255,0.06)',
231
+ background: 'rgba(255,255,255,0.01)'
232
+ };
233
+
234
+ const errorBadgeStyle = {
235
+ fontSize: '11px',
236
+ fontWeight: 900,
237
+ color: '#ffffff',
238
+ background: '#ef4444',
239
+ padding: '2px 8px',
240
+ borderRadius: '4px',
241
+ letterSpacing: '0.05em'
242
+ };
243
+
244
+ const pluginBadgeStyle = {
245
+ fontSize: '11px',
246
+ color: '#64748b',
247
+ background: 'rgba(255, 255, 255, 0.03)',
248
+ padding: '2px 8px',
249
+ borderRadius: '4px',
250
+ fontFamily: 'monospace',
251
+ border: '1px solid rgba(255, 255, 255, 0.05)'
252
+ };
253
+
254
+ const terminalContentStyle = {
255
+ padding: '24px',
256
+ overflow: 'auto',
257
+ flex: 1,
258
+ fontFamily: '"JetBrains Mono", monospace',
259
+ fontSize: '13px',
260
+ lineHeight: 1.6,
261
+ color: '#e2e8f0',
262
+ whiteSpace: 'pre-wrap',
263
+ wordBreak: 'break-word',
264
+ };
265
+
266
+ const stackContainerStyle = {
267
+ marginTop: '24px',
268
+ opacity: 0.4,
269
+ borderTop: '1px dashed rgba(255,255,255,0.1)',
270
+ paddingTop: '16px'
271
+ };
272
+
273
+ const footerStyle = {
274
+ padding: '10px 24px',
275
+ background: 'rgba(255,255,255,0.01)',
276
+ borderTop: '1px solid rgba(255,255,255,0.03)',
277
+ display: 'flex',
278
+ justifyContent: 'space-between',
279
+ fontSize: '11px',
280
+ color: 'rgba(255,255,255,0.3)',
281
+ fontFamily: 'Inter, sans-serif'
282
+ };
283
+
284
+ const getBtnStyle = (kind, hovering) => {
285
+ const base = {
286
+ padding: '8px 16px',
287
+ borderRadius: '8px',
288
+ fontSize: '11px',
289
+ fontWeight: 700,
290
+ cursor: 'pointer',
291
+ transition: 'all 0.2s ease',
292
+ textTransform: 'uppercase',
293
+ letterSpacing: '0.05em',
294
+ border: 'none',
295
+ outline: 'none',
296
+ fontFamily: 'Inter, system-ui, sans-serif'
297
+ };
298
+ if (kind === 'primary') {
299
+ return {
300
+ ...base,
301
+ background: hovering ? '#ffffff' : '#f1f5f9',
302
+ color: '#000000',
303
+ boxShadow: hovering ? `0 0 15px rgba(255, 255, 255, 0.2)` : 'none',
304
+ };
305
+ }
306
+ return {
307
+ ...base,
308
+ background: hovering ? 'rgba(255, 255, 255, 0.08)' : 'transparent',
309
+ color: hovering ? '#fff' : 'rgba(255, 255, 255, 0.4)',
310
+ border: '1px solid transparent',
311
+ borderColor: hovering ? 'rgba(255, 255, 255, 0.1)' : 'transparent',
312
+ };
313
+ };
314
+
315
+ const copyButtonStyle = computed(() => getBtnStyle('secondary', isHoveringCopy.value));
316
+ const closeButtonStyle = computed(() => getBtnStyle('primary', isHoveringClose.value));
317
317
  </script>