ai-extension-preview 0.1.7 → 0.1.8
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 +36 -10
- package/package.json +2 -2
|
@@ -22,6 +22,15 @@ function findChrome() {
|
|
|
22
22
|
}
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
|
+
const normalizePathToWindows = (p) => {
|
|
26
|
+
// Handle Git Bash /c/ style
|
|
27
|
+
const gitBashMatch = p.match(/^\/([a-z])\/(.*)/i);
|
|
28
|
+
if (gitBashMatch) {
|
|
29
|
+
return `${gitBashMatch[1].toUpperCase()}:\\${gitBashMatch[2].replace(/\//g, '\\')}`;
|
|
30
|
+
}
|
|
31
|
+
// Handle Forward slashes
|
|
32
|
+
return p.replace(/\//g, '\\');
|
|
33
|
+
};
|
|
25
34
|
export const BrowserPlugin = {
|
|
26
35
|
name: 'browser',
|
|
27
36
|
version: '1.0.0',
|
|
@@ -36,7 +45,11 @@ export const BrowserPlugin = {
|
|
|
36
45
|
return false;
|
|
37
46
|
}
|
|
38
47
|
const isWSL = fs.existsSync('/mnt/c');
|
|
39
|
-
let executable = chromePath;
|
|
48
|
+
let executable = chromePath;
|
|
49
|
+
// Normalize Executable for Native Windows (Git Bash)
|
|
50
|
+
if (!isWSL && process.platform === 'win32') {
|
|
51
|
+
executable = normalizePathToWindows(chromePath);
|
|
52
|
+
}
|
|
40
53
|
const STAGING_DIR = isWSL ? '/mnt/c/Temp/ai-ext-preview' : path.join(config.workDir, '../staging');
|
|
41
54
|
const WIN_PROFILE_DIR = 'C:/Temp/ai-ext-profile';
|
|
42
55
|
// For native windows/linux, use local staging path
|
|
@@ -51,6 +64,12 @@ export const BrowserPlugin = {
|
|
|
51
64
|
fs.ensureDirSync(STAGING_DIR);
|
|
52
65
|
fs.copySync(DIST_DIR, STAGING_DIR);
|
|
53
66
|
await ctx.actions.runAction('core:log', { level: 'info', message: `Synced code to Staging` });
|
|
67
|
+
// DEBUG: Log contents of staging
|
|
68
|
+
try {
|
|
69
|
+
const files = fs.readdirSync(STAGING_DIR);
|
|
70
|
+
await ctx.actions.runAction('core:log', { level: 'info', message: `Staging Contents: ${files.join(', ')}` });
|
|
71
|
+
}
|
|
72
|
+
catch (e) { }
|
|
54
73
|
// Emit staged event for ServerPlugin (optional for now, but good practice)
|
|
55
74
|
ctx.events.emit('browser:staged', { path: STAGING_DIR });
|
|
56
75
|
}
|
|
@@ -85,7 +104,8 @@ export const BrowserPlugin = {
|
|
|
85
104
|
let extensionRoot = findExtensionRoot(STAGING_DIR) || STAGING_DIR;
|
|
86
105
|
// Check if we found a valid root
|
|
87
106
|
if (!fs.existsSync(path.join(extensionRoot, 'manifest.json'))) {
|
|
88
|
-
await ctx.actions.runAction('core:log', { level: 'error', message: `[CRITICAL] manifest.json not found in ${
|
|
107
|
+
await ctx.actions.runAction('core:log', { level: 'error', message: `[CRITICAL] manifest.json not found in ${extensionRoot}. Extension will not load.` });
|
|
108
|
+
await ctx.actions.runAction('core:log', { level: 'info', message: `Checked Path: ${extensionRoot}` });
|
|
89
109
|
}
|
|
90
110
|
else if (extensionRoot !== STAGING_DIR) {
|
|
91
111
|
await ctx.actions.runAction('core:log', { level: 'info', message: `Detected nested extension at: ${path.basename(extensionRoot)}` });
|
|
@@ -112,6 +132,7 @@ export const BrowserPlugin = {
|
|
|
112
132
|
const winDistRoot = relative ? `C:\\Temp\\ai-ext-preview\\${relative}` : 'C:\\Temp\\ai-ext-preview';
|
|
113
133
|
const finalWinDist = winDistRoot.replace(/\//g, '\\');
|
|
114
134
|
const winProfile = 'C:\\Temp\\ai-ext-profile';
|
|
135
|
+
await ctx.actions.runAction('core:log', { level: 'info', message: `WSL Launch Target: ${finalWinDist}` });
|
|
115
136
|
const batContent = `@echo off
|
|
116
137
|
start "" "${winChromePath}" --load-extension="${finalWinDist}" --user-data-dir="${winProfile}" --no-first-run --no-default-browser-check --disable-gpu about:blank
|
|
117
138
|
exit
|
|
@@ -122,7 +143,7 @@ exit
|
|
|
122
143
|
fs.writeFileSync(batPath, batContent);
|
|
123
144
|
}
|
|
124
145
|
catch (e) {
|
|
125
|
-
|
|
146
|
+
await ctx.actions.runAction('core:log', { level: 'error', message: `WSL Write Bat Failed: ${e.message}` });
|
|
126
147
|
}
|
|
127
148
|
const cli = 'cmd.exe';
|
|
128
149
|
const subprocess = spawn(cli, ['/c', winBatPath], {
|
|
@@ -138,8 +159,8 @@ exit
|
|
|
138
159
|
// Use extensionRoot which points to the detected subfolder or root
|
|
139
160
|
const safeDist = path.resolve(extensionRoot);
|
|
140
161
|
const safeProfile = path.join(path.dirname(config.workDir), 'profile'); // ~/.ai-extension-preview/profile
|
|
141
|
-
await ctx.actions.runAction('core:log', { level: 'info', message: `
|
|
142
|
-
await ctx.actions.runAction('core:log', { level: 'info', message: `
|
|
162
|
+
await ctx.actions.runAction('core:log', { level: 'info', message: `Native Launch Executable: ${executable}` });
|
|
163
|
+
await ctx.actions.runAction('core:log', { level: 'info', message: `Native Launch Target: ${safeDist}` });
|
|
143
164
|
const cleanArgs = [
|
|
144
165
|
`--load-extension=${safeDist}`,
|
|
145
166
|
`--user-data-dir=${safeProfile}`,
|
|
@@ -148,11 +169,16 @@ exit
|
|
|
148
169
|
'--disable-gpu',
|
|
149
170
|
'chrome://extensions'
|
|
150
171
|
];
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
172
|
+
try {
|
|
173
|
+
const subprocess = spawn(executable, cleanArgs, {
|
|
174
|
+
detached: true,
|
|
175
|
+
stdio: 'ignore'
|
|
176
|
+
});
|
|
177
|
+
subprocess.unref();
|
|
178
|
+
}
|
|
179
|
+
catch (spawnErr) {
|
|
180
|
+
await ctx.actions.runAction('core:log', { level: 'error', message: `Spawn Failed: ${spawnErr.message}` });
|
|
181
|
+
}
|
|
156
182
|
return true;
|
|
157
183
|
}
|
|
158
184
|
};
|
package/package.json
CHANGED