vg-coder-cli 2.0.30 → 2.0.32

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 (40) hide show
  1. package/ARCHITECTURE.md +255 -0
  2. package/README.md +0 -11
  3. package/change.sh +0 -0
  4. package/dist/vg-coder-bundle.js +42 -0
  5. package/gulpfile.js +111 -0
  6. package/package.json +19 -11
  7. package/scripts/postinstall.js +13 -3
  8. package/src/index.js +28 -220
  9. package/src/server/api-server.js +120 -428
  10. package/src/server/views/css/bubble.css +81 -0
  11. package/src/server/views/css/code-viewer.css +58 -0
  12. package/src/server/views/css/terminal.css +59 -155
  13. package/src/server/views/dashboard.css +78 -678
  14. package/src/server/views/dashboard.html +39 -278
  15. package/src/server/views/js/api.js +2 -22
  16. package/src/server/views/js/config.js +27 -15
  17. package/src/server/views/js/event-protocol.js +263 -0
  18. package/src/server/views/js/features/bubble-features/index.js +125 -0
  19. package/src/server/views/js/features/bubble-features/paste-run-feature.js +16 -0
  20. package/src/server/views/js/features/bubble-features/terminal-feature.js +16 -0
  21. package/src/server/views/js/features/bubble.js +175 -0
  22. package/src/server/views/js/features/code-viewer.js +90 -0
  23. package/src/server/views/js/features/commands.js +34 -81
  24. package/src/server/views/js/features/editor-tabs.js +19 -46
  25. package/src/server/views/js/features/git-view.js +63 -81
  26. package/src/server/views/js/features/iframe-manager.js +3 -97
  27. package/src/server/views/js/features/monaco-manager.js +19 -39
  28. package/src/server/views/js/features/project-switcher.js +7 -63
  29. package/src/server/views/js/features/resize.js +5 -16
  30. package/src/server/views/js/features/structure.js +38 -106
  31. package/src/server/views/js/features/terminal.js +102 -418
  32. package/src/server/views/js/handlers.js +60 -43
  33. package/src/server/views/js/main.js +75 -179
  34. package/src/server/views/js/shadow-entry.js +21 -0
  35. package/src/server/views/js/utils.js +48 -28
  36. package/src/server/views/vg-coder/_metadata/generated_indexed_rulesets/_ruleset1 +0 -0
  37. package/src/server/views/vg-coder/controller.js +33 -258
  38. package/vetgo-auto/chrome/src/utils/injector-script.ts +33 -258
  39. package/vetgo-auto/vg-coder.zip +0 -0
  40. package/src/server/views/dashboard.js +0 -457
@@ -1,272 +1,47 @@
1
- // VG Coder Iframe Injector Script (Bundled for Extension)
2
- // Two-Button Toggle with hidden fullscreen when collapsed
1
+ // VG Coder Shadow DOM Bundle Loader
2
+ // This script fetches the compiled bundle from the local server and executes it.
3
3
 
4
4
  export const VG_CODER_INJECTOR_SCRIPT = `
5
5
  (function() {
6
6
  'use strict';
7
7
 
8
8
  const CONFIG = {
9
- VG_CODER_URL: 'http://localhost:6868?embedded=true',
10
- IFRAME_ID: 'vg-coder-side-iframe',
11
- CONTAINER_ID: 'vg-coder-container',
12
- CONTROLS_ID: 'vg-coder-controls',
13
- RESIZE_HANDLE_ID: 'vg-coder-resize-handle',
14
- DEFAULT_WIDTH: '420px',
15
- FULLSCREEN_WIDTH: '100%',
16
- MIN_WIDTH: 300,
17
- MAX_WIDTH_PERCENT: 70,
18
- STATE_DEFAULT: 'default',
19
- STATE_FULLSCREEN: 'fullscreen',
20
- STATE_COLLAPSED: 'collapsed',
21
- Z_INDEX: 9999,
22
- STORAGE_KEY_WIDTH: 'vg_coder_width',
23
- STORAGE_KEY_STATE: 'vg_coder_state',
9
+ // Trỏ tới file bundle vừa build
10
+ BUNDLE_URL: 'http://localhost:6868/dist/vg-coder-bundle.js',
11
+ CONTAINER_ID: 'vg-coder-shadow-host'
24
12
  };
25
13
 
26
- if (sessionStorage.getItem('VG_CODER_NESTED') === 'true') {
27
- console.log('🚫 VG Coder iframe injection skipped - nested context');
28
- return;
29
- }
30
-
31
- if (window.self !== window.top && document.referrer.includes(':6868')) {
32
- console.log('🚫 VG Coder iframe injection skipped - parent is :6868');
33
- return;
34
- }
35
-
14
+ // 1. Kiểm tra nếu đã inject rồi
36
15
  if (document.getElementById(CONFIG.CONTAINER_ID)) {
37
- console.log('⚠️ VG Coder iframe already injected');
16
+ console.log(' VG Coder already injected');
38
17
  return;
39
18
  }
19
+
20
+ console.log('🚀 Loading VG Coder Bundle from:', CONFIG.BUNDLE_URL);
21
+
22
+ // 2. Tạo Script Tag để load bundle
23
+ // Cách này tốt hơn fetch+eval vì tận dụng cache và debug dễ hơn
24
+ const script = document.createElement('script');
25
+ script.src = CONFIG.BUNDLE_URL;
26
+ script.type = 'text/javascript';
27
+ script.async = true;
28
+
29
+ script.onload = () => {
30
+ console.log('✅ VG Coder Bundle Loaded Successfully');
31
+ };
40
32
 
41
- function getState() {
42
- return localStorage.getItem(CONFIG.STORAGE_KEY_STATE) || CONFIG.STATE_DEFAULT;
43
- }
44
-
45
- function getWidth() {
46
- return localStorage.getItem(CONFIG.STORAGE_KEY_WIDTH) || CONFIG.DEFAULT_WIDTH;
47
- }
48
-
49
- function setState(state) {
50
- localStorage.setItem(CONFIG.STORAGE_KEY_STATE, state);
51
- }
52
-
53
- function setWidth(width) {
54
- localStorage.setItem(CONFIG.STORAGE_KEY_WIDTH, width);
55
- }
56
-
57
- function updateBodyMargin(width) {
58
- if (!document.body.style.transition.includes('margin')) {
59
- document.body.style.transition = 'margin-left 0.3s ease';
60
- }
61
- document.body.style.marginLeft = width;
62
- }
63
-
64
- function removeBodyMargin() {
65
- document.body.style.marginLeft = '0';
66
- }
67
-
68
- function injectStyles() {
69
- const style = document.createElement('style');
70
- style.textContent = '#' + CONFIG.CONTAINER_ID + ' {' +
71
- 'position: fixed; top: 0; left: 0; bottom: 0;' +
72
- 'width: ' + getWidth() + ';' +
73
- 'background: #1a1a1a; z-index: ' + CONFIG.Z_INDEX + ';' +
74
- 'display: flex; flex-direction: column;' +
75
- 'box-shadow: 4px 0 12px rgba(0, 0, 0, 0.3);' +
76
- 'transition: width 0.3s ease, transform 0.3s ease;' +
77
- '}' +
78
- '#' + CONFIG.CONTAINER_ID + '.collapsed { transform: translateX(-100%); }' +
79
- '#' + CONFIG.IFRAME_ID + ' {' +
80
- 'flex: 1; border: none; width: 100%; height: 100%; background: white;' +
81
- '}' +
82
- '#' + CONFIG.CONTROLS_ID + ' {' +
83
- 'position: absolute; top: 50%; right: -36px; transform: translateY(-50%);' +
84
- 'z-index: ' + (CONFIG.Z_INDEX + 1) + '; display: flex; flex-direction: column; gap: 4px;' +
85
- 'transition: right 0.3s ease;' +
86
- '}' +
87
- '#' + CONFIG.CONTROLS_ID + '.fullscreen {' +
88
- 'right: 12px;' +
89
- '}' +
90
- '#' + CONFIG.CONTROLS_ID + ' button {' +
91
- 'background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);' +
92
- 'color: white; border: none; border-radius: 0 6px 6px 0;' +
93
- 'padding: 8px 6px; cursor: pointer; font-size: 18px;' +
94
- 'box-shadow: -2px 2px 6px rgba(0, 0, 0, 0.2);' +
95
- 'transition: all 0.2s ease; width: 32px; height: 32px;' +
96
- 'display: flex; align-items: center; justify-content: center;' +
97
- '}' +
98
- '#' + CONFIG.CONTROLS_ID + ' button.hidden {' +
99
- 'display: none;' +
100
- '}' +
101
- '#' + CONFIG.CONTROLS_ID + ' button:hover {' +
102
- 'background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);' +
103
- 'box-shadow: -3px 3px 8px rgba(0, 0, 0, 0.3);' +
104
- '}' +
105
- '#' + CONFIG.RESIZE_HANDLE_ID + ' {' +
106
- 'position: absolute; right: 0; top: 0; bottom: 0; width: 6px;' +
107
- 'cursor: ew-resize; background: transparent; transition: background 0.2s ease;' +
108
- '}' +
109
- '#' + CONFIG.RESIZE_HANDLE_ID + ':hover { background: rgba(102, 126, 234, 0.5); }' +
110
- '#' + CONFIG.RESIZE_HANDLE_ID + '.resizing { background: rgba(102, 126, 234, 0.8); }';
111
- document.head.appendChild(style);
112
- }
113
-
114
- function createContainer() {
115
- const container = document.createElement('div');
116
- container.id = CONFIG.CONTAINER_ID;
117
- const currentState = getState();
118
- if (currentState === CONFIG.STATE_COLLAPSED) {
119
- container.classList.add('collapsed');
120
- } else if (currentState === CONFIG.STATE_FULLSCREEN) {
121
- container.style.width = CONFIG.FULLSCREEN_WIDTH;
122
- }
123
- return container;
124
- }
125
-
126
- function createIframe() {
127
- const iframe = document.createElement('iframe');
128
- iframe.id = CONFIG.IFRAME_ID;
129
- iframe.src = CONFIG.VG_CODER_URL;
130
- iframe.title = 'VG Coder Dashboard';
131
- iframe.allow = 'clipboard-read; clipboard-write';
132
- return iframe;
133
- }
134
-
135
- function createResizeHandle() {
136
- const handle = document.createElement('div');
137
- handle.id = CONFIG.RESIZE_HANDLE_ID;
138
- return handle;
139
- }
140
-
141
- function createControls() {
142
- const controls = document.createElement('div');
143
- controls.id = CONFIG.CONTROLS_ID;
144
- const currentState = getState();
145
- if (currentState === CONFIG.STATE_FULLSCREEN) {
146
- controls.classList.add('fullscreen');
147
- }
148
- const btnFullscreen = document.createElement('button');
149
- btnFullscreen.innerHTML = currentState === CONFIG.STATE_FULLSCREEN ? '◧' : '▣';
150
- btnFullscreen.title = currentState === CONFIG.STATE_FULLSCREEN ? 'Default (45%)' : 'Fullscreen (100%)';
151
- if (currentState === CONFIG.STATE_COLLAPSED) {
152
- btnFullscreen.classList.add('hidden');
153
- }
154
- const btnCollapse = document.createElement('button');
155
- btnCollapse.innerHTML = currentState === CONFIG.STATE_COLLAPSED ? '▶' : '◄';
156
- btnCollapse.title = currentState === CONFIG.STATE_COLLAPSED ? 'Expand' : 'Collapse';
157
- controls.appendChild(btnFullscreen);
158
- controls.appendChild(btnCollapse);
159
- return controls;
160
- }
161
-
162
- function initResize(container, handle, controls) {
163
- let isResizing = false, startX = 0, startWidth = 0;
164
- handle.addEventListener('mousedown', (e) => {
165
- isResizing = true; startX = e.clientX; startWidth = container.offsetWidth;
166
- handle.classList.add('resizing');
167
- document.body.style.cursor = 'ew-resize';
168
- document.body.style.userSelect = 'none';
169
- e.preventDefault();
170
- });
171
- document.addEventListener('mousemove', (e) => {
172
- if (!isResizing) return;
173
- const deltaX = e.clientX - startX;
174
- const newWidth = startWidth + deltaX;
175
- const maxWidth = window.innerWidth * (CONFIG.MAX_WIDTH_PERCENT / 100);
176
- if (newWidth >= CONFIG.MIN_WIDTH && newWidth <= maxWidth) {
177
- const widthPercent = (newWidth / window.innerWidth) * 100;
178
- container.style.width = widthPercent + '%';
179
- setWidth(widthPercent + '%');
180
- updateBodyMargin(widthPercent + '%');
181
- }
182
- });
183
- document.addEventListener('mouseup', () => {
184
- if (isResizing) {
185
- isResizing = false; handle.classList.remove('resizing');
186
- document.body.style.cursor = '';
187
- document.body.style.userSelect = '';
188
- }
189
- });
190
- }
191
-
192
- function initControls(container, controls) {
193
- const buttons = controls.querySelectorAll('button');
194
- const btnFullscreen = buttons[0];
195
- const btnCollapse = buttons[1];
196
- btnFullscreen.addEventListener('click', () => {
197
- const currentState = getState();
198
- if (currentState === CONFIG.STATE_FULLSCREEN) {
199
- setState(CONFIG.STATE_DEFAULT);
200
- container.style.width = CONFIG.DEFAULT_WIDTH;
201
- controls.classList.remove('fullscreen');
202
- btnFullscreen.innerHTML = '▣';
203
- btnFullscreen.title = 'Fullscreen (100%)';
204
- updateBodyMargin(CONFIG.DEFAULT_WIDTH);
205
- } else {
206
- setState(CONFIG.STATE_FULLSCREEN);
207
- container.style.width = CONFIG.FULLSCREEN_WIDTH;
208
- controls.classList.add('fullscreen');
209
- btnFullscreen.innerHTML = '◧';
210
- btnFullscreen.title = 'Default (45%)';
211
- updateBodyMargin(CONFIG.FULLSCREEN_WIDTH);
212
- }
213
- });
214
- btnCollapse.addEventListener('click', () => {
215
- const currentState = getState();
216
- if (currentState === CONFIG.STATE_COLLAPSED) {
217
- setState(CONFIG.STATE_DEFAULT);
218
- container.classList.remove('collapsed');
219
- container.style.width = CONFIG.DEFAULT_WIDTH;
220
- controls.classList.remove('fullscreen');
221
- btnCollapse.innerHTML = '◄';
222
- btnCollapse.title = 'Collapse';
223
- btnFullscreen.classList.remove('hidden');
224
- btnFullscreen.innerHTML = '▣';
225
- btnFullscreen.title = 'Fullscreen (100%)';
226
- updateBodyMargin(CONFIG.DEFAULT_WIDTH);
227
- } else {
228
- const wasFullscreen = currentState === CONFIG.STATE_FULLSCREEN;
229
- setState(CONFIG.STATE_COLLAPSED);
230
- container.classList.add('collapsed');
231
- if (wasFullscreen) {
232
- controls.classList.remove('fullscreen');
233
- }
234
- btnFullscreen.classList.add('hidden');
235
- btnCollapse.innerHTML = '▶';
236
- btnCollapse.title = 'Expand';
237
- removeBodyMargin();
238
- }
239
- });
240
- }
241
-
242
- function init() {
243
- if (!document.body) {
244
- setTimeout(init, 100);
245
- return;
246
- }
247
- console.log('🚀 Initializing VG Coder iframe injection...');
248
- injectStyles();
249
- const container = createContainer();
250
- const iframe = createIframe();
251
- const resizeHandle = createResizeHandle();
252
- const controls = createControls();
253
- container.appendChild(resizeHandle);
254
- container.appendChild(iframe);
255
- container.appendChild(controls);
256
- document.body.appendChild(container);
257
- initResize(container, resizeHandle, controls);
258
- initControls(container, controls);
259
- const currentState = getState();
260
- if (currentState !== CONFIG.STATE_COLLAPSED) {
261
- const width = currentState === CONFIG.STATE_FULLSCREEN ? CONFIG.FULLSCREEN_WIDTH : getWidth();
262
- updateBodyMargin(width);
263
- }
264
- console.log('✅ VG Coder iframe injected successfully');
265
- }
266
- if (document.readyState === 'loading') {
267
- document.addEventListener('DOMContentLoaded', init);
268
- } else {
269
- init();
270
- }
33
+ script.onerror = () => {
34
+ console.error('❌ Failed to load VG Coder Bundle. Is the server running at port 6868?');
35
+ // Optional: Show a visual error toast on the page
36
+ const toast = document.createElement('div');
37
+ toast.style.cssText = 'position:fixed; top:20px; right:20px; background:#ff3b30; color:white; padding:10px 20px; border-radius:8px; z-index:999999; font-family:sans-serif; box-shadow:0 4px 12px rgba(0,0,0,0.2);';
38
+ toast.textContent = '⚠️ VG Coder Connection Failed (Is Server Running?)';
39
+ document.body.appendChild(toast);
40
+ setTimeout(() => toast.remove(), 5000);
41
+ };
42
+
43
+ // 3. Inject vào Head hoặc Body
44
+ (document.head || document.body).appendChild(script);
45
+
271
46
  })();
272
47
  `;
Binary file