vg-coder-cli 2.0.4 → 2.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vg-coder-cli",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "🚀 CLI tool to analyze projects, concatenate source files, count tokens, and export HTML with syntax highlighting and copy functionality",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -167,16 +167,11 @@
167
167
  /* Buttons */
168
168
  .btn-group {
169
169
  display: grid;
170
- grid-template-columns: 1fr;
170
+ grid-template-columns: 1fr 1fr;
171
+ /* 2 columns for better layout */
171
172
  gap: 12px;
172
173
  }
173
174
 
174
- @media (min-width: 600px) {
175
- .btn-group {
176
- grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
177
- }
178
- }
179
-
180
175
  .btn {
181
176
  border: none;
182
177
  background: var(--ios-blue);
@@ -204,6 +199,11 @@
204
199
  color: var(--ios-blue);
205
200
  }
206
201
 
202
+ /* Full width button in single column if needed */
203
+ .btn-full {
204
+ grid-column: 1 / -1;
205
+ }
206
+
207
207
  .btn-copy {
208
208
  background: #E5E5EA;
209
209
  color: black;
@@ -367,7 +367,7 @@
367
367
  </div>
368
368
  <div class="prompt-content" id="system-prompt-content">
369
369
  <div class="code-block" id="prompt-text"></div>
370
- <button class="btn btn-secondary" onclick="copySystemPrompt()" style="width: 100%">
370
+ <button class="btn btn-secondary btn-full" onclick="copySystemPrompt()">
371
371
  <span id="copy-icon">📋</span>
372
372
  <span id="copy-text">Copy Prompt</span>
373
373
  </button>
@@ -396,9 +396,6 @@
396
396
  <button class="btn btn-secondary" onclick="copyAnalyzeResult()">
397
397
  <span id="analyze-copy-icon">📋</span> Copy
398
398
  </button>
399
- <button class="btn btn-copy" onclick="copyAnalyzeAsFile()">
400
- <span id="analyze-file-icon">📄</span> File
401
- </button>
402
399
  </div>
403
400
  <div class="response" id="analyze-response"></div>
404
401
  </div>
@@ -502,9 +499,35 @@ EOF
502
499
  setTimeout(() => toast.classList.remove('show'), 3000);
503
500
  }
504
501
 
505
- async function copyToClipboard(text, btnElement, successIconId, successTextId) {
502
+ // --- ROBUST COPY FUNCTION (MODERN + FALLBACK) ---
503
+ function fallbackCopyTextToClipboard(text) {
504
+ var textArea = document.createElement("textarea");
505
+ textArea.value = text;
506
+
507
+ // Ensure textarea is not visible but part of DOM
508
+ textArea.style.position = "fixed";
509
+ textArea.style.left = "-9999px";
510
+ textArea.style.top = "0";
511
+ document.body.appendChild(textArea);
512
+
513
+ textArea.focus();
514
+ textArea.select();
515
+
506
516
  try {
507
- await navigator.clipboard.writeText(text);
517
+ var successful = document.execCommand('copy');
518
+ return successful;
519
+ } catch (err) {
520
+ console.error('Fallback: Oops, unable to copy', err);
521
+ return false;
522
+ } finally {
523
+ document.body.removeChild(textArea);
524
+ }
525
+ }
526
+
527
+ async function copyToClipboard(text, btnElement, successIconId, successTextId) {
528
+ if (!text) return showToast('Nothing to copy', 'error');
529
+
530
+ const updateUI = () => {
508
531
  if (btnElement) {
509
532
  btnElement.classList.add('copied');
510
533
  const icon = document.getElementById(successIconId);
@@ -523,8 +546,29 @@ EOF
523
546
  }, 2000);
524
547
  }
525
548
  showToast('Copied to clipboard!');
526
- } catch (err) {
527
- showToast('Failed to copy', 'error');
549
+ };
550
+
551
+ // Try Modern API first
552
+ if (navigator.clipboard && navigator.clipboard.writeText) {
553
+ try {
554
+ await navigator.clipboard.writeText(text);
555
+ updateUI();
556
+ } catch (err) {
557
+ console.warn('Modern copy failed, trying fallback', err);
558
+ // Try fallback if modern API fails
559
+ if (fallbackCopyTextToClipboard(text)) {
560
+ updateUI();
561
+ } else {
562
+ showToast('Failed to copy', 'error');
563
+ }
564
+ }
565
+ } else {
566
+ // Use fallback immediately if API doesn't exist
567
+ if (fallbackCopyTextToClipboard(text)) {
568
+ updateUI();
569
+ } else {
570
+ showToast('Failed to copy', 'error');
571
+ }
528
572
  }
529
573
  }
530
574
 
@@ -576,21 +620,13 @@ EOF
576
620
  async function copyAnalyzeResult() {
577
621
  const btn = event.target.closest('.btn');
578
622
  if (!lastAnalyzeResult) {
579
- showToast('Please analyze first', 'error');
623
+ // If not analyzed yet, try to analyze silently or warn
624
+ showToast('Please analyze/download first', 'error');
580
625
  return;
581
626
  }
582
627
  copyToClipboard(lastAnalyzeResult, btn, 'analyze-copy-icon', 'analyze-copy-text');
583
628
  }
584
629
 
585
- async function copyAnalyzeAsFile() {
586
- const btn = event.target.closest('.btn');
587
- if (!lastAnalyzeResult) {
588
- showToast('Please analyze first', 'error');
589
- return;
590
- }
591
- copyToClipboard(lastAnalyzeResult, btn, 'analyze-file-icon', 'analyze-file-text');
592
- }
593
-
594
630
  async function testExecute() {
595
631
  const btn = event.target.closest('.btn');
596
632
  const bash = document.getElementById('execute-bash').value;
@@ -613,7 +649,6 @@ EOF
613
649
  }
614
650
 
615
651
  async function executeFromClipboard() {
616
- const btn = event.target.closest('.btn');
617
652
  try {
618
653
  const text = await navigator.clipboard.readText();
619
654
  if (!text.trim()) return showToast('Clipboard is empty', 'error');
Binary file