codex-lens 0.1.9 → 0.1.10
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/watcher.js +9 -4
- package/package.json +1 -1
- package/src/watcher.js +11 -4
package/dist/watcher.js
CHANGED
|
@@ -139,7 +139,14 @@ class FileWatcher {
|
|
|
139
139
|
}
|
|
140
140
|
handleChange(filePath, eventType) {
|
|
141
141
|
try {
|
|
142
|
-
|
|
142
|
+
const isCode = this.isCodeFile(filePath);
|
|
143
|
+
if (eventType === "add") {
|
|
144
|
+
logger.info(`File added: ${filePath}`);
|
|
145
|
+
this.emitFileTreeUpdate();
|
|
146
|
+
} else {
|
|
147
|
+
logger.info(`File changed: ${filePath}`);
|
|
148
|
+
}
|
|
149
|
+
if (!isCode) return;
|
|
143
150
|
const stats = statSync(filePath);
|
|
144
151
|
if (stats.size > 5 * 1024 * 1024) {
|
|
145
152
|
logger.warn(`Skipping large file: ${filePath}`);
|
|
@@ -149,13 +156,10 @@ class FileWatcher {
|
|
|
149
156
|
const oldContent = this.fileContents.get(filePath) || "";
|
|
150
157
|
this.fileContents.set(filePath, newContent);
|
|
151
158
|
if (eventType === "add") {
|
|
152
|
-
logger.info(`File added: ${filePath}`);
|
|
153
159
|
const lines = newContent.split("\n");
|
|
154
160
|
const diff = lines.map((line) => ({ content: line, added: true }));
|
|
155
161
|
this.emitFileChange(filePath, newContent, diff);
|
|
156
|
-
this.emitFileTreeUpdate();
|
|
157
162
|
} else {
|
|
158
|
-
logger.info(`File changed: ${filePath}`);
|
|
159
163
|
const changes = diffLines(oldContent, newContent);
|
|
160
164
|
const diff = [];
|
|
161
165
|
for (const change of changes) {
|
|
@@ -184,6 +188,7 @@ class FileWatcher {
|
|
|
184
188
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
185
189
|
}
|
|
186
190
|
});
|
|
191
|
+
this.emitFileTreeUpdate();
|
|
187
192
|
}
|
|
188
193
|
emitFileChange(filePath, newContent, diff) {
|
|
189
194
|
this.wsEmitter({
|
package/package.json
CHANGED
package/src/watcher.js
CHANGED
|
@@ -118,7 +118,16 @@ class FileWatcher {
|
|
|
118
118
|
|
|
119
119
|
handleChange(filePath, eventType) {
|
|
120
120
|
try {
|
|
121
|
-
|
|
121
|
+
const isCode = this.isCodeFile(filePath);
|
|
122
|
+
|
|
123
|
+
if (eventType === 'add') {
|
|
124
|
+
logger.info(`File added: ${filePath}`);
|
|
125
|
+
this.emitFileTreeUpdate();
|
|
126
|
+
} else {
|
|
127
|
+
logger.info(`File changed: ${filePath}`);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (!isCode) return;
|
|
122
131
|
|
|
123
132
|
const stats = statSync(filePath);
|
|
124
133
|
if (stats.size > 5 * 1024 * 1024) {
|
|
@@ -132,13 +141,10 @@ class FileWatcher {
|
|
|
132
141
|
this.fileContents.set(filePath, newContent);
|
|
133
142
|
|
|
134
143
|
if (eventType === 'add') {
|
|
135
|
-
logger.info(`File added: ${filePath}`);
|
|
136
144
|
const lines = newContent.split('\n');
|
|
137
145
|
const diff = lines.map(line => ({ content: line, added: true }));
|
|
138
146
|
this.emitFileChange(filePath, newContent, diff);
|
|
139
|
-
this.emitFileTreeUpdate();
|
|
140
147
|
} else {
|
|
141
|
-
logger.info(`File changed: ${filePath}`);
|
|
142
148
|
const changes = diffLines(oldContent, newContent);
|
|
143
149
|
const diff = [];
|
|
144
150
|
|
|
@@ -170,6 +176,7 @@ class FileWatcher {
|
|
|
170
176
|
timestamp: new Date().toISOString()
|
|
171
177
|
}
|
|
172
178
|
});
|
|
179
|
+
this.emitFileTreeUpdate();
|
|
173
180
|
}
|
|
174
181
|
|
|
175
182
|
emitFileChange(filePath, newContent, diff) {
|