@gxp-dev/tools 2.0.13 → 2.0.15
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/bin/lib/tui/App.tsx +36 -23
- package/bin/lib/tui/services/ExtensionService.ts +34 -0
- package/browser-extensions/chrome/manifest.json +1 -1
- package/browser-extensions/chrome/popup.html +339 -237
- package/browser-extensions/chrome/popup.js +110 -110
- package/browser-extensions/firefox/manifest.json +2 -1
- package/browser-extensions/firefox/popup.html +478 -519
- package/browser-extensions/firefox/popup.js +444 -481
- package/dist/tui/App.d.ts.map +1 -1
- package/dist/tui/App.js +34 -24
- package/dist/tui/App.js.map +1 -1
- package/dist/tui/services/ExtensionService.d.ts.map +1 -1
- package/dist/tui/services/ExtensionService.js +30 -0
- package/dist/tui/services/ExtensionService.js.map +1 -1
- package/package.json +1 -1
- package/scripts/launch-chrome.js +39 -0
package/bin/lib/tui/App.tsx
CHANGED
|
@@ -451,30 +451,33 @@ export default function App({ autoStart, args }: AppProps) {
|
|
|
451
451
|
};
|
|
452
452
|
|
|
453
453
|
const addSystemLog = (message: string) => {
|
|
454
|
-
//
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
}
|
|
454
|
+
// Use functional update to properly handle rapid successive calls
|
|
455
|
+
setServices(prev => {
|
|
456
|
+
const existingSystem = prev.find(s => s.id === 'system');
|
|
457
|
+
if (existingSystem) {
|
|
458
|
+
// Add message to existing system service
|
|
459
|
+
return prev.map(s =>
|
|
460
|
+
s.id === 'system' ? { ...s, logs: [...s.logs, message] } : s
|
|
461
|
+
);
|
|
462
|
+
} else {
|
|
463
|
+
// Create new system service with the message
|
|
464
|
+
const newService: Service = {
|
|
465
|
+
id: 'system',
|
|
466
|
+
name: 'System',
|
|
467
|
+
status: 'running',
|
|
468
|
+
logs: [message],
|
|
469
|
+
};
|
|
470
|
+
return [...prev, newService];
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
473
|
|
|
474
474
|
// Switch to system tab
|
|
475
475
|
setTimeout(() => {
|
|
476
|
-
|
|
477
|
-
|
|
476
|
+
setServices(current => {
|
|
477
|
+
const sysIdx = current.findIndex(s => s.id === 'system');
|
|
478
|
+
if (sysIdx >= 0) setActiveTab(sysIdx);
|
|
479
|
+
return current; // Don't modify, just read
|
|
480
|
+
});
|
|
478
481
|
}, 50);
|
|
479
482
|
};
|
|
480
483
|
|
|
@@ -524,11 +527,21 @@ export default function App({ autoStart, args }: AppProps) {
|
|
|
524
527
|
// Use dynamic imports for ES modules
|
|
525
528
|
const path = await import('path');
|
|
526
529
|
const fs = await import('fs');
|
|
530
|
+
const url = await import('url');
|
|
527
531
|
const { createRequire } = await import('module');
|
|
528
532
|
|
|
533
|
+
// Get the directory of this file and resolve to the utils directory
|
|
534
|
+
const __filename = url.fileURLToPath(import.meta.url);
|
|
535
|
+
const __dirname = path.dirname(__filename);
|
|
536
|
+
|
|
537
|
+
// The compiled JS is in dist/tui/, utils is in bin/lib/utils/
|
|
538
|
+
// From dist/tui/ we need to go up to package root, then into bin/lib/utils/
|
|
539
|
+
const packageRoot = path.resolve(__dirname, '..', '..');
|
|
540
|
+
const utilsPath = path.join(packageRoot, 'bin', 'lib', 'utils', 'extract-config.js');
|
|
541
|
+
|
|
529
542
|
// Create a require function to load CommonJS modules
|
|
530
|
-
const
|
|
531
|
-
const extractConfigUtils =
|
|
543
|
+
const requireCjs = createRequire(import.meta.url);
|
|
544
|
+
const extractConfigUtils = requireCjs(utilsPath) as {
|
|
532
545
|
extractConfigFromSource: (srcDir: string) => ExtractedConfig;
|
|
533
546
|
mergeConfig: (existing: Record<string, unknown>, extracted: ExtractedConfig, options: { overwrite: boolean }) => Record<string, unknown>;
|
|
534
547
|
generateSummary: (config: ExtractedConfig) => string;
|
|
@@ -20,6 +20,37 @@ function getToolkitRoot(): string {
|
|
|
20
20
|
return path.resolve(__dirname, '..', '..', '..');
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Generate extension defaults based on environment variables
|
|
25
|
+
* This creates a defaults.json file that the popup.js reads on load
|
|
26
|
+
*/
|
|
27
|
+
function generateExtensionDefaults(extensionPath: string, useHttps: boolean, port: number | string): void {
|
|
28
|
+
const protocol = useHttps ? 'https' : 'http';
|
|
29
|
+
const baseUrl = `${protocol}://localhost:${port}`;
|
|
30
|
+
|
|
31
|
+
const defaults = {
|
|
32
|
+
// Extension should be enabled by default when launched from CLI
|
|
33
|
+
enabled: true,
|
|
34
|
+
// JS redirect URL based on env
|
|
35
|
+
jsRedirectUrl: `${baseUrl}/src/Plugin.vue`,
|
|
36
|
+
// CSS redirect URL (empty by default, uses blank CSS)
|
|
37
|
+
cssRedirectUrl: '',
|
|
38
|
+
// CSS override should be enabled by default
|
|
39
|
+
cssRuleEnabled: true,
|
|
40
|
+
// Return blank CSS by default
|
|
41
|
+
cssReturnBlank: true,
|
|
42
|
+
// Use custom URL pattern by default
|
|
43
|
+
jsUseCustomPattern: true,
|
|
44
|
+
cssUseCustomPattern: true,
|
|
45
|
+
// Cache settings
|
|
46
|
+
clearCacheOnEnable: true,
|
|
47
|
+
disableCacheForRedirects: true,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const defaultsPath = path.join(extensionPath, 'defaults.json');
|
|
51
|
+
fs.writeFileSync(defaultsPath, JSON.stringify(defaults, null, 2));
|
|
52
|
+
}
|
|
53
|
+
|
|
23
54
|
// Find the extension path (project-local or toolkit built-in)
|
|
24
55
|
function findExtensionPath(browser: BrowserType, cwd: string): string | null {
|
|
25
56
|
// Check local project first
|
|
@@ -64,6 +95,9 @@ export function startExtension(options: ExtensionOptions): void {
|
|
|
64
95
|
return;
|
|
65
96
|
}
|
|
66
97
|
|
|
98
|
+
// Generate defaults.json for the extension based on environment
|
|
99
|
+
generateExtensionDefaults(extensionPath, useHttps, port);
|
|
100
|
+
|
|
67
101
|
if (browser === 'firefox') {
|
|
68
102
|
const config: ServiceConfig = {
|
|
69
103
|
id: serviceId,
|