@expo/metro-file-map 57.0.2 → 57.0.4
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/build/Watcher.js +8 -7
- package/build/types.d.ts +10 -3
- package/build/watchers/AbstractWatcher.d.ts +2 -3
- package/build/watchers/AbstractWatcher.js +3 -5
- package/build/watchers/FallbackWatcher.js +42 -15
- package/build/watchers/NativeWatcher.js +1 -1
- package/build/watchers/WatchmanWatcher.js +1 -13
- package/build/watchers/common.d.ts +9 -5
- package/build/watchers/common.js +22 -9
- package/package.json +2 -4
package/build/Watcher.js
CHANGED
|
@@ -146,15 +146,16 @@ class Watcher extends events_1.default {
|
|
|
146
146
|
this.#activeWatcher = watcher;
|
|
147
147
|
const createWatcherBackend = (root) => {
|
|
148
148
|
const watcherOptions = {
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
included: {
|
|
150
|
+
extensions: new Set(extensions),
|
|
151
151
|
// Ensure we always include package.json files, which are crucial for
|
|
152
|
-
|
|
153
|
-
'
|
|
152
|
+
// module resolution.
|
|
153
|
+
basenames: new Set(['package.json']),
|
|
154
154
|
// Ensure we always watch any health check files
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
basenamePrefixes: this.#options.healthCheckFilePrefix != null
|
|
156
|
+
? [this.#options.healthCheckFilePrefix]
|
|
157
|
+
: [],
|
|
158
|
+
},
|
|
158
159
|
ignored: ignorePatternForWatch,
|
|
159
160
|
watchmanDeferStates: this.#options.watchmanDeferStates,
|
|
160
161
|
};
|
package/build/types.d.ts
CHANGED
|
@@ -270,7 +270,6 @@ export interface FileSystem {
|
|
|
270
270
|
rootDir?: Path | null | undefined;
|
|
271
271
|
}): Iterable<Path>;
|
|
272
272
|
}
|
|
273
|
-
export type Glob = string;
|
|
274
273
|
export type JsonData = string | number | boolean | null | JsonData[] | {
|
|
275
274
|
[key: string]: JsonData;
|
|
276
275
|
};
|
|
@@ -379,8 +378,16 @@ export type WatcherBackendChangeEvent = {
|
|
|
379
378
|
};
|
|
380
379
|
export interface WatcherBackendOptions {
|
|
381
380
|
readonly ignored: RegExp | undefined | null;
|
|
382
|
-
readonly
|
|
383
|
-
|
|
381
|
+
readonly included: WatcherIncludedFiles | null | undefined;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Regular files a watcher reports changes to: those matching any of the
|
|
385
|
+
* extensions (without a leading dot), basenames, or basename prefixes.
|
|
386
|
+
*/
|
|
387
|
+
export interface WatcherIncludedFiles {
|
|
388
|
+
readonly extensions: ReadonlySet<string>;
|
|
389
|
+
readonly basenames: ReadonlySet<string>;
|
|
390
|
+
readonly basenamePrefixes: readonly string[];
|
|
384
391
|
}
|
|
385
392
|
export type WatchmanClockSpec = string | {
|
|
386
393
|
readonly scm: {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import type { WatcherBackend, WatcherBackendChangeEvent, WatcherBackendOptions } from '../types';
|
|
7
|
+
import type { WatcherBackend, WatcherBackendChangeEvent, WatcherBackendOptions, WatcherIncludedFiles } from '../types';
|
|
8
8
|
type EachOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
|
|
9
9
|
export type WatcherBackendChangeEventWithoutRoot = EachOmit<WatcherBackendChangeEvent, 'root'>;
|
|
10
10
|
export interface Listeners {
|
|
@@ -15,8 +15,7 @@ export declare class AbstractWatcher implements WatcherBackend {
|
|
|
15
15
|
#private;
|
|
16
16
|
readonly root: string;
|
|
17
17
|
readonly ignored: RegExp | undefined | null;
|
|
18
|
-
readonly
|
|
19
|
-
readonly dot: boolean;
|
|
18
|
+
readonly included: WatcherIncludedFiles | null | undefined;
|
|
20
19
|
readonly doIgnore: (path: string) => boolean;
|
|
21
20
|
constructor(dir: string, opts: WatcherBackendOptions);
|
|
22
21
|
onFileEvent(listener: (event: WatcherBackendChangeEvent) => void): () => void;
|
|
@@ -50,15 +50,13 @@ const common_1 = require("./common");
|
|
|
50
50
|
class AbstractWatcher {
|
|
51
51
|
root;
|
|
52
52
|
ignored;
|
|
53
|
-
|
|
54
|
-
dot;
|
|
53
|
+
included;
|
|
55
54
|
doIgnore;
|
|
56
55
|
#emitter = new events_1.default();
|
|
57
56
|
constructor(dir, opts) {
|
|
58
|
-
const { ignored,
|
|
59
|
-
this.dot = dot || false;
|
|
57
|
+
const { ignored, included } = opts;
|
|
60
58
|
this.ignored = ignored;
|
|
61
|
-
this.
|
|
59
|
+
this.included = included;
|
|
62
60
|
this.doIgnore = ignored
|
|
63
61
|
? (filePath) => (0, isWatcherExcluded_1.default)(filePath) || (0, common_1.posixPathMatchesPattern)(ignored, filePath)
|
|
64
62
|
: isWatcherExcluded_1.default;
|
|
@@ -101,7 +101,7 @@ class FallbackWatcher extends AbstractWatcher_1.AbstractWatcher {
|
|
|
101
101
|
}
|
|
102
102
|
const relativePath = path_1.default.relative(this.root, filepath);
|
|
103
103
|
if (this.doIgnore(relativePath) ||
|
|
104
|
-
(type === 'f' && !common.
|
|
104
|
+
(type === 'f' && !common.isIncluded('f', this.included, relativePath))) {
|
|
105
105
|
return false;
|
|
106
106
|
}
|
|
107
107
|
if (!this.#dirRegistry[dir]) {
|
|
@@ -161,9 +161,24 @@ class FallbackWatcher extends AbstractWatcher_1.AbstractWatcher {
|
|
|
161
161
|
if (this.#watched[dir]) {
|
|
162
162
|
return false;
|
|
163
163
|
}
|
|
164
|
-
|
|
164
|
+
let watcher;
|
|
165
|
+
try {
|
|
166
|
+
watcher = fs_1.default.watch(dir, { persistent: true }, (event, filename) => this.#normalizeChange(dir, event, filename));
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
// Directory can vanish before watch; filterDir must not throw.
|
|
170
|
+
this.#checkedEmitError(error);
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
165
173
|
this.#watched[dir] = watcher;
|
|
166
|
-
watcher.on('error',
|
|
174
|
+
watcher.on('error', (error) => {
|
|
175
|
+
// Node emits no `close` after `error`.
|
|
176
|
+
if (this.#watched[dir] === watcher) {
|
|
177
|
+
delete this.#watched[dir];
|
|
178
|
+
}
|
|
179
|
+
watcher.close();
|
|
180
|
+
this.#checkedEmitError(error);
|
|
181
|
+
});
|
|
167
182
|
if (this.root !== dir) {
|
|
168
183
|
this.#register(dir, 'd');
|
|
169
184
|
}
|
|
@@ -174,13 +189,15 @@ class FallbackWatcher extends AbstractWatcher_1.AbstractWatcher {
|
|
|
174
189
|
*/
|
|
175
190
|
async #stopWatching(dir) {
|
|
176
191
|
const watcher = this.#watched[dir];
|
|
177
|
-
if (watcher) {
|
|
178
|
-
|
|
179
|
-
watcher.once('close', () => process.nextTick(resolve));
|
|
180
|
-
watcher.close();
|
|
181
|
-
delete this.#watched[dir];
|
|
182
|
-
});
|
|
192
|
+
if (!watcher) {
|
|
193
|
+
return;
|
|
183
194
|
}
|
|
195
|
+
delete this.#watched[dir];
|
|
196
|
+
await new Promise((resolve) => {
|
|
197
|
+
watcher.once('close', () => process.nextTick(resolve));
|
|
198
|
+
watcher.once('error', () => process.nextTick(resolve));
|
|
199
|
+
watcher.close();
|
|
200
|
+
});
|
|
184
201
|
}
|
|
185
202
|
/**
|
|
186
203
|
* End watching.
|
|
@@ -232,6 +249,13 @@ class FallbackWatcher extends AbstractWatcher_1.AbstractWatcher {
|
|
|
232
249
|
*/
|
|
233
250
|
#normalizeChange(dir, event, file) {
|
|
234
251
|
if (!file) {
|
|
252
|
+
if (!this.#dirRegistry[dir]) {
|
|
253
|
+
// Windows may omit filename; list the new directory.
|
|
254
|
+
this.#processChange(dir, event === 'change' ? 'rename' : event, '').catch((error) => {
|
|
255
|
+
this.emitError(error);
|
|
256
|
+
});
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
235
259
|
this.#detectChangedFile(dir, event, (actualFile) => {
|
|
236
260
|
if (actualFile) {
|
|
237
261
|
this.#processChange(dir, event, actualFile).catch((error) => {
|
|
@@ -260,8 +284,7 @@ class FallbackWatcher extends AbstractWatcher_1.AbstractWatcher {
|
|
|
260
284
|
if (event === 'change') {
|
|
261
285
|
return;
|
|
262
286
|
}
|
|
263
|
-
if (this.doIgnore(relativePath) ||
|
|
264
|
-
!common.includedByGlob('d', this.globs, this.dot, relativePath)) {
|
|
287
|
+
if (this.doIgnore(relativePath) || !common.isIncluded('d', this.included, relativePath)) {
|
|
265
288
|
return;
|
|
266
289
|
}
|
|
267
290
|
recReaddir(path_1.default.resolve(this.root, relativePath), (dir, stats) => {
|
|
@@ -385,11 +408,15 @@ function isIgnorableFileError(error) {
|
|
|
385
408
|
*/
|
|
386
409
|
function recReaddir(dir, dirCallback, fileCallback, symlinkCallback, endCallback, errorCallback, ignored) {
|
|
387
410
|
const walk = walker(dir);
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
411
|
+
// Watch before readdir so a file written in between is not missed.
|
|
412
|
+
walk.filterDir((currentDir, stats) => {
|
|
413
|
+
if (ignored && common.posixPathMatchesPattern(ignored, currentDir)) {
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
normalizeProxy(dirCallback)(currentDir, stats);
|
|
417
|
+
return true;
|
|
418
|
+
});
|
|
391
419
|
walk
|
|
392
|
-
.on('dir', normalizeProxy(dirCallback))
|
|
393
420
|
.on('file', normalizeProxy(fileCallback))
|
|
394
421
|
.on('symlink', normalizeProxy(symlinkCallback))
|
|
395
422
|
.on('error', errorCallback)
|
|
@@ -118,7 +118,7 @@ class NativeWatcher extends AbstractWatcher_1.AbstractWatcher {
|
|
|
118
118
|
if (!type) {
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
|
-
if (!(0, common_1.
|
|
121
|
+
if (!(0, common_1.isIncluded)(type, this.included, relativePath)) {
|
|
122
122
|
return;
|
|
123
123
|
}
|
|
124
124
|
// For directory "rename" events, notify that we need a recrawl since we
|
|
@@ -128,17 +128,6 @@ class WatchmanWatcher extends AbstractWatcher_1.AbstractWatcher {
|
|
|
128
128
|
defer: self.#watchmanDeferStates,
|
|
129
129
|
relative_root: watchProjectInfo.relativePath,
|
|
130
130
|
};
|
|
131
|
-
// Make sure we honor the dot option if even we're not using globs.
|
|
132
|
-
if (self.globs.length === 0 && !self.dot) {
|
|
133
|
-
options.expression = [
|
|
134
|
-
'match',
|
|
135
|
-
'**',
|
|
136
|
-
'wholename',
|
|
137
|
-
{
|
|
138
|
-
includedotfiles: false,
|
|
139
|
-
},
|
|
140
|
-
];
|
|
141
|
-
}
|
|
142
131
|
self.#client.command(['subscribe', getWatchRoot(), self.subscriptionName, options], onSubscribe);
|
|
143
132
|
}
|
|
144
133
|
const onSubscribe = (error, resp) => {
|
|
@@ -190,8 +179,7 @@ class WatchmanWatcher extends AbstractWatcher_1.AbstractWatcher {
|
|
|
190
179
|
if (type != null && !(type === 'f' || type === 'd' || type === 'l')) {
|
|
191
180
|
return;
|
|
192
181
|
}
|
|
193
|
-
if (this.doIgnore(relativePath) ||
|
|
194
|
-
!common.includedByGlob(type, this.globs, this.dot, relativePath)) {
|
|
182
|
+
if (this.doIgnore(relativePath) || !common.isIncluded(type, this.included, relativePath)) {
|
|
195
183
|
return;
|
|
196
184
|
}
|
|
197
185
|
const clock = typeof rawClock === 'string' && this.#watchProjectInfo != null
|
|
@@ -8,23 +8,27 @@
|
|
|
8
8
|
* https://github.com/amasad/sane/blob/64ff3a870c42e84f744086884bf55a4f9c22d376/src/common.js
|
|
9
9
|
*/
|
|
10
10
|
import type { Stats } from 'fs';
|
|
11
|
-
import type { ChangeEventMetadata } from '../types';
|
|
11
|
+
import type { ChangeEventMetadata, WatcherIncludedFiles } from '../types';
|
|
12
12
|
export declare const DELETE_EVENT = "delete";
|
|
13
13
|
export declare const TOUCH_EVENT = "touch";
|
|
14
14
|
export declare const RECRAWL_EVENT = "recrawl";
|
|
15
15
|
export declare const ALL_EVENT = "all";
|
|
16
16
|
export interface WatcherOptions {
|
|
17
|
-
readonly
|
|
18
|
-
readonly dot: boolean;
|
|
17
|
+
readonly included: WatcherIncludedFiles | null | undefined;
|
|
19
18
|
readonly ignored: RegExp | null | undefined;
|
|
20
19
|
readonly watchmanDeferStates: readonly string[];
|
|
21
20
|
readonly watchman?: unknown;
|
|
22
21
|
readonly watchmanPath?: string;
|
|
23
22
|
}
|
|
24
23
|
/**
|
|
25
|
-
*
|
|
24
|
+
* Whether a watcher should report a change at the given relative path. Only
|
|
25
|
+
* regular files are checked against `included`, and every file is included
|
|
26
|
+
* when it is null.
|
|
27
|
+
*
|
|
28
|
+
* A file matches an extension when its basename ends with `.` followed by
|
|
29
|
+
* that extension, so `.env` matches `env` and `foo.d.ts` matches `d.ts`.
|
|
26
30
|
*/
|
|
27
|
-
export declare function
|
|
31
|
+
export declare function isIncluded(type: 'f' | 'l' | 'd' | null | undefined, included: WatcherIncludedFiles | null | undefined, relativePath: string): boolean;
|
|
28
32
|
/**
|
|
29
33
|
* Whether the given filePath matches the given RegExp, after converting
|
|
30
34
|
* (on Windows only) system separators to posix separators.
|
package/build/watchers/common.js
CHANGED
|
@@ -13,24 +13,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.posixPathMatchesPattern = exports.ALL_EVENT = exports.RECRAWL_EVENT = exports.TOUCH_EVENT = exports.DELETE_EVENT = void 0;
|
|
16
|
-
exports.
|
|
16
|
+
exports.isIncluded = isIncluded;
|
|
17
17
|
exports.typeFromStat = typeFromStat;
|
|
18
|
-
const micromatch_1 = __importDefault(require("micromatch"));
|
|
19
18
|
const path_1 = __importDefault(require("path"));
|
|
20
19
|
exports.DELETE_EVENT = 'delete';
|
|
21
20
|
exports.TOUCH_EVENT = 'touch';
|
|
22
21
|
exports.RECRAWL_EVENT = 'recrawl';
|
|
23
22
|
exports.ALL_EVENT = 'all';
|
|
24
23
|
/**
|
|
25
|
-
*
|
|
24
|
+
* Whether a watcher should report a change at the given relative path. Only
|
|
25
|
+
* regular files are checked against `included`, and every file is included
|
|
26
|
+
* when it is null.
|
|
27
|
+
*
|
|
28
|
+
* A file matches an extension when its basename ends with `.` followed by
|
|
29
|
+
* that extension, so `.env` matches `env` and `foo.d.ts` matches `d.ts`.
|
|
26
30
|
*/
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
function isIncluded(type, included, relativePath) {
|
|
32
|
+
if (included == null || type !== 'f') {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
const basename = path_1.default.basename(relativePath);
|
|
36
|
+
return (hasIncludedExtension(included.extensions, basename) ||
|
|
37
|
+
included.basenames.has(basename) ||
|
|
38
|
+
included.basenamePrefixes.some((prefix) => basename.startsWith(prefix)));
|
|
39
|
+
}
|
|
40
|
+
function hasIncludedExtension(extensions, basename) {
|
|
41
|
+
for (let i = basename.indexOf('.'); i !== -1; i = basename.indexOf('.', i + 1)) {
|
|
42
|
+
if (extensions.has(basename.slice(i + 1))) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
32
45
|
}
|
|
33
|
-
return
|
|
46
|
+
return false;
|
|
34
47
|
}
|
|
35
48
|
/**
|
|
36
49
|
* Whether the given filePath matches the given RegExp, after converting
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/metro-file-map",
|
|
3
|
-
"version": "57.0.
|
|
3
|
+
"version": "57.0.4",
|
|
4
4
|
"description": "A metro-file-map fork for Expo used with the Metro bundler",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
"fb-watchman": "^2.0.2",
|
|
27
27
|
"invariant": "^2.2.4",
|
|
28
28
|
"jest-worker": "^29.7.0",
|
|
29
|
-
"micromatch": "^4.0.4",
|
|
30
29
|
"walker": "^1.0.8"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
@@ -34,7 +33,6 @@
|
|
|
34
33
|
"@types/debug": "^4.1.7",
|
|
35
34
|
"@types/fb-watchman": "^2.0.6",
|
|
36
35
|
"@types/invariant": "^2.2.37",
|
|
37
|
-
"@types/micromatch": "^4.0.10",
|
|
38
36
|
"@types/node": "^22.14.0",
|
|
39
37
|
"memfs": "^3.6.0",
|
|
40
38
|
"expo-module-scripts": "56.0.3"
|
|
@@ -42,7 +40,7 @@
|
|
|
42
40
|
"publishConfig": {
|
|
43
41
|
"access": "public"
|
|
44
42
|
},
|
|
45
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "50ac74f1ab5682c8e32b24da6e5e97dd4dbbb80f",
|
|
46
44
|
"scripts": {
|
|
47
45
|
"build": "expo-module tsc",
|
|
48
46
|
"clean": "expo-module clean",
|