@atlaspack/watcher-watchman-js 2.14.5-canary.19 → 2.14.5-canary.191
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/CHANGELOG.md +176 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/wrapper.d.ts +27 -0
- package/lib/wrapper.js +3 -6
- package/package.json +14 -10
- package/src/{index.js → index.ts} +2 -1
- package/src/{wrapper.js → wrapper.ts} +39 -33
- package/tsconfig.json +4 -0
- package/lib/index.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,181 @@
|
|
|
1
1
|
# @atlaspack/watcher-watchman-js
|
|
2
2
|
|
|
3
|
+
## 2.14.29
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies []:
|
|
8
|
+
- @atlaspack/utils@2.19.1
|
|
9
|
+
- @atlaspack/logger@2.14.21
|
|
10
|
+
|
|
11
|
+
## 2.14.28
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#758](https://github.com/atlassian-labs/atlaspack/pull/758) [`c940954`](https://github.com/atlassian-labs/atlaspack/commit/c940954d27d657c3c93cd328dfb394778da46eab) Thanks [@marcins](https://github.com/marcins)! - Type fixes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`f0349a6`](https://github.com/atlassian-labs/atlaspack/commit/f0349a6b9b04755088f121095ca6301a2ada3767)]:
|
|
18
|
+
- @atlaspack/utils@2.19.0
|
|
19
|
+
- @atlaspack/logger@2.14.20
|
|
20
|
+
|
|
21
|
+
## 2.14.27
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies []:
|
|
26
|
+
- @atlaspack/utils@2.18.4
|
|
27
|
+
- @atlaspack/logger@2.14.19
|
|
28
|
+
|
|
29
|
+
## 2.14.26
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- [#742](https://github.com/atlassian-labs/atlaspack/pull/742) [`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd) Thanks [@yamadapc](https://github.com/yamadapc)! - Internal changes and bug fixes to environmentDeduplication flag
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd), [`889c65c`](https://github.com/atlassian-labs/atlaspack/commit/889c65cd25b811045e26a117e7404f694dde77a2)]:
|
|
36
|
+
- @atlaspack/logger@2.14.18
|
|
37
|
+
- @atlaspack/utils@2.18.3
|
|
38
|
+
|
|
39
|
+
## 2.14.25
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Updated dependencies []:
|
|
44
|
+
- @atlaspack/utils@2.18.2
|
|
45
|
+
- @atlaspack/logger@2.14.17
|
|
46
|
+
|
|
47
|
+
## 2.14.24
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- Updated dependencies []:
|
|
52
|
+
- @atlaspack/logger@2.14.16
|
|
53
|
+
- @atlaspack/utils@2.18.1
|
|
54
|
+
|
|
55
|
+
## 2.14.23
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
|
|
60
|
+
- @atlaspack/utils@2.18.0
|
|
61
|
+
- @atlaspack/logger@2.14.15
|
|
62
|
+
|
|
63
|
+
## 2.14.22
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
|
|
68
|
+
|
|
69
|
+
- Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
|
|
70
|
+
- @atlaspack/logger@2.14.14
|
|
71
|
+
- @atlaspack/utils@2.17.4
|
|
72
|
+
|
|
73
|
+
## 2.14.21
|
|
74
|
+
|
|
75
|
+
### Patch Changes
|
|
76
|
+
|
|
77
|
+
- Updated dependencies []:
|
|
78
|
+
- @atlaspack/utils@2.17.3
|
|
79
|
+
|
|
80
|
+
## 2.14.20
|
|
81
|
+
|
|
82
|
+
### Patch Changes
|
|
83
|
+
|
|
84
|
+
- Updated dependencies []:
|
|
85
|
+
- @atlaspack/utils@2.17.2
|
|
86
|
+
|
|
87
|
+
## 2.14.19
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- Updated dependencies []:
|
|
92
|
+
- @atlaspack/utils@2.17.1
|
|
93
|
+
|
|
94
|
+
## 2.14.18
|
|
95
|
+
|
|
96
|
+
### Patch Changes
|
|
97
|
+
|
|
98
|
+
- [#682](https://github.com/atlassian-labs/atlaspack/pull/682) [`a5ed1b4`](https://github.com/atlassian-labs/atlaspack/commit/a5ed1b414498560f393ff491af4da25b6e8dde56) Thanks [@alshdavid](https://github.com/alshdavid)! - Updating build system
|
|
99
|
+
|
|
100
|
+
- Updated dependencies [[`dbb4072`](https://github.com/atlassian-labs/atlaspack/commit/dbb40721ebeb45990a14ba04e6b44e7f836fb32d), [`de23e0c`](https://github.com/atlassian-labs/atlaspack/commit/de23e0ce49d5504fe3947ac26640a3d951087da3), [`18a57cf`](https://github.com/atlassian-labs/atlaspack/commit/18a57cf8a4789b2de5ad8e2676f317a26cc91417), [`a5ed1b4`](https://github.com/atlassian-labs/atlaspack/commit/a5ed1b414498560f393ff491af4da25b6e8dde56)]:
|
|
101
|
+
- @atlaspack/utils@2.17.0
|
|
102
|
+
- @atlaspack/logger@2.14.13
|
|
103
|
+
|
|
104
|
+
## 2.14.17
|
|
105
|
+
|
|
106
|
+
### Patch Changes
|
|
107
|
+
|
|
108
|
+
- Updated dependencies []:
|
|
109
|
+
- @atlaspack/logger@2.14.12
|
|
110
|
+
- @atlaspack/utils@2.16.1
|
|
111
|
+
|
|
112
|
+
## 2.14.16
|
|
113
|
+
|
|
114
|
+
### Patch Changes
|
|
115
|
+
|
|
116
|
+
- Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
|
|
117
|
+
- @atlaspack/utils@2.16.0
|
|
118
|
+
|
|
119
|
+
## 2.14.15
|
|
120
|
+
|
|
121
|
+
### Patch Changes
|
|
122
|
+
|
|
123
|
+
- Updated dependencies []:
|
|
124
|
+
- @atlaspack/utils@2.15.3
|
|
125
|
+
|
|
126
|
+
## 2.14.14
|
|
127
|
+
|
|
128
|
+
### Patch Changes
|
|
129
|
+
|
|
130
|
+
- Updated dependencies []:
|
|
131
|
+
- @atlaspack/utils@2.15.2
|
|
132
|
+
|
|
133
|
+
## 2.14.13
|
|
134
|
+
|
|
135
|
+
### Patch Changes
|
|
136
|
+
|
|
137
|
+
- Updated dependencies [[`ef3d622`](https://github.com/atlassian-labs/atlaspack/commit/ef3d6228f4e006702198a19c61e051d194d325cb)]:
|
|
138
|
+
- @atlaspack/logger@2.14.11
|
|
139
|
+
- @atlaspack/utils@2.15.1
|
|
140
|
+
|
|
141
|
+
## 2.14.12
|
|
142
|
+
|
|
143
|
+
### Patch Changes
|
|
144
|
+
|
|
145
|
+
- Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
|
|
146
|
+
- @atlaspack/utils@2.15.0
|
|
147
|
+
|
|
148
|
+
## 2.14.11
|
|
149
|
+
|
|
150
|
+
### Patch Changes
|
|
151
|
+
|
|
152
|
+
- Updated dependencies []:
|
|
153
|
+
- @atlaspack/utils@2.14.11
|
|
154
|
+
|
|
155
|
+
## 2.14.10
|
|
156
|
+
|
|
157
|
+
### Patch Changes
|
|
158
|
+
|
|
159
|
+
- Updated dependencies []:
|
|
160
|
+
- @atlaspack/logger@2.14.10
|
|
161
|
+
- @atlaspack/utils@2.14.10
|
|
162
|
+
|
|
163
|
+
## 2.14.9
|
|
164
|
+
|
|
165
|
+
### Patch Changes
|
|
166
|
+
|
|
167
|
+
- Updated dependencies []:
|
|
168
|
+
- @atlaspack/logger@2.14.9
|
|
169
|
+
- @atlaspack/utils@2.14.9
|
|
170
|
+
|
|
171
|
+
## 2.14.8
|
|
172
|
+
|
|
173
|
+
### Patch Changes
|
|
174
|
+
|
|
175
|
+
- Updated dependencies []:
|
|
176
|
+
- @atlaspack/utils@2.14.8
|
|
177
|
+
- @atlaspack/logger@2.14.8
|
|
178
|
+
|
|
3
179
|
## 2.14.7
|
|
4
180
|
|
|
5
181
|
### Patch Changes
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const writeSnapshot: (dir: string, snapshot: string, opts?: import("@parcel/watcher").Options) => Promise<string>;
|
|
2
|
+
export declare const getEventsSince: (dir: string, snapshot: string, opts?: import("@parcel/watcher").Options) => Promise<Array<import("@parcel/watcher").Event>>;
|
|
3
|
+
export declare const subscribe: (dir: string, fn: import("@parcel/watcher").SubscribeCallback, opts?: import("@parcel/watcher").Options) => Promise<import("@parcel/watcher").AsyncSubscription>;
|
|
4
|
+
export declare const unsubscribe: (dir: string, fn: import("@parcel/watcher").SubscribeCallback, opts?: import("@parcel/watcher").Options) => Promise<void>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as watchman from 'fb-watchman';
|
|
2
|
+
import type { Options, Event, SubscribeCallback, AsyncSubscription } from '@parcel/watcher';
|
|
3
|
+
type WatchmanArgs = any;
|
|
4
|
+
type FilePath = string;
|
|
5
|
+
type GlobPattern = string;
|
|
6
|
+
export interface Watcher {
|
|
7
|
+
getEventsSince(dir: FilePath, snapshot: FilePath, opts?: Options): Promise<Array<Event>>;
|
|
8
|
+
subscribe(dir: FilePath, fn: SubscribeCallback, opts?: Options): Promise<AsyncSubscription>;
|
|
9
|
+
unsubscribe(dir: FilePath, fn: SubscribeCallback, opts?: Options): Promise<void>;
|
|
10
|
+
writeSnapshot(dir: FilePath, snapshot: FilePath, opts?: Options): Promise<FilePath>;
|
|
11
|
+
}
|
|
12
|
+
export declare class AtlaspackWatcherWatchmanJS implements Watcher {
|
|
13
|
+
subscriptionName: string;
|
|
14
|
+
client: watchman.Client;
|
|
15
|
+
initPromise: Promise<void> | undefined;
|
|
16
|
+
constructor();
|
|
17
|
+
commandAsync(args: WatchmanArgs): Promise<any>;
|
|
18
|
+
capabilityCheckAsync(args: any): Promise<any>;
|
|
19
|
+
_init(watchDir: string): Promise<void>;
|
|
20
|
+
init(watchDir: string): Promise<void>;
|
|
21
|
+
writeSnapshot(dir: string, snapshot: FilePath): Promise<string>;
|
|
22
|
+
getEventsSince(dir: string, snapshot: FilePath, opts?: Options): Promise<Event[]>;
|
|
23
|
+
_createExpression(dir: string, ignore?: Array<FilePath | GlobPattern>): WatchmanArgs;
|
|
24
|
+
subscribe(dir: string, fn: SubscribeCallback, opts?: Options): Promise<AsyncSubscription>;
|
|
25
|
+
unsubscribe(dir: string): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
package/lib/wrapper.js
CHANGED
|
@@ -43,6 +43,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
43
43
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
44
44
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
45
45
|
// Matches the Watcher API from "@parcel/watcher"
|
|
46
|
+
|
|
46
47
|
class AtlaspackWatcherWatchmanJS {
|
|
47
48
|
constructor() {
|
|
48
49
|
this.subscriptionName = 'parcel-watcher-subscription-' + Date.now();
|
|
@@ -51,9 +52,7 @@ class AtlaspackWatcherWatchmanJS {
|
|
|
51
52
|
commandAsync(args) {
|
|
52
53
|
return new Promise((resolve, reject) => {
|
|
53
54
|
const client = this.client;
|
|
54
|
-
client.command(args,
|
|
55
|
-
// $FlowFixMe
|
|
56
|
-
(err, response) => {
|
|
55
|
+
client.command(args, (err, response) => {
|
|
57
56
|
if (err) reject(err);else resolve(response);
|
|
58
57
|
});
|
|
59
58
|
});
|
|
@@ -61,9 +60,7 @@ class AtlaspackWatcherWatchmanJS {
|
|
|
61
60
|
capabilityCheckAsync(args) {
|
|
62
61
|
return new Promise((resolve, reject) => {
|
|
63
62
|
const client = this.client;
|
|
64
|
-
client.capabilityCheck(args,
|
|
65
|
-
// $FlowFixMe
|
|
66
|
-
(err, response) => {
|
|
63
|
+
client.capabilityCheck(args, (err, response) => {
|
|
67
64
|
if (err) reject(err);else resolve(response);
|
|
68
65
|
});
|
|
69
66
|
});
|
package/package.json
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/watcher-watchman-js",
|
|
3
|
-
"version": "2.14.5-canary.
|
|
3
|
+
"version": "2.14.5-canary.191+eedcbc408",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"source": "src/index.
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"source": "./src/index.ts",
|
|
7
|
+
"types": "./lib/index.d.ts",
|
|
7
8
|
"publishConfig": {
|
|
8
9
|
"access": "public"
|
|
9
10
|
},
|
|
10
11
|
"dependencies": {
|
|
11
|
-
"@atlaspack/logger": "2.14.5-canary.
|
|
12
|
-
"@atlaspack/utils": "2.14.5-canary.
|
|
12
|
+
"@atlaspack/logger": "2.14.5-canary.191+eedcbc408",
|
|
13
|
+
"@atlaspack/utils": "2.14.5-canary.191+eedcbc408",
|
|
14
|
+
"@parcel/watcher": "^2.4.1",
|
|
15
|
+
"@types/fb-watchman": "^2.0.2",
|
|
13
16
|
"fb-watchman": "^2.0.2"
|
|
14
17
|
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"@parcel/watcher": "^2.4.1"
|
|
17
|
-
},
|
|
18
18
|
"type": "commonjs",
|
|
19
|
-
"
|
|
20
|
-
|
|
19
|
+
"scripts": {
|
|
20
|
+
"check-ts": "tsc --emitDeclarationOnly --rootDir src",
|
|
21
|
+
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
22
|
+
},
|
|
23
|
+
"gitHead": "eedcbc408fc1e86a2a8e25f1a41c57146d8529e1"
|
|
24
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {AtlaspackWatcherWatchmanJS} from './wrapper';
|
|
2
|
+
import type {Watcher} from './wrapper';
|
|
2
3
|
|
|
3
|
-
const wrapper = new AtlaspackWatcherWatchmanJS();
|
|
4
|
+
const wrapper: Watcher = new AtlaspackWatcherWatchmanJS();
|
|
4
5
|
|
|
5
6
|
export const writeSnapshot = wrapper.writeSnapshot.bind(wrapper);
|
|
6
7
|
export const getEventsSince = wrapper.getEventsSince.bind(wrapper);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import * as fs from 'fs';
|
|
3
2
|
import * as path from 'path';
|
|
4
3
|
import * as watchman from 'fb-watchman';
|
|
@@ -42,39 +41,44 @@ export interface Watcher {
|
|
|
42
41
|
export class AtlaspackWatcherWatchmanJS implements Watcher {
|
|
43
42
|
subscriptionName: string;
|
|
44
43
|
client: watchman.Client;
|
|
45
|
-
initPromise: Promise<void> |
|
|
44
|
+
initPromise: Promise<void> | undefined;
|
|
46
45
|
|
|
47
46
|
constructor() {
|
|
48
47
|
this.subscriptionName = 'parcel-watcher-subscription-' + Date.now();
|
|
49
48
|
this.client = new watchman.Client();
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
commandAsync(args:
|
|
53
|
-
return new Promise(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
commandAsync(args: WatchmanArgs): Promise<any> {
|
|
52
|
+
return new Promise(
|
|
53
|
+
(
|
|
54
|
+
resolve: (result: Promise<never>) => void,
|
|
55
|
+
reject: (error?: any) => void,
|
|
56
|
+
) => {
|
|
57
|
+
const client = this.client;
|
|
58
|
+
client.command(args, (err: Error | null | undefined, response: any) => {
|
|
59
59
|
if (err) reject(err);
|
|
60
60
|
else resolve(response);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
capabilityCheckAsync(args: any): Promise<any> {
|
|
67
|
-
return new Promise(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
return new Promise(
|
|
68
|
+
(
|
|
69
|
+
resolve: (result: Promise<never>) => void,
|
|
70
|
+
reject: (error?: any) => void,
|
|
71
|
+
) => {
|
|
72
|
+
const client = this.client;
|
|
73
|
+
client.capabilityCheck(
|
|
74
|
+
args,
|
|
75
|
+
(err: Error | null | undefined, response: any) => {
|
|
76
|
+
if (err) reject(err);
|
|
77
|
+
else resolve(response);
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
},
|
|
81
|
+
);
|
|
78
82
|
}
|
|
79
83
|
async _init(watchDir: string): Promise<void> {
|
|
80
84
|
await this.capabilityCheckAsync({optional: [], required: []});
|
|
@@ -146,17 +150,19 @@ export class AtlaspackWatcherWatchmanJS implements Watcher {
|
|
|
146
150
|
];
|
|
147
151
|
|
|
148
152
|
if (ignore) {
|
|
149
|
-
const customIgnores = ignore?.map(
|
|
150
|
-
|
|
153
|
+
const customIgnores = ignore?.map(
|
|
154
|
+
(filePathOrGlob: FilePath | GlobPattern) => {
|
|
155
|
+
const relative = path.relative(dir, filePathOrGlob);
|
|
151
156
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
157
|
+
if (isGlob(filePathOrGlob)) {
|
|
158
|
+
return ['match', relative, 'wholename'];
|
|
159
|
+
}
|
|
155
160
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
161
|
+
// If pattern is not a glob, then assume it's a directory.
|
|
162
|
+
// Ignoring single files is not currently supported
|
|
163
|
+
return ['dirname', relative];
|
|
164
|
+
},
|
|
165
|
+
);
|
|
160
166
|
|
|
161
167
|
ignores.push(...customIgnores);
|
|
162
168
|
}
|
|
@@ -190,7 +196,7 @@ export class AtlaspackWatcherWatchmanJS implements Watcher {
|
|
|
190
196
|
},
|
|
191
197
|
]);
|
|
192
198
|
|
|
193
|
-
this.client.on('subscription', function (resp) {
|
|
199
|
+
this.client.on('subscription', function (resp: any) {
|
|
194
200
|
if (!resp.files || resp.subscription !== subscriptionName) {
|
|
195
201
|
return;
|
|
196
202
|
}
|
package/tsconfig.json
ADDED
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;ACyCO,MAAMA;IAKXY,aAAc;QACZ,IAAI,CAACC,gBAAgB,GAAG,iCAAiCC,KAAKC,GAAG;QACjE,IAAI,CAACC,MAAM,GAAG,IAAIP;IACpB;IAEAS,aAAaC,IAAW,EAAgB;QACtC,OAAO,IAA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/index.js","packages/utils/atlaspack-watcher-watchman-js/src/wrapper.js"],"sourcesContent":["import {AtlaspackWatcherWatchmanJS} from './wrapper';\n\nconst wrapper = new AtlaspackWatcherWatchmanJS();\n\nexport const writeSnapshot = wrapper.writeSnapshot.bind(wrapper);\nexport const getEventsSince = wrapper.getEventsSince.bind(wrapper);\nexport const subscribe = wrapper.subscribe.bind(wrapper);\nexport const unsubscribe = wrapper.unsubscribe.bind(wrapper);\n","// @flow\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as watchman from 'fb-watchman';\nimport {isGlob} from '@atlaspack/utils';\nimport logger from '@atlaspack/logger';\nimport type {\n Options,\n Event,\n SubscribeCallback,\n AsyncSubscription,\n} from '@parcel/watcher';\n\ntype WatchmanArgs = any;\ntype FilePath = string;\ntype GlobPattern = string;\n\n// Matches the Watcher API from \"@parcel/watcher\"\nexport interface Watcher {\n getEventsSince(\n dir: FilePath,\n snapshot: FilePath,\n opts?: Options,\n ): Promise<Array<Event>>;\n subscribe(\n dir: FilePath,\n fn: SubscribeCallback,\n opts?: Options,\n ): Promise<AsyncSubscription>;\n unsubscribe(\n dir: FilePath,\n fn: SubscribeCallback,\n opts?: Options,\n ): Promise<void>;\n writeSnapshot(\n dir: FilePath,\n snapshot: FilePath,\n opts?: Options,\n ): Promise<FilePath>;\n}\n\nexport class AtlaspackWatcherWatchmanJS implements Watcher {\n subscriptionName: string;\n client: watchman.Client;\n initPromise: Promise<void> | void;\n\n constructor() {\n this.subscriptionName = 'parcel-watcher-subscription-' + Date.now();\n this.client = new watchman.Client();\n }\n\n commandAsync(args: any[]): Promise<any> {\n return new Promise((resolve, reject) => {\n const client = this.client;\n client.command(\n args,\n // $FlowFixMe\n (err: Error | null | undefined, response: any) => {\n if (err) reject(err);\n else resolve(response);\n },\n );\n });\n }\n\n capabilityCheckAsync(args: any): Promise<any> {\n return new Promise((resolve, reject) => {\n const client = this.client;\n client.capabilityCheck(\n args,\n // $FlowFixMe\n (err: Error | null | undefined, response: any) => {\n if (err) reject(err);\n else resolve(response);\n },\n );\n });\n }\n async _init(watchDir: string): Promise<void> {\n await this.capabilityCheckAsync({optional: [], required: []});\n const resp = await this.commandAsync(['watch-project', watchDir]);\n\n if ('warning' in resp) {\n logger.warn({message: resp.warning});\n }\n }\n\n init(watchDir: string): Promise<void> {\n if (this.initPromise) {\n return this.initPromise;\n }\n\n this.initPromise = this._init(watchDir);\n\n return this.initPromise;\n }\n\n // Types should match @parcel/watcher/index.js.flow\n async writeSnapshot(dir: string, snapshot: FilePath): Promise<string> {\n await this.init(dir);\n\n const response = await this.commandAsync(['clock', dir]);\n fs.mkdirSync(path.dirname(snapshot), {recursive: true});\n fs.writeFileSync(snapshot, response.clock, {\n encoding: 'utf-8',\n });\n return response.clock;\n }\n\n async getEventsSince(\n dir: string,\n snapshot: FilePath,\n opts?: Options,\n ): Promise<Event[]> {\n await this.init(dir);\n\n const clock = fs.readFileSync(snapshot, {\n encoding: 'utf-8',\n });\n\n const response = await this.commandAsync([\n 'query',\n dir,\n {\n expression: this._createExpression(dir, opts?.ignore),\n fields: ['name', 'mode', 'exists', 'new'],\n since: clock,\n },\n ]);\n\n return (response.files || []).map((file: any) => ({\n path: file.name,\n type: file.new ? 'create' : file.exists ? 'update' : 'delete',\n }));\n }\n\n _createExpression(\n dir: string,\n ignore?: Array<FilePath | GlobPattern>,\n ): WatchmanArgs {\n const ignores = [\n // Ignore the watchman cookie\n ['match', '.watchman-cookie-*'],\n // Ignore directory changes as they are just noise\n ['type', 'd'],\n ];\n\n if (ignore) {\n const customIgnores = ignore?.map((filePathOrGlob) => {\n const relative = path.relative(dir, filePathOrGlob);\n\n if (isGlob(filePathOrGlob)) {\n return ['match', relative, 'wholename'];\n }\n\n // If pattern is not a glob, then assume it's a directory.\n // Ignoring single files is not currently supported\n return ['dirname', relative];\n });\n\n ignores.push(...customIgnores);\n }\n\n return ['not', ['anyof', ...ignores]];\n }\n\n async subscribe(\n dir: string,\n fn: SubscribeCallback,\n opts?: Options,\n ): Promise<AsyncSubscription> {\n await this.init(dir);\n\n const {subscriptionName} = this;\n const {clock} = await this.commandAsync(['clock', dir]);\n\n await this.commandAsync([\n 'subscribe',\n dir,\n subscriptionName,\n {\n // `defer` can be used here if you want to pause the\n // notification stream until something has finished.\n //\n // https://facebook.github.io/watchman/docs/cmd/subscribe#defer\n // defer: ['my-company-example'],\n expression: this._createExpression(dir, opts?.ignore),\n fields: ['name', 'mode', 'exists', 'new'],\n since: clock,\n },\n ]);\n\n this.client.on('subscription', function (resp) {\n if (!resp.files || resp.subscription !== subscriptionName) {\n return;\n }\n\n fn(\n null /* err */,\n resp.files.map((file: any) => {\n return {\n path: path.join(dir, file.name),\n type: file.new ? 'create' : file.exists ? 'update' : 'delete',\n };\n }),\n );\n });\n\n const unsubscribe = async () => {\n await this.commandAsync(['unsubscribe', dir, subscriptionName]);\n };\n\n return {\n unsubscribe,\n };\n }\n\n async unsubscribe(dir: string): Promise<void> {\n await this.commandAsync(['unsubscribe', dir, this.subscriptionName]);\n }\n}\n"],"names":["AtlaspackWatcherWatchmanJS","wrapper","writeSnapshot","bind","getEventsSince","subscribe","unsubscribe","fs","path","watchman","isGlob","logger","constructor","subscriptionName","Date","now","client","Client","commandAsync","args","Promise","resolve","reject","command","err","response","capabilityCheckAsync","capabilityCheck","_init","watchDir","optional","required","resp","warn","message","warning","init","initPromise","dir","snapshot","mkdirSync","dirname","recursive","writeFileSync","clock","encoding","opts","readFileSync","expression","_createExpression","ignore","fields","since","files","map","file","name","type","new","exists","ignores","customIgnores","filePathOrGlob","relative","push","fn","on","subscription","join"],"version":3,"file":"index.js.map"}
|