ai-extension-preview 0.1.1 → 0.1.3
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/dist/plugins/BrowserPlugin.js +26 -17
- package/package.json +1 -1
|
@@ -84,14 +84,6 @@ export const BrowserPlugin = {
|
|
|
84
84
|
// Convert Chrome path to Windows format if in WSL
|
|
85
85
|
// /mnt/c/Program Files/... -> C:\Program Files\...
|
|
86
86
|
let executable = chromePath;
|
|
87
|
-
let args = [
|
|
88
|
-
`--load-extension=${extensionPath}`,
|
|
89
|
-
`--user-data-dir=${userDataDir}`,
|
|
90
|
-
'--no-first-run',
|
|
91
|
-
'--no-default-browser-check',
|
|
92
|
-
'--disable-gpu',
|
|
93
|
-
'about:blank'
|
|
94
|
-
];
|
|
95
87
|
// If WSL, use a batch file to handle the launch robustly
|
|
96
88
|
if (isWSL) {
|
|
97
89
|
const driveLetter = chromePath.match(/\/mnt\/([a-z])\//)?.[1] || 'c';
|
|
@@ -103,8 +95,6 @@ export const BrowserPlugin = {
|
|
|
103
95
|
const winDist = 'C:\\Temp\\ai-ext-preview';
|
|
104
96
|
const winProfile = 'C:\\Temp\\ai-ext-profile';
|
|
105
97
|
// Create the batch file content
|
|
106
|
-
// NOTE: We quote the executable path and arguments carefully
|
|
107
|
-
// start "" "Executable" args...
|
|
108
98
|
const batContent = `@echo off
|
|
109
99
|
start "" "${winChromePath}" --load-extension="${winDist}" --user-data-dir="${winProfile}" --no-first-run --no-default-browser-check --disable-gpu about:blank
|
|
110
100
|
exit
|
|
@@ -120,10 +110,9 @@ exit
|
|
|
120
110
|
}
|
|
121
111
|
await ctx.actions.runAction('core:log', { level: 'info', message: `EXEC: ${winBatPath}` });
|
|
122
112
|
// Execute the batch file via cmd.exe using spawn + PATH lookup
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const subprocess = spawn(executable, ['/c', winBatPath], {
|
|
113
|
+
const cli = 'cmd.exe';
|
|
114
|
+
await ctx.actions.runAction('core:log', { level: 'info', message: `SPAWN (WSL): ${cli} /c ${winBatPath}` });
|
|
115
|
+
const subprocess = spawn(cli, ['/c', winBatPath], {
|
|
127
116
|
detached: true,
|
|
128
117
|
stdio: 'ignore',
|
|
129
118
|
cwd: '/mnt/c'
|
|
@@ -132,9 +121,23 @@ exit
|
|
|
132
121
|
return true;
|
|
133
122
|
}
|
|
134
123
|
else {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const
|
|
124
|
+
// Standard Windows / Linux Launch (Git Bash / Native)
|
|
125
|
+
// Normalize paths (stripping trailing slashes which Chrome hates)
|
|
126
|
+
const safeDist = path.resolve(extensionPath);
|
|
127
|
+
const safeProfile = path.resolve(userDataDir);
|
|
128
|
+
await ctx.actions.runAction('core:log', { level: 'info', message: `SPAWN: ${executable}` });
|
|
129
|
+
await ctx.actions.runAction('core:log', { level: 'info', message: `EXT PATH: ${safeDist}` });
|
|
130
|
+
// Reconstruct args with safe paths
|
|
131
|
+
const cleanArgs = [
|
|
132
|
+
`--load-extension=${safeDist}`,
|
|
133
|
+
`--user-data-dir=${safeProfile}`,
|
|
134
|
+
'--no-first-run',
|
|
135
|
+
'--no-default-browser-check',
|
|
136
|
+
'--disable-gpu',
|
|
137
|
+
'chrome://extensions' // Better for verifying if it loaded
|
|
138
|
+
];
|
|
139
|
+
await ctx.actions.runAction('core:log', { level: 'info', message: `ARGS: ${cleanArgs.join(' ')}` });
|
|
140
|
+
const subprocess = spawn(executable, cleanArgs, {
|
|
138
141
|
detached: true,
|
|
139
142
|
stdio: 'ignore'
|
|
140
143
|
});
|
|
@@ -145,6 +148,12 @@ exit
|
|
|
145
148
|
ctx.actions.registerAction({
|
|
146
149
|
id: 'browser:start',
|
|
147
150
|
handler: async () => {
|
|
151
|
+
// On Windows (including Git Bash), web-ext is unreliable for loading extensions correctly.
|
|
152
|
+
// We force detached mode to ensure the extension loads.
|
|
153
|
+
if (process.platform === 'win32') {
|
|
154
|
+
await ctx.actions.runAction('core:log', { level: 'warning', message: 'Windows detected: Forcing Detached Mode for reliability.' });
|
|
155
|
+
return await launchDetached();
|
|
156
|
+
}
|
|
148
157
|
await ctx.actions.runAction('core:log', { level: 'info', message: 'Launching browser...' });
|
|
149
158
|
try {
|
|
150
159
|
// Try web-ext first
|