@theia/filesystem 1.77.0-next.57 → 1.77.0-next.63
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/lib/common/filesystem-watcher-protocol.d.ts +4 -0
- package/lib/common/filesystem-watcher-protocol.d.ts.map +1 -1
- package/lib/node/disk-file-system-provider.d.ts.map +1 -1
- package/lib/node/disk-file-system-provider.js +2 -1
- package/lib/node/disk-file-system-provider.js.map +1 -1
- package/lib/node/filesystem-backend-module.d.ts +2 -2
- package/lib/node/filesystem-backend-module.d.ts.map +1 -1
- package/lib/node/filesystem-backend-module.js +5 -4
- package/lib/node/filesystem-backend-module.js.map +1 -1
- package/lib/node/filesystem-watcher-service-impl.d.ts +30 -0
- package/lib/node/filesystem-watcher-service-impl.d.ts.map +1 -0
- package/lib/node/filesystem-watcher-service-impl.js +92 -0
- package/lib/node/filesystem-watcher-service-impl.js.map +1 -0
- package/lib/node/filesystem-watcher-service-impl.spec.d.ts +2 -0
- package/lib/node/filesystem-watcher-service-impl.spec.d.ts.map +1 -0
- package/lib/node/filesystem-watcher-service-impl.spec.js +202 -0
- package/lib/node/filesystem-watcher-service-impl.spec.js.map +1 -0
- package/lib/node/filesystem-watcher.d.ts +93 -0
- package/lib/node/filesystem-watcher.d.ts.map +1 -0
- package/lib/node/filesystem-watcher.js +134 -0
- package/lib/node/filesystem-watcher.js.map +1 -0
- package/lib/node/nodejs-watcher/node-directory-watcher.d.ts +175 -0
- package/lib/node/nodejs-watcher/node-directory-watcher.d.ts.map +1 -0
- package/lib/node/nodejs-watcher/node-directory-watcher.js +580 -0
- package/lib/node/nodejs-watcher/node-directory-watcher.js.map +1 -0
- package/lib/node/nodejs-watcher/node-directory-watcher.spec.d.ts +2 -0
- package/lib/node/nodejs-watcher/node-directory-watcher.spec.d.ts.map +1 -0
- package/lib/node/nodejs-watcher/node-directory-watcher.spec.js +1284 -0
- package/lib/node/nodejs-watcher/node-directory-watcher.spec.js.map +1 -0
- package/lib/node/nodejs-watcher/watch-request-router.d.ts +63 -0
- package/lib/node/nodejs-watcher/watch-request-router.d.ts.map +1 -0
- package/lib/node/nodejs-watcher/watch-request-router.js +183 -0
- package/lib/node/nodejs-watcher/watch-request-router.js.map +1 -0
- package/lib/node/nodejs-watcher/watcher-host.d.ts +50 -0
- package/lib/node/nodejs-watcher/watcher-host.d.ts.map +1 -0
- package/lib/node/nodejs-watcher/watcher-host.js +99 -0
- package/lib/node/nodejs-watcher/watcher-host.js.map +1 -0
- package/lib/node/parcel-watcher/index.js +2 -2
- package/lib/node/parcel-watcher/index.js.map +1 -1
- package/lib/node/parcel-watcher/parcel-filesystem-service.d.ts +14 -194
- package/lib/node/parcel-watcher/parcel-filesystem-service.d.ts.map +1 -1
- package/lib/node/parcel-watcher/parcel-filesystem-service.js +7 -424
- package/lib/node/parcel-watcher/parcel-filesystem-service.js.map +1 -1
- package/lib/node/parcel-watcher/parcel-filesystem-watcher.spec.js +2 -2
- package/lib/node/parcel-watcher/parcel-filesystem-watcher.spec.js.map +1 -1
- package/lib/node/parcel-watcher/parcel-watcher-exclude.spec.js +3 -3
- package/lib/node/parcel-watcher/parcel-watcher-exclude.spec.js.map +1 -1
- package/lib/node/parcel-watcher/parcel-watcher-retry.spec.js +2 -2
- package/lib/node/parcel-watcher/parcel-watcher-retry.spec.js.map +1 -1
- package/lib/node/parcel-watcher/parcel-watcher.d.ts +165 -0
- package/lib/node/parcel-watcher/parcel-watcher.d.ts.map +1 -0
- package/lib/node/parcel-watcher/parcel-watcher.js +370 -0
- package/lib/node/parcel-watcher/parcel-watcher.js.map +1 -0
- package/lib/node/test/watcher-test-helper.d.ts +21 -0
- package/lib/node/test/watcher-test-helper.d.ts.map +1 -0
- package/lib/node/test/watcher-test-helper.js +56 -0
- package/lib/node/test/watcher-test-helper.js.map +1 -0
- package/package.json +3 -3
- package/src/common/filesystem-watcher-protocol.ts +4 -0
- package/src/node/disk-file-system-provider.ts +2 -1
- package/src/node/filesystem-backend-module.ts +5 -4
- package/src/node/filesystem-watcher-service-impl.spec.ts +272 -0
- package/src/node/filesystem-watcher-service-impl.ts +109 -0
- package/src/node/filesystem-watcher.ts +197 -0
- package/src/node/nodejs-watcher/node-directory-watcher.spec.ts +1594 -0
- package/src/node/nodejs-watcher/node-directory-watcher.ts +664 -0
- package/src/node/nodejs-watcher/watch-request-router.ts +224 -0
- package/src/node/nodejs-watcher/watcher-host.ts +126 -0
- package/src/node/parcel-watcher/index.ts +2 -2
- package/src/node/parcel-watcher/parcel-filesystem-service.ts +14 -500
- package/src/node/parcel-watcher/parcel-filesystem-watcher.spec.ts +4 -4
- package/src/node/parcel-watcher/parcel-watcher-exclude.spec.ts +4 -4
- package/src/node/parcel-watcher/parcel-watcher-retry.spec.ts +3 -3
- package/src/node/parcel-watcher/parcel-watcher.ts +432 -0
- package/src/node/test/watcher-test-helper.ts +58 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2017-2018 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.RecursiveWatcherProvider = exports.ParcelWatcher = exports.WatcherDisposal = exports.ParcelFileSystemWatcherServerOptions = void 0;
|
|
19
|
+
const path = require("path");
|
|
20
|
+
const fs_1 = require("fs");
|
|
21
|
+
const minimatch_1 = require("minimatch");
|
|
22
|
+
const file_uri_1 = require("@theia/core/lib/common/file-uri");
|
|
23
|
+
const file_change_collection_1 = require("../file-change-collection");
|
|
24
|
+
const promise_util_1 = require("@theia/core/lib/common/promise-util");
|
|
25
|
+
const watcher_1 = require("@theia/core/shared/@parcel/watcher");
|
|
26
|
+
const core_1 = require("@theia/core");
|
|
27
|
+
const filesystem_watcher_1 = require("../filesystem-watcher");
|
|
28
|
+
exports.ParcelFileSystemWatcherServerOptions = Symbol('ParcelFileSystemWatcherServerOptions');
|
|
29
|
+
/**
|
|
30
|
+
* This is a flag value passed around upon disposal.
|
|
31
|
+
*/
|
|
32
|
+
exports.WatcherDisposal = Symbol('WatcherDisposal');
|
|
33
|
+
/**
|
|
34
|
+
* Because URIs can be watched by different clients, we'll track
|
|
35
|
+
* how many are listening for a given URI.
|
|
36
|
+
*
|
|
37
|
+
* This component wraps the whole start/stop process given some
|
|
38
|
+
* reference count.
|
|
39
|
+
*
|
|
40
|
+
* Once there are no more references the handle
|
|
41
|
+
* will wait for some time before destroying its resources.
|
|
42
|
+
*/
|
|
43
|
+
class ParcelWatcher extends filesystem_watcher_1.AbstractFileSystemWatcher {
|
|
44
|
+
// copied from https://github.com/microsoft/vscode/blob/e3a5acfb517a443235981655413d566533107e92/src/vs/platform/files/node/watcher/parcel/parcelWatcher.ts#L158
|
|
45
|
+
static { this.PARCEL_WATCHER_BACKEND = core_1.isWindows ? 'windows' : core_1.isOSX ? 'fs-events' : 'inotify'; }
|
|
46
|
+
constructor(
|
|
47
|
+
/**
|
|
48
|
+
* Initial reference to this handle.
|
|
49
|
+
* @deprecated since 1.77.0 - pass `undefined` and use {@link addRequest}; references follow requests.
|
|
50
|
+
*/
|
|
51
|
+
initialClientId,
|
|
52
|
+
/** Filesystem path to be watched. */
|
|
53
|
+
fsPath,
|
|
54
|
+
/** Watcher-specific options */
|
|
55
|
+
watcherOptions,
|
|
56
|
+
/** Logging and parcel watcher options */
|
|
57
|
+
parcelFileSystemWatchServerOptions,
|
|
58
|
+
/** The client to forward events to. */
|
|
59
|
+
fileSystemWatcherClient,
|
|
60
|
+
/** Amount of time in ms to wait once this handle is not referenced anymore. */
|
|
61
|
+
deferredDisposalTimeout = 10_000) {
|
|
62
|
+
super(fsPath, parcelFileSystemWatchServerOptions);
|
|
63
|
+
this.fsPath = fsPath;
|
|
64
|
+
this.watcherOptions = watcherOptions;
|
|
65
|
+
this.parcelFileSystemWatchServerOptions = parcelFileSystemWatchServerOptions;
|
|
66
|
+
this.fileSystemWatcherClient = fileSystemWatcherClient;
|
|
67
|
+
this.deferredDisposalTimeout = deferredDisposalTimeout;
|
|
68
|
+
/**
|
|
69
|
+
* We count each reference made to this watcher, per client.
|
|
70
|
+
*
|
|
71
|
+
* We do this to know where to send events via the network.
|
|
72
|
+
*
|
|
73
|
+
* An entry should be removed when its value hits zero.
|
|
74
|
+
*/
|
|
75
|
+
this.refsPerClient = new Map();
|
|
76
|
+
/** Requests served by this watcher, so that releasing one drops the reference of the right client. */
|
|
77
|
+
this.requests = new Map();
|
|
78
|
+
/**
|
|
79
|
+
* Ensures that events are processed in the order they are emitted,
|
|
80
|
+
* despite being processed async.
|
|
81
|
+
*/
|
|
82
|
+
this.parcelEventProcessingQueue = Promise.resolve();
|
|
83
|
+
if (initialClientId !== undefined) {
|
|
84
|
+
this.refsPerClient.set(initialClientId, { value: 1 });
|
|
85
|
+
}
|
|
86
|
+
this.whenStarted = this.start().then(() => true, error => {
|
|
87
|
+
if (error === exports.WatcherDisposal) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
console.error(`Watcher failed to start at "${this.fsPath}":`, error);
|
|
91
|
+
this._dispose();
|
|
92
|
+
this.fireError();
|
|
93
|
+
throw error;
|
|
94
|
+
});
|
|
95
|
+
this.debug('NEW', `initialClientId=${initialClientId}`);
|
|
96
|
+
}
|
|
97
|
+
addRequest(watcherId, request) {
|
|
98
|
+
this.requests.set(watcherId, request);
|
|
99
|
+
this.addRef(request.clientId);
|
|
100
|
+
}
|
|
101
|
+
removeRequest(watcherId) {
|
|
102
|
+
const request = this.requests.get(watcherId);
|
|
103
|
+
if (request) {
|
|
104
|
+
this.requests.delete(watcherId);
|
|
105
|
+
this.removeRef(request.clientId);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
addRef(clientId) {
|
|
109
|
+
let refs = this.refsPerClient.get(clientId);
|
|
110
|
+
if (typeof refs === 'undefined') {
|
|
111
|
+
this.refsPerClient.set(clientId, refs = { value: 1 });
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
refs.value += 1;
|
|
115
|
+
}
|
|
116
|
+
const totalRefs = this.getTotalReferences();
|
|
117
|
+
// If it was zero before, 1 means we were revived:
|
|
118
|
+
const revived = totalRefs === 1;
|
|
119
|
+
if (revived) {
|
|
120
|
+
this.onRefsRevive();
|
|
121
|
+
}
|
|
122
|
+
this.debug('REF++', `clientId=${clientId}, clientRefs=${refs.value}, totalRefs=${totalRefs}. revived=${revived}`);
|
|
123
|
+
}
|
|
124
|
+
removeRef(clientId) {
|
|
125
|
+
const refs = this.refsPerClient.get(clientId);
|
|
126
|
+
if (typeof refs === 'undefined') {
|
|
127
|
+
this.info('WARN REF--', `removed one too many reference: clientId=${clientId}`);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
refs.value -= 1;
|
|
131
|
+
// We must remove the key from `this.clientReferences` because
|
|
132
|
+
// we list active clients by reading the keys of this map.
|
|
133
|
+
if (refs.value === 0) {
|
|
134
|
+
this.refsPerClient.delete(clientId);
|
|
135
|
+
}
|
|
136
|
+
const totalRefs = this.getTotalReferences();
|
|
137
|
+
const dead = totalRefs === 0;
|
|
138
|
+
if (dead) {
|
|
139
|
+
this.onRefsReachZero();
|
|
140
|
+
}
|
|
141
|
+
this.debug('REF--', `clientId=${clientId}, clientRefs=${refs.value}, totalRefs=${totalRefs}, dead=${dead}`);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* All clients with at least one active reference.
|
|
145
|
+
*/
|
|
146
|
+
getClientIds() {
|
|
147
|
+
return Array.from(this.refsPerClient.keys());
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Add the references for each client together.
|
|
151
|
+
*/
|
|
152
|
+
getTotalReferences() {
|
|
153
|
+
let total = 0;
|
|
154
|
+
for (const refs of this.refsPerClient.values()) {
|
|
155
|
+
total += refs.value;
|
|
156
|
+
}
|
|
157
|
+
return total;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Returns true if at least one client listens to this handle.
|
|
161
|
+
*/
|
|
162
|
+
isInUse() {
|
|
163
|
+
return this.refsPerClient.size > 0;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* @throws with {@link WatcherDisposal} if this instance is disposed.
|
|
167
|
+
*/
|
|
168
|
+
assertNotDisposed() {
|
|
169
|
+
if (this.isDisposed) {
|
|
170
|
+
throw exports.WatcherDisposal;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* When starting a watcher, we'll first check and wait for the path to exists
|
|
175
|
+
* before running a parcel watcher.
|
|
176
|
+
*/
|
|
177
|
+
async start() {
|
|
178
|
+
while (await fs_1.promises.stat(this.fsPath).then(() => false, () => true)) {
|
|
179
|
+
await (0, promise_util_1.timeout)(500);
|
|
180
|
+
this.assertNotDisposed();
|
|
181
|
+
}
|
|
182
|
+
this.assertNotDisposed();
|
|
183
|
+
// This race is specific to Linux/inotify: parcel-watcher's inotify backend walks
|
|
184
|
+
// the tree and then calls inotify_add_watch on every subdirectory. If a subdirectory
|
|
185
|
+
// disappears between the walk and the add (common when watching dirs that contain
|
|
186
|
+
// auto-rotated log/temp folders), the syscall returns ENOENT and parcel-watcher fails
|
|
187
|
+
// the entire subscribe. Retry a few times: by the next walk the gone-but-not-forgotten
|
|
188
|
+
// dir is no longer present. Windows (ReadDirectoryChangesW) and macOS (FSEvents) watch
|
|
189
|
+
// the whole subtree from a single handle on the root and never register per-subdirectory
|
|
190
|
+
// watches, so they cannot hit this race; the retry is simply a no-op there.
|
|
191
|
+
let watcher;
|
|
192
|
+
let attempt = 0;
|
|
193
|
+
while (true) {
|
|
194
|
+
try {
|
|
195
|
+
watcher = await this.createWatcher();
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
const message = (error && error.message) || '';
|
|
200
|
+
const isTransientEnoent = message.includes('No such file or directory')
|
|
201
|
+
&& await fs_1.promises.stat(this.fsPath).then(() => true, () => false);
|
|
202
|
+
if (!isTransientEnoent || attempt >= 4) {
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
attempt++;
|
|
206
|
+
this.assertNotDisposed();
|
|
207
|
+
await (0, promise_util_1.timeout)(100 * attempt);
|
|
208
|
+
this.assertNotDisposed();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
this.assertNotDisposed();
|
|
212
|
+
this.debug('STARTED', `disposed=${this.isDisposed}`);
|
|
213
|
+
// The watcher could be disposed while it was starting, make sure to check for this:
|
|
214
|
+
if (this.isDisposed) {
|
|
215
|
+
await this.stopWatcher(watcher);
|
|
216
|
+
throw exports.WatcherDisposal;
|
|
217
|
+
}
|
|
218
|
+
this.watcher = watcher;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Given a started parcel watcher instance, gracefully shut it down.
|
|
222
|
+
*/
|
|
223
|
+
async stopWatcher(watcher) {
|
|
224
|
+
await watcher.unsubscribe()
|
|
225
|
+
.then(() => 'success=true', error => error)
|
|
226
|
+
.then(status => this.debug('STOPPED', status));
|
|
227
|
+
}
|
|
228
|
+
async createWatcher() {
|
|
229
|
+
let fsPath = await fs_1.promises.realpath(this.fsPath);
|
|
230
|
+
if ((await fs_1.promises.stat(fsPath)).isFile()) {
|
|
231
|
+
fsPath = path.dirname(fsPath);
|
|
232
|
+
}
|
|
233
|
+
return (0, watcher_1.subscribe)(fsPath, (err, events) => {
|
|
234
|
+
if (err) {
|
|
235
|
+
if (err.message && err.message.includes('File system must be re-scanned')) {
|
|
236
|
+
console.log(`FS Events were dropped on watcher ${fsPath}`);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
console.error(`Watcher service error on "${fsPath}":`, err);
|
|
240
|
+
this._dispose();
|
|
241
|
+
this.fireError();
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (events) {
|
|
246
|
+
this.handleWatcherEvents(events);
|
|
247
|
+
}
|
|
248
|
+
}, {
|
|
249
|
+
backend: ParcelWatcher.PARCEL_WATCHER_BACKEND,
|
|
250
|
+
...this.parcelFileSystemWatchServerOptions.parcelOptions,
|
|
251
|
+
// Pass the excludes to parcel's native `ignore` so excluded directories are pruned
|
|
252
|
+
// from the watch tree (no OS watch is placed), not merely filtered out of the event
|
|
253
|
+
// stream. Mirrors VS Code's parcel watcher (`ignore: <request excludes>`).
|
|
254
|
+
ignore: [
|
|
255
|
+
...(this.parcelFileSystemWatchServerOptions.parcelOptions.ignore ?? []),
|
|
256
|
+
...this.watcherOptions.ignorePatterns
|
|
257
|
+
]
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
handleWatcherEvents(events) {
|
|
261
|
+
// Only process events if someone is listening.
|
|
262
|
+
if (this.isInUse()) {
|
|
263
|
+
// This callback is async, but parcel won't wait for it to finish before firing the next one.
|
|
264
|
+
// We will use a lock/queue to make sure everything is processed in the order it arrives.
|
|
265
|
+
this.parcelEventProcessingQueue = this.parcelEventProcessingQueue.then(async () => {
|
|
266
|
+
const fileChangeCollection = new file_change_collection_1.FileChangeCollection();
|
|
267
|
+
for (const event of events) {
|
|
268
|
+
const filePath = event.path;
|
|
269
|
+
if (event.type === 'create') {
|
|
270
|
+
this.pushFileChange(fileChangeCollection, 1 /* FileChangeType.ADDED */, filePath);
|
|
271
|
+
}
|
|
272
|
+
else if (event.type === 'delete') {
|
|
273
|
+
this.pushFileChange(fileChangeCollection, 2 /* FileChangeType.DELETED */, filePath);
|
|
274
|
+
}
|
|
275
|
+
else if (event.type === 'update') {
|
|
276
|
+
this.pushFileChange(fileChangeCollection, 0 /* FileChangeType.UPDATED */, filePath);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
const changes = fileChangeCollection.values();
|
|
280
|
+
// If all changes are part of the ignored files, the collection will be empty.
|
|
281
|
+
if (changes.length > 0) {
|
|
282
|
+
this.fileSystemWatcherClient.onDidFilesChanged({
|
|
283
|
+
clients: this.getClientIds(),
|
|
284
|
+
changes,
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
}, console.error);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
async resolveEventPath(directory, file) {
|
|
291
|
+
// parcel already resolves symlinks, the paths should be clean already:
|
|
292
|
+
return path.resolve(directory, file);
|
|
293
|
+
}
|
|
294
|
+
pushFileChange(changes, type, filePath) {
|
|
295
|
+
if (!this.isIgnored(filePath)) {
|
|
296
|
+
const uri = file_uri_1.FileUri.create(filePath).toString();
|
|
297
|
+
changes.push({ type, uri });
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
fireError() {
|
|
301
|
+
this.fileSystemWatcherClient.onError({
|
|
302
|
+
clients: this.getClientIds(),
|
|
303
|
+
uri: this.fsPath,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* When references hit zero, we'll schedule disposal for a bit later.
|
|
308
|
+
*
|
|
309
|
+
* This allows new references to reuse this watcher instead of creating a new one.
|
|
310
|
+
*
|
|
311
|
+
* e.g. A frontend disconnects for a few milliseconds before reconnecting again.
|
|
312
|
+
*/
|
|
313
|
+
onRefsReachZero() {
|
|
314
|
+
this.deferredDisposalTimer = setTimeout(() => this._dispose(), this.deferredDisposalTimeout);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* If we get new references after hitting zero, let's unschedule our disposal and keep watching.
|
|
318
|
+
*/
|
|
319
|
+
onRefsRevive() {
|
|
320
|
+
if (this.deferredDisposalTimer) {
|
|
321
|
+
clearTimeout(this.deferredDisposalTimer);
|
|
322
|
+
this.deferredDisposalTimer = undefined;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
isIgnored(filePath) {
|
|
326
|
+
return this.watcherOptions.ignored.length > 0
|
|
327
|
+
&& this.watcherOptions.ignored.some(m => m.match(filePath));
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Internal disposal mechanism.
|
|
331
|
+
*/
|
|
332
|
+
async _dispose() {
|
|
333
|
+
if (this.markDisposed()) {
|
|
334
|
+
if (this.watcher) {
|
|
335
|
+
this.stopWatcher(this.watcher);
|
|
336
|
+
this.watcher = undefined;
|
|
337
|
+
}
|
|
338
|
+
this.debug('DISPOSED');
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
exports.ParcelWatcher = ParcelWatcher;
|
|
343
|
+
/** Serves recursive requests with `@parcel/watcher`, one subscription per path and exclude set. */
|
|
344
|
+
class RecursiveWatcherProvider extends filesystem_watcher_1.AbstractWatcherProvider {
|
|
345
|
+
constructor(options, client, deferredDisposalTimeout) {
|
|
346
|
+
super();
|
|
347
|
+
this.options = options;
|
|
348
|
+
this.client = client;
|
|
349
|
+
this.deferredDisposalTimeout = deferredDisposalTimeout;
|
|
350
|
+
}
|
|
351
|
+
canHandle(options) {
|
|
352
|
+
return options.recursive;
|
|
353
|
+
}
|
|
354
|
+
async watch(watcherId, request) {
|
|
355
|
+
this.serve(watcherId, this.getOrCreateWatcher(this.watcherKey(request), () => this.createWatcher(request)), request);
|
|
356
|
+
}
|
|
357
|
+
/** Excludes are part of the key: parcel prunes them from the crawl, so a different set is a different watch. */
|
|
358
|
+
watcherKey(request) {
|
|
359
|
+
return [request.path, [...request.ignored].sort().join()].join();
|
|
360
|
+
}
|
|
361
|
+
createWatcher(request) {
|
|
362
|
+
const watcherOptions = {
|
|
363
|
+
ignored: request.ignored.map(pattern => new minimatch_1.Minimatch(pattern, { dot: true })),
|
|
364
|
+
ignorePatterns: [...request.ignored]
|
|
365
|
+
};
|
|
366
|
+
return new ParcelWatcher(undefined, request.path, watcherOptions, this.options, this.client, this.deferredDisposalTimeout);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
exports.RecursiveWatcherProvider = RecursiveWatcherProvider;
|
|
370
|
+
//# sourceMappingURL=parcel-watcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parcel-watcher.js","sourceRoot":"","sources":["../../../src/node/parcel-watcher/parcel-watcher.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,8CAA8C;AAC9C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEhF,6BAA8B;AAC9B,2BAAqC;AACrC,yCAAsC;AACtC,8DAA0D;AAE1D,sEAAiE;AACjE,sEAA8D;AAC9D,gEAAkG;AAClG,sCAA+C;AAC/C,8DAA8I;AAoBjI,QAAA,oCAAoC,GAAG,MAAM,CAAC,sCAAsC,CAAC,CAAC;AAKnG;;GAEG;AACU,QAAA,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAEzD;;;;;;;;;GASG;AACH,MAAa,aAAc,SAAQ,8CAAyB;IAuCxD,gKAAgK;aACxI,2BAAsB,GAAG,gBAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,AAA1D,CAA2D;IAEzG;IACI;;;OAGG;IACH,eAAmC;IACnC,qCAAqC;IAC5B,MAAc;IACvB,+BAA+B;IACtB,cAAqC;IAC9C,yCAAyC;IACtB,kCAA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C;IACzH,CAAC;IAED,gHAAgH;IACtG,UAAU,CAAC,OAAqB;QACtC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACrE,CAAC;IAES,aAAa,CAAC,OAAqB;QACzC,MAAM,cAAc,GAA0B;YAC1C,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,qBAAS,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9E,cAAc,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;SACvC,CAAC;QACF,OAAO,IAAI,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;IAC/H,CAAC;CACJ;AA9BD,4DA8BC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NodeDirectoryWatcherTimings } from '../nodejs-watcher/node-directory-watcher';
|
|
2
|
+
/** Scaled down so the suite stays quick; only the order of the delays matters. */
|
|
3
|
+
export declare const WATCHER_TIMINGS: NodeDirectoryWatcherTimings;
|
|
4
|
+
export declare const NO_LOGGING: {
|
|
5
|
+
verbose: boolean;
|
|
6
|
+
info: () => void;
|
|
7
|
+
error: () => void;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* A directory to act on, one per test, so that no test depends on what another one left behind. The root is
|
|
11
|
+
* passed in because `temp` is a root-level dev dependency, and this file is published.
|
|
12
|
+
*/
|
|
13
|
+
export declare class TempDir {
|
|
14
|
+
readonly root: string;
|
|
15
|
+
constructor(root: string);
|
|
16
|
+
path(...segments: string[]): string;
|
|
17
|
+
write(...segments: string[]): string;
|
|
18
|
+
mkdir(...segments: string[]): string;
|
|
19
|
+
remove(...segments: string[]): void;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=watcher-test-helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watcher-test-helper.d.ts","sourceRoot":"","sources":["../../../src/node/test/watcher-test-helper.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AAEvF,kFAAkF;AAClF,eAAO,MAAM,eAAe,EAAE,2BAK7B,CAAC;AAEF,eAAO,MAAM,UAAU;;;;CAAwD,CAAC;AAEhF;;;GAGG;AACH,qBAAa,OAAO;IAEJ,QAAQ,CAAC,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM;IAEjC,IAAI,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM;IAInC,KAAK,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM;IAMpC,KAAK,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM;IAMpC,MAAM,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI;CAGtC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 Ehab Younes and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.TempDir = exports.NO_LOGGING = exports.WATCHER_TIMINGS = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const path = tslib_1.__importStar(require("path"));
|
|
21
|
+
const fs = tslib_1.__importStar(require("@theia/core/shared/fs-extra"));
|
|
22
|
+
/** Scaled down so the suite stays quick; only the order of the delays matters. */
|
|
23
|
+
exports.WATCHER_TIMINGS = {
|
|
24
|
+
changeDelay: 5,
|
|
25
|
+
deleteDelay: 20,
|
|
26
|
+
existencePollDelay: 20,
|
|
27
|
+
deferredDisposalTimeout: 30
|
|
28
|
+
};
|
|
29
|
+
exports.NO_LOGGING = { verbose: false, info: () => { }, error: () => { } };
|
|
30
|
+
/**
|
|
31
|
+
* A directory to act on, one per test, so that no test depends on what another one left behind. The root is
|
|
32
|
+
* passed in because `temp` is a root-level dev dependency, and this file is published.
|
|
33
|
+
*/
|
|
34
|
+
class TempDir {
|
|
35
|
+
constructor(root) {
|
|
36
|
+
this.root = root;
|
|
37
|
+
}
|
|
38
|
+
path(...segments) {
|
|
39
|
+
return path.resolve(this.root, ...segments);
|
|
40
|
+
}
|
|
41
|
+
write(...segments) {
|
|
42
|
+
const target = this.path(...segments);
|
|
43
|
+
fs.writeFileSync(target, 'content');
|
|
44
|
+
return target;
|
|
45
|
+
}
|
|
46
|
+
mkdir(...segments) {
|
|
47
|
+
const target = this.path(...segments);
|
|
48
|
+
fs.mkdirSync(target, { recursive: true });
|
|
49
|
+
return target;
|
|
50
|
+
}
|
|
51
|
+
remove(...segments) {
|
|
52
|
+
fs.removeSync(this.path(...segments));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.TempDir = TempDir;
|
|
56
|
+
//# sourceMappingURL=watcher-test-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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QAC1C,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,GAAG,QAAkB;QACxB,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IAC1C,CAAC;CACJ;AAvBD,0BAuBC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/filesystem",
|
|
3
|
-
"version": "1.77.0-next.
|
|
3
|
+
"version": "1.77.0-next.63+046af0812",
|
|
4
4
|
"description": "Theia - FileSystem Extension",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.77.0-next.
|
|
6
|
+
"@theia/core": "1.77.0-next.63+046af0812",
|
|
7
7
|
"@types/body-parser": "^1.19.6",
|
|
8
8
|
"@types/multer": "^1.4.13",
|
|
9
9
|
"@types/tar-fs": "^1.16.3",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"nyc": {
|
|
83
83
|
"extends": "../../configs/nyc.json"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "046af0812516f46f2bf7ce3357cca0b672159b20"
|
|
86
86
|
}
|
|
@@ -89,6 +89,10 @@ export interface FileSystemWatcherClient {
|
|
|
89
89
|
|
|
90
90
|
export interface WatchOptions {
|
|
91
91
|
ignored: string[];
|
|
92
|
+
/**
|
|
93
|
+
* Watch the whole subtree under the given path. Defaults to `true`.
|
|
94
|
+
*/
|
|
95
|
+
recursive?: boolean;
|
|
92
96
|
}
|
|
93
97
|
export interface FileChange {
|
|
94
98
|
uri: string;
|
|
@@ -835,7 +835,8 @@ export class DiskFileSystemProvider implements Disposable,
|
|
|
835
835
|
};
|
|
836
836
|
watcherService.watchFileChanges(resource.toString(), {
|
|
837
837
|
// Convert from `files.WatchOptions` to internal `watcher-protocol.WatchOptions`:
|
|
838
|
-
ignored: opts.excludes
|
|
838
|
+
ignored: opts.excludes,
|
|
839
|
+
recursive: opts.recursive
|
|
839
840
|
}).then(watcherId => {
|
|
840
841
|
if (handle.disposed) {
|
|
841
842
|
watcherService.unwatchFileChanges(watcherId);
|
|
@@ -19,7 +19,8 @@ import { ContainerModule, interfaces } from '@theia/core/shared/inversify';
|
|
|
19
19
|
import { ConnectionHandler, RpcConnectionHandler, ILogger } from '@theia/core/lib/common';
|
|
20
20
|
import { FileSystemWatcherServer, FileSystemWatcherService } from '../common/filesystem-watcher-protocol';
|
|
21
21
|
import { FileSystemWatcherServerClient } from './filesystem-watcher-client';
|
|
22
|
-
import {
|
|
22
|
+
import { FileSystemWatcherServiceImpl } from './filesystem-watcher-service-impl';
|
|
23
|
+
import { ParcelFileSystemWatcherServerOptions } from './parcel-watcher/parcel-watcher';
|
|
23
24
|
import { NodeFileUploadService } from './upload/node-file-upload-service';
|
|
24
25
|
import { ParcelWatcherOptions } from './parcel-watcher/parcel-options';
|
|
25
26
|
import { DiskFileSystemProvider } from './disk-file-system-provider';
|
|
@@ -38,11 +39,11 @@ export const WATCHER_VERBOSE = process.argv.includes('--watcher-verbose');
|
|
|
38
39
|
|
|
39
40
|
export const FileSystemWatcherServiceProcessOptions = Symbol('FileSystemWatcherServiceProcessOptions');
|
|
40
41
|
/**
|
|
41
|
-
* Options to control the way the `
|
|
42
|
+
* Options to control the way the `FileSystemWatcherServiceImpl` process is spawned.
|
|
42
43
|
*/
|
|
43
44
|
export interface FileSystemWatcherServiceProcessOptions {
|
|
44
45
|
/**
|
|
45
|
-
* Path to the script that will run the `
|
|
46
|
+
* Path to the script that will run the `FileSystemWatcherServiceImpl` in a new process.
|
|
46
47
|
*/
|
|
47
48
|
entryPoint: string;
|
|
48
49
|
}
|
|
@@ -102,7 +103,7 @@ export function bindFileSystemWatcherServer(bind: interfaces.Bind): void {
|
|
|
102
103
|
export function createParcelFileSystemWatcherService(ctx: interfaces.Context): FileSystemWatcherService {
|
|
103
104
|
const options = ctx.container.get<ParcelFileSystemWatcherServerOptions>(ParcelFileSystemWatcherServerOptions);
|
|
104
105
|
const dispatcher = ctx.container.get<FileSystemWatcherServiceDispatcher>(FileSystemWatcherServiceDispatcher);
|
|
105
|
-
const server = new
|
|
106
|
+
const server = new FileSystemWatcherServiceImpl(options);
|
|
106
107
|
server.setClient(dispatcher);
|
|
107
108
|
return server;
|
|
108
109
|
}
|