@gxp-dev/tools 2.0.13 → 2.0.14
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 +12 -2
- 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.js +31 -12
- package/dist/tui/App.d.ts.map +1 -1
- package/dist/tui/App.js +10 -2
- 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
|
@@ -524,11 +524,21 @@ export default function App({ autoStart, args }: AppProps) {
|
|
|
524
524
|
// Use dynamic imports for ES modules
|
|
525
525
|
const path = await import('path');
|
|
526
526
|
const fs = await import('fs');
|
|
527
|
+
const url = await import('url');
|
|
527
528
|
const { createRequire } = await import('module');
|
|
528
529
|
|
|
530
|
+
// Get the directory of this file and resolve to the utils directory
|
|
531
|
+
const __filename = url.fileURLToPath(import.meta.url);
|
|
532
|
+
const __dirname = path.dirname(__filename);
|
|
533
|
+
|
|
534
|
+
// The compiled JS is in dist/tui/, utils is in bin/lib/utils/
|
|
535
|
+
// From dist/tui/ we need to go up to package root, then into bin/lib/utils/
|
|
536
|
+
const packageRoot = path.resolve(__dirname, '..', '..');
|
|
537
|
+
const utilsPath = path.join(packageRoot, 'bin', 'lib', 'utils', 'extract-config.js');
|
|
538
|
+
|
|
529
539
|
// Create a require function to load CommonJS modules
|
|
530
|
-
const
|
|
531
|
-
const extractConfigUtils =
|
|
540
|
+
const requireCjs = createRequire(import.meta.url);
|
|
541
|
+
const extractConfigUtils = requireCjs(utilsPath) as {
|
|
532
542
|
extractConfigFromSource: (srcDir: string) => ExtractedConfig;
|
|
533
543
|
mergeConfig: (existing: Record<string, unknown>, extracted: ExtractedConfig, options: { overwrite: boolean }) => Record<string, unknown>;
|
|
534
544
|
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,
|